veni18 commited on
Commit
bcb5a2e
·
1 Parent(s): 16bc359
Files changed (1) hide show
  1. app.py +9 -5
app.py CHANGED
@@ -21,16 +21,20 @@ def speechToText(file):
21
  sentences = my_text["text"].split(".")
22
 
23
 
 
 
 
 
 
 
24
 
25
- translation = pipeline("translation", model="Helsinki-NLP/opus-mt-en-hu")
26
 
27
- text_translated=[]
28
- for text in sentences:
29
- text_translated.append(translation(text))
30
 
31
  #combined_text = ' '.join([item['translation_text'] for sublist in text_translated for item in sublist])
32
 
33
- return text_translated
34
 
35
  demo = gr.Interface(fn=speechToText, inputs="file", outputs="text")
36
  demo.launch()
 
21
  sentences = my_text["text"].split(".")
22
 
23
 
24
+ def translate(sentences):
25
+ translation = pipeline("translation", model="Helsinki-NLP/opus-mt-en-hu")
26
+
27
+ text_translated=[]
28
+ for text in sentences:
29
+ text_translated.append(translation(text))
30
 
31
+ return text_translated
32
 
33
+ text_translate = translate(sentences)
 
 
34
 
35
  #combined_text = ' '.join([item['translation_text'] for sublist in text_translated for item in sublist])
36
 
37
+ return text_translate
38
 
39
  demo = gr.Interface(fn=speechToText, inputs="file", outputs="text")
40
  demo.launch()