vladelesin commited on
Commit
bcb5aac
·
1 Parent(s): 2dcbe47

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +8 -8
app.py CHANGED
@@ -1,5 +1,4 @@
1
- # -*- coding: utf-8 -*-
2
- """app.ipynb
3
  Automatically generated by Colaboratory.
4
  Original file is located at
5
  https://colab.research.google.com/drive/16MxXQeF3O0htL9eQ61aa6ZxnApGg9TKN
@@ -9,17 +8,18 @@ import gradio as gr
9
  import numpy as np
10
  import torch
11
 
12
- from transformers import pipeline, VitsModel, VitsTokenizer, FSMTForConditionalGeneration, FSMTTokenizer
 
13
 
14
  device = "cuda:0" if torch.cuda.is_available() else "cpu"
15
 
16
- #eng audio to text transformation
17
  asr_pipe = pipeline("automatic-speech-recognition", model="asapp/sew-d-tiny-100k-ft-ls100h", device=device)
18
 
19
- #eng text to rus text translation
20
- translation_pipe = pipeline("translation", model="Helsinki-NLP/opus-mt-en-ru")
21
 
22
- #rus text to rus speech transformation
23
  vits_model = VitsModel.from_pretrained("facebook/mms-tts-rus")
24
  vits_tokenizer = VitsTokenizer.from_pretrained("facebook/mms-tts-rus")
25
 
@@ -28,7 +28,7 @@ def transform_audio_to_speech_en(audio):
28
  return outputs["text"]
29
 
30
  def translator(text):
31
- translated_text = translation_pipe(text)
32
  return translated_text[0]['translation_text']
33
 
34
  def synthesise(translated_text):
 
1
+ """
 
2
  Automatically generated by Colaboratory.
3
  Original file is located at
4
  https://colab.research.google.com/drive/16MxXQeF3O0htL9eQ61aa6ZxnApGg9TKN
 
8
  import numpy as np
9
  import torch
10
 
11
+ from transformers import pipeline
12
+ from transformers import VitsModel, VitsTokenizer, FSMTForConditionalGeneration, FSMTTokenizer
13
 
14
  device = "cuda:0" if torch.cuda.is_available() else "cpu"
15
 
16
+ # Transform audio to en text
17
  asr_pipe = pipeline("automatic-speech-recognition", model="asapp/sew-d-tiny-100k-ft-ls100h", device=device)
18
 
19
+ # Translate en to rus text
20
+ translation_en_to_rus = pipeline("translation", model="Helsinki-NLP/opus-mt-en-ru")
21
 
22
+ # Create speech from rus text
23
  vits_model = VitsModel.from_pretrained("facebook/mms-tts-rus")
24
  vits_tokenizer = VitsTokenizer.from_pretrained("facebook/mms-tts-rus")
25
 
 
28
  return outputs["text"]
29
 
30
  def translator(text):
31
+ translated_text = translation_en_to_rus(text)
32
  return translated_text[0]['translation_text']
33
 
34
  def synthesise(translated_text):