TruongScotl
commited on
Commit
•
9f724f2
1
Parent(s):
37195cf
Update app.py
Browse files
app.py
CHANGED
@@ -1,14 +1,30 @@
|
|
1 |
import gradio as gr
|
|
|
2 |
|
3 |
-
|
|
|
|
|
|
|
4 |
description = """
|
5 |
<p>
|
6 |
<center>
|
7 |
-
Open your
|
8 |
<img src="https://huggingface.co/spaces/course-demos/Rick_and_Morty_QA/resolve/main/rick.png" width=200px>
|
9 |
</center>
|
10 |
</p>
|
11 |
"""
|
12 |
|
13 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
14 |
|
|
|
1 |
import gradio as gr
|
2 |
+
from transformers import pipeline
|
3 |
|
4 |
+
|
5 |
+
inputs=gr.Audio(type="filepath")
|
6 |
+
pipe = pipeline(model="models/TruongScotl/stvietnamese2")
|
7 |
+
title = "Speech to Text Translation"
|
8 |
description = """
|
9 |
<p>
|
10 |
<center>
|
11 |
+
Open your eyes Morty, that translator is mind-blowing. Drop the damn file, Morty!
|
12 |
<img src="https://huggingface.co/spaces/course-demos/Rick_and_Morty_QA/resolve/main/rick.png" width=200px>
|
13 |
</center>
|
14 |
</p>
|
15 |
"""
|
16 |
|
17 |
+
def translate(audio):
|
18 |
+
text = pipe(audio)["text"]
|
19 |
+
return text
|
20 |
+
|
21 |
+
translate = gr.Interface(
|
22 |
+
fn=translate,
|
23 |
+
inputs=inputs,
|
24 |
+
outputs="text",
|
25 |
+
title=title,
|
26 |
+
description=description
|
27 |
+
)
|
28 |
+
|
29 |
+
translate.launch()
|
30 |
|