Spaces:
Paused
Paused
Update app.py
Browse files
app.py
CHANGED
@@ -34,14 +34,12 @@ def whisper_speech_demo(text, lang, speaker_audio, mix_lang, mix_text):
|
|
34 |
audio_data = pipe.generate(text, speaker_url, lang)
|
35 |
|
36 |
resample_audio = resampler(newsr=24000)
|
37 |
-
audio_data_resampled = next(resample_audio([{'sample_rate':
|
38 |
-
|
39 |
-
# Normalize audio
|
40 |
audio_np = audio_data_resampled.cpu().numpy()
|
41 |
audio_np = audio_np / np.max(np.abs(audio_np))
|
42 |
-
|
43 |
with tempfile.NamedTemporaryFile(suffix='.wav', delete=False) as tmp_file:
|
44 |
-
sf.write(tmp_file.name,
|
45 |
return tmp_file.name
|
46 |
|
47 |
with gr.Blocks() as demo:
|
|
|
34 |
audio_data = pipe.generate(text, speaker_url, lang)
|
35 |
|
36 |
resample_audio = resampler(newsr=24000)
|
37 |
+
audio_data_resampled = next(resample_audio([{'sample_rate': 24000, 'samples': audio_data.cpu()}]))['samples_24k']
|
|
|
|
|
38 |
audio_np = audio_data_resampled.cpu().numpy()
|
39 |
audio_np = audio_np / np.max(np.abs(audio_np))
|
40 |
+
audio_np = np.asarray(audio_np, dtype=np.float32)
|
41 |
with tempfile.NamedTemporaryFile(suffix='.wav', delete=False) as tmp_file:
|
42 |
+
sf.write(tmp_file.name, audio_stereo, 24000, format='WAV', subtype='PCM_16')
|
43 |
return tmp_file.name
|
44 |
|
45 |
with gr.Blocks() as demo:
|