heisenberg3376
commited on
Commit
•
5ee8ae8
1
Parent(s):
ac9a553
Update app.py
Browse files
app.py
CHANGED
@@ -1,3 +1,43 @@
|
|
1 |
import gradio as gr
|
2 |
|
3 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
import gradio as gr
|
2 |
|
3 |
+
model_id = 'heisenberg3376/whisper-tiny-minds14'
|
4 |
+
pipe = pipeline("automatic-speech-recognition", model=model_id)
|
5 |
+
|
6 |
+
def transcribe_speech(filepath):
|
7 |
+
output = pipe(
|
8 |
+
filepath,
|
9 |
+
max_new_tokens=256,
|
10 |
+
generate_kwargs={
|
11 |
+
"task": "transcribe",
|
12 |
+
}, # update with the language you've fine-tuned on
|
13 |
+
chunk_length_s=30,
|
14 |
+
batch_size=8,
|
15 |
+
)
|
16 |
+
return output["text"]
|
17 |
+
|
18 |
+
|
19 |
+
|
20 |
+
|
21 |
+
demo = gr.Blocks()
|
22 |
+
|
23 |
+
|
24 |
+
|
25 |
+
mic_transcribe = gr.Interface(
|
26 |
+
fn=transcribe_speech,
|
27 |
+
inputs=gr.Audio(sources="microphone", type="filepath"),
|
28 |
+
outputs=gr.Textbox(),
|
29 |
+
)
|
30 |
+
|
31 |
+
file_transcribe = gr.Interface(
|
32 |
+
fn=transcribe_speech,
|
33 |
+
inputs=gr.Audio(sources="upload", type="filepath"),
|
34 |
+
outputs=gr.Textbox(),
|
35 |
+
)
|
36 |
+
|
37 |
+
with demo:
|
38 |
+
gr.TabbedInterface(
|
39 |
+
[mic_transcribe, file_transcribe],
|
40 |
+
["Transcribe Microphone", "Transcribe Audio File"],
|
41 |
+
)
|
42 |
+
|
43 |
+
demo.launch(debug=True, share=True)
|