TruongScotl
commited on
Commit
•
83505ca
1
Parent(s):
fa97825
Update app.py
Browse files
app.py
CHANGED
@@ -1,3 +1,29 @@
|
|
|
|
|
|
|
|
|
|
|
|
1 |
import gradio as gr
|
2 |
|
3 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# import gradio as gr
|
2 |
+
|
3 |
+
# gr.load("models/TruongScotl/stvietnamese2").launch()
|
4 |
+
|
5 |
+
from transformers import pipeline
|
6 |
import gradio as gr
|
7 |
|
8 |
+
model = pipeline("models/TruongScotl/stvietnamese2")
|
9 |
+
|
10 |
+
|
11 |
+
def transcribe_audio(mic=None, file=None):
|
12 |
+
if mic is not None:
|
13 |
+
audio = mic
|
14 |
+
elif file is not None:
|
15 |
+
audio = file
|
16 |
+
else:
|
17 |
+
return "You must either provide a mic recording or a file"
|
18 |
+
transcription = model(audio)["text"]
|
19 |
+
return transcription
|
20 |
+
|
21 |
+
|
22 |
+
gr.Interface(
|
23 |
+
fn=transcribe_audio,
|
24 |
+
inputs=[
|
25 |
+
gr.Audio(source="microphone", type="filepath", optional=True),
|
26 |
+
gr.Audio(source="upload", type="filepath", optional=True),
|
27 |
+
],
|
28 |
+
outputs="text",
|
29 |
+
).launch()
|