try
Browse files
app.py
ADDED
@@ -0,0 +1,23 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import gradio as gr
|
2 |
+
from transformers import pipeline
|
3 |
+
|
4 |
+
def transcribe_speech(filepath):
|
5 |
+
model_id = "chaouch/whisper-small-dv" # update with your model id
|
6 |
+
pipe = pipeline("automatic-speech-recognition", model=model_id)
|
7 |
+
output = pipe(
|
8 |
+
filepath,
|
9 |
+
max_new_tokens=256,
|
10 |
+
generate_kwargs={
|
11 |
+
"task": "transcribe",
|
12 |
+
"language": "sinhalese",
|
13 |
+
}, # update with the language you've fine-tuned on
|
14 |
+
chunk_length_s=30,
|
15 |
+
batch_size=8,
|
16 |
+
)
|
17 |
+
return output["text"]
|
18 |
+
|
19 |
+
if __name__ == "__main__":
|
20 |
+
demo = gr.Interface(fn=transcribe_speech,
|
21 |
+
inputs=gr.Audio(sources="microphone", type="file"),
|
22 |
+
outputs=gr.Textbox())
|
23 |
+
demo.launch(debug=True)
|