heisenberg3376 commited on
Commit
1864517
1 Parent(s): bcd35fa

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +4 -3
app.py CHANGED
@@ -24,14 +24,15 @@ def translate(audio):
24
 
25
  def synthesise(text):
26
  inputs = tokenizer(text=text, return_tensors="pt")
27
- speech = model(**inputs).waveform
28
- speech = speech.detach().cpu().numpy()
29
- return speech
30
 
31
 
32
  def speech_to_speech_translation(audio):
33
  translated_text = translate(audio)
34
  synthesised_speech = synthesise(translated_text)
 
35
  return 16000, synthesised_speech
36
 
37
 
 
24
 
25
  def synthesise(text):
26
  inputs = tokenizer(text=text, return_tensors="pt")
27
+ with torch.no_grad():
28
+ speech = model(**inputs).waveform
29
+ return speech.cpu()
30
 
31
 
32
  def speech_to_speech_translation(audio):
33
  translated_text = translate(audio)
34
  synthesised_speech = synthesise(translated_text)
35
+ synthesised_speech = (synthesised_speech.numpy() * 32767).astype(np.int16)
36
  return 16000, synthesised_speech
37
 
38