Spaces:
Running on Zero
Running on Zero
Return an AIFF input as WAV
Browse filesHARP accepts .aif, the extension Logic Pro gives AIFF, but soundfile cannot write a file named with it, so such an input failed when its result was written, inside the GPU call. Gradio also converts an AIFF output to 16-bit WAV, since browsers cannot play AIFF, so keeping that container gained nothing. Lossless inputs now keep WAV and FLAC alone, and AIFF comes back as WAV at the bit depth this Space writes.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
app.py
CHANGED
|
@@ -28,7 +28,7 @@ model_card = ModelCard(
|
|
| 28 |
)
|
| 29 |
|
| 30 |
# A lossless input keeps its container. A lossy one, the usual input here, comes back as WAV.
|
| 31 |
-
LOSSLESS = {".wav", ".flac"
|
| 32 |
|
| 33 |
def load_audio(file_path):
|
| 34 |
audio, samplerate = torchaudio.load(file_path)
|
|
@@ -170,7 +170,7 @@ def restore(input_audio_path: str) -> str:
|
|
| 170 |
output_audio_path = os.path.join(
|
| 171 |
output_dir, f"output_restored{input_ext if input_ext in LOSSLESS else '.wav'}"
|
| 172 |
)
|
| 173 |
-
# Floating point, as the restoration can exceed full scale, where FLAC
|
| 174 |
sf.write(output_audio_path, result.cpu().numpy().T, input_rate,
|
| 175 |
subtype="FLOAT" if output_audio_path.endswith(".wav") else "PCM_24")
|
| 176 |
print(f"✓ Saved output to {output_audio_path}")
|
|
|
|
| 28 |
)
|
| 29 |
|
| 30 |
# A lossless input keeps its container. A lossy one, the usual input here, comes back as WAV.
|
| 31 |
+
LOSSLESS = {".wav", ".flac"}
|
| 32 |
|
| 33 |
def load_audio(file_path):
|
| 34 |
audio, samplerate = torchaudio.load(file_path)
|
|
|
|
| 170 |
output_audio_path = os.path.join(
|
| 171 |
output_dir, f"output_restored{input_ext if input_ext in LOSSLESS else '.wav'}"
|
| 172 |
)
|
| 173 |
+
# Floating point, as the restoration can exceed full scale, where FLAC takes 24 bits
|
| 174 |
sf.write(output_audio_path, result.cpu().numpy().T, input_rate,
|
| 175 |
subtype="FLOAT" if output_audio_path.endswith(".wav") else "PCM_24")
|
| 176 |
print(f"✓ Saved output to {output_audio_path}")
|