Tonic commited on
Commit
ce9c685
1 Parent(s): ac8fcf0

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +4 -3
app.py CHANGED
@@ -94,12 +94,13 @@ def whisper_speech_demo(multilingual_text, speaker_audio):
94
 
95
  concatenated_audio = concatenate_audio_segments(audio_segments)
96
  print("Final concatenated audio shape:", concatenated_audio.shape) # Debug statement
97
-
98
  # Normalize the concatenated audio
99
  concatenated_audio = concatenated_audio / np.max(np.abs(concatenated_audio))
100
 
101
- # Return the concatenated audio as a NumPy array
102
- return concatenated_audio[0]
 
 
103
 
104
  with gr.Blocks() as demo:
105
  gr.Markdown(title)
 
94
 
95
  concatenated_audio = concatenate_audio_segments(audio_segments)
96
  print("Final concatenated audio shape:", concatenated_audio.shape) # Debug statement
 
97
  # Normalize the concatenated audio
98
  concatenated_audio = concatenated_audio / np.max(np.abs(concatenated_audio))
99
 
100
+ # Write the audio data to a temporary file and return the file path
101
+ with tempfile.NamedTemporaryFile(suffix='.wav', delete=False) as tmp_file:
102
+ sf.write(tmp_file.name, concatenated_audio.T, 24000, format='WAV', subtype='PCM_16')
103
+ return tmp_file.name
104
 
105
  with gr.Blocks() as demo:
106
  gr.Markdown(title)