Tonic commited on
Commit
4c8a999
β€’
1 Parent(s): 50e659a

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +6 -5
app.py CHANGED
@@ -91,14 +91,15 @@ def whisper_speech_demo(multilingual_text, speaker_audio):
91
  audio_np = generate_segment_audio(text_str, lang, speaker_url, pipe)
92
  print("Audio segment shape:", audio_np.shape) # Debug statement
93
  audio_segments.append(audio_np)
 
94
  concatenated_audio = concatenate_audio_segments(audio_segments)
95
  print("Final concatenated audio shape:", concatenated_audio.shape) # Debug statement
96
- # audio_stereo = np.stack((concatenated_audio, concatenated_audio), axis=-1)
97
- # audio_stereo = audio_stereo.reshape(-1, 2)
98
 
99
- with tempfile.NamedTemporaryFile(suffix='.wav', delete=False) as tmp_file:
100
- sf.write(tmp_file.name, concatenated_audio, 24000, format='WAV', subtype='PCM_16')
101
- return tmp_file.name
 
 
102
 
103
  with gr.Blocks() as demo:
104
  gr.Markdown(title)
 
91
  audio_np = generate_segment_audio(text_str, lang, speaker_url, pipe)
92
  print("Audio segment shape:", audio_np.shape) # Debug statement
93
  audio_segments.append(audio_np)
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
103
 
104
  with gr.Blocks() as demo:
105
  gr.Markdown(title)