shamik commited on
Commit
d33896e
1 Parent(s): 8949488

Modified the app.

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