Adbhut commited on
Commit
783b7ae
·
1 Parent(s): 16157cd

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +2 -6
app.py CHANGED
@@ -5,10 +5,8 @@ import torch
5
  from transformers import VitsModel, AutoTokenizer, pipeline
6
 
7
 
8
- device = "cuda:0" if torch.cuda.is_available() else "cpu"
9
-
10
  # load speech translation checkpoint
11
- asr_pipe = pipeline("automatic-speech-recognition", model="openai/whisper-base", device=device)
12
 
13
  # load text-to-speech checkpoint
14
  model = VitsModel.from_pretrained("facebook/mms-tts-fra")
@@ -25,13 +23,11 @@ def translate(audio):
25
 
26
 
27
  def synthesise(text):
28
- print(text)
29
  inputs = tokenizer(text=text, return_tensors="pt")
30
- # inputs['input_ids'] = inputs['input_ids'].long()
31
  with torch.no_grad():
32
  speech = model(**inputs).waveform
33
  speech = speech[0] # remove batch dimension
34
- return speech.cpu()
35
 
36
 
37
  def speech_to_speech_translation(audio):
 
5
  from transformers import VitsModel, AutoTokenizer, pipeline
6
 
7
 
 
 
8
  # load speech translation checkpoint
9
+ asr_pipe = pipeline("automatic-speech-recognition", model="openai/whisper-base")
10
 
11
  # load text-to-speech checkpoint
12
  model = VitsModel.from_pretrained("facebook/mms-tts-fra")
 
23
 
24
 
25
  def synthesise(text):
 
26
  inputs = tokenizer(text=text, return_tensors="pt")
 
27
  with torch.no_grad():
28
  speech = model(**inputs).waveform
29
  speech = speech[0] # remove batch dimension
30
+ return speech
31
 
32
 
33
  def speech_to_speech_translation(audio):