yuvscherbatov commited on
Commit
b28d750
1 Parent(s): bff9774

Upload app.py

Browse files
Files changed (1) hide show
  1. app.py +3 -11
app.py CHANGED
@@ -19,11 +19,7 @@ device = "cuda:0" if torch.cuda.is_available() else "cpu"
19
  asr_pipe = pipeline("automatic-speech-recognition", model="asapp/sew-d-tiny-100k-ft-ls100h", device=device)
20
 
21
  #eng text to rus text translation
22
- mname = "facebook/wmt19-en-ru"
23
- tokenizer = FSMTTokenizer.from_pretrained(mname)
24
- model = FSMTForConditionalGeneration.from_pretrained(mname)
25
-
26
- #translation_pipe = pipeline("translation", model="facebook/wmt19-en-ru")
27
 
28
  #rus text to rus speech transformation
29
  vits_model = VitsModel.from_pretrained("facebook/mms-tts-rus")
@@ -34,12 +30,8 @@ def transform_audio_to_speech_en(audio):
34
  return outputs["text"]
35
 
36
  def translator(text):
37
- input_ids = tokenizer.encode(text, return_tensors="pt")
38
- outputs = model.generate(input_ids)
39
- decoded = tokenizer.decode(outputs[0], skip_special_tokens=True)
40
- return decoded
41
- #translated_text = translation_pipe(text)
42
- #return translated_text[0]['translation_text']
43
 
44
  def synthesise(translated_text):
45
  translated_text = translator(translated_text)
 
19
  asr_pipe = pipeline("automatic-speech-recognition", model="asapp/sew-d-tiny-100k-ft-ls100h", device=device)
20
 
21
  #eng text to rus text translation
22
+ translation_pipe = pipeline("translation", model="facebook/wmt19-en-ru")
 
 
 
 
23
 
24
  #rus text to rus speech transformation
25
  vits_model = VitsModel.from_pretrained("facebook/mms-tts-rus")
 
30
  return outputs["text"]
31
 
32
  def translator(text):
33
+ translated_text = translation_pipe(text)
34
+ return translated_text[0]['translation_text']
 
 
 
 
35
 
36
  def synthesise(translated_text):
37
  translated_text = translator(translated_text)