shamik commited on
Commit
c705c41
1 Parent(s): 2465f9d

Modified the app.

Browse files
Files changed (1) hide show
  1. app.py +5 -1
app.py CHANGED
@@ -30,11 +30,15 @@ def synthesise(text):
30
  speech = outputs["waveform"]
31
  return speech
32
 
 
 
 
33
 
34
  def speech_to_speech_translation(audio):
35
  translated_text = translate(audio)
36
  synthesised_speech = synthesise(translated_text)
37
- synthesised_speech = (synthesised_speech.squeeze().numpy() * 32767).astype(np.int16)
 
38
  return 16000, synthesised_speech
39
 
40
 
 
30
  speech = outputs["waveform"]
31
  return speech
32
 
33
+ # converting the output audio array to int16,which is expected by gradio
34
+ target_dtype = np.int16
35
+ max_range = np.iinfo(target_dtype).max
36
 
37
  def speech_to_speech_translation(audio):
38
  translated_text = translate(audio)
39
  synthesised_speech = synthesise(translated_text)
40
+ # converting for gradio
41
+ synthesised_speech = (synthesised_speech.squeeze().numpy() * max_range).astype(np.int16)
42
  return 16000, synthesised_speech
43
 
44