translate
Browse files
app.py
CHANGED
@@ -6,7 +6,7 @@ import os
|
|
6 |
|
7 |
def speechToText(file):
|
8 |
|
9 |
-
api_key = os.getenv("veni18sttts")
|
10 |
API_URL = "https://api-inference.huggingface.co/models/openai/whisper-large-v3-turbo"
|
11 |
headers = {"Authorization": f"Bearer {api_key}"}
|
12 |
|
@@ -18,19 +18,19 @@ def speechToText(file):
|
|
18 |
|
19 |
my_text = query(file)
|
20 |
|
21 |
-
|
22 |
|
23 |
-
|
24 |
|
25 |
-
|
26 |
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
|
31 |
#combined_text = ' '.join([item['translation_text'] for sublist in text_translated for item in sublist])
|
32 |
|
33 |
-
|
34 |
|
35 |
demo = gr.Interface(fn=speechToText, inputs="file", outputs="text")
|
36 |
demo.launch()
|
|
|
6 |
|
7 |
def speechToText(file):
|
8 |
|
9 |
+
api_key = os.getenv("veni18sttts")
|
10 |
API_URL = "https://api-inference.huggingface.co/models/openai/whisper-large-v3-turbo"
|
11 |
headers = {"Authorization": f"Bearer {api_key}"}
|
12 |
|
|
|
18 |
|
19 |
my_text = query(file)
|
20 |
|
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()
|