Spaces:
Runtime error
Runtime error
TenzinGayche
commited on
Commit
•
3294ddc
1
Parent(s):
9851902
Update app.py
Browse files
app.py
CHANGED
@@ -0,0 +1,35 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
from transformers import pipeline
|
2 |
+
import gradio as gr
|
3 |
+
import pyewts
|
4 |
+
|
5 |
+
converter = pyewts.pyewts()
|
6 |
+
|
7 |
+
|
8 |
+
|
9 |
+
pipe = pipeline(model="spsither/whisper-small-r2-70k-2ep",device='cuda') # change to "your-username/the-name-you-picked"
|
10 |
+
|
11 |
+
|
12 |
+
def transcribe(microphone, upload):
|
13 |
+
if(microphone):
|
14 |
+
audio = microphone
|
15 |
+
else:
|
16 |
+
audio = upload
|
17 |
+
|
18 |
+
|
19 |
+
text = pipe(audio)["text"]
|
20 |
+
text = remove_repeated_words(text)
|
21 |
+
state = converter.toUnicode(text)
|
22 |
+
return state
|
23 |
+
|
24 |
+
|
25 |
+
# Set the starting state to an empty string
|
26 |
+
|
27 |
+
iface = gr.Interface(
|
28 |
+
fn=transcribe,
|
29 |
+
inputs=[gr.Audio(source="microphone", type="filepath"),gr.Audio(source="upload", type="filepath")],
|
30 |
+
outputs="text",
|
31 |
+
title="Whisper Large Tibetan",
|
32 |
+
description="Realtime demo for Tibetan speech recognition using a fine-tuned Whisper medium model.",
|
33 |
+
)
|
34 |
+
|
35 |
+
iface.launch(share=True,debug=True)
|