harp-dev Claude Opus 5.5 commited on
Commit
028e4e4
·
verified ·
1 Parent(s): f35abfe

Return an AIFF input as WAV

Browse files

HARP 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>

Files changed (1) hide show
  1. app.py +2 -2
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", ".aiff", ".aif"}
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 and AIFF take 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}")
 
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}")