Tonic commited on
Commit
a69166e
1 Parent(s): 806b774

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +3 -5
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': 22050, 'samples': audio_data.cpu()}]))['samples_24k']
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, audio_np, 24000, 'PCM_16')
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: