thak123 commited on
Commit
b357c71
1 Parent(s): d70ead9

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +31 -0
app.py CHANGED
@@ -0,0 +1,31 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from transformers import WhisperTokenizer
2
+
3
+ tokenizer = WhisperTokenizer.from_pretrained("openai/whisper-small", language="marathi", task="transcribe")
4
+
5
+ from transformers import pipeline
6
+ import gradio as gr
7
+ import torch
8
+
9
+ pipe = pipeline(model="thak123/whisper-small-gom",
10
+ task="automatic-speech-recognition", tokenizer= tokenizer) # change to "your-username/the-name-you-picked"
11
+
12
+ pipe.model.config.forced_decoder_ids = (
13
+ pipe.tokenizer.get_decoder_prompt_ids(
14
+ language="marathi", task="transcribe"
15
+ )
16
+ )
17
+
18
+ def transcribe(audio):
19
+ text = pipe(audio)["text"]
20
+ return text
21
+
22
+ iface = gr.Interface(
23
+ fn=transcribe,
24
+ inputs=gr.Audio(source="microphone", type="filepath"),
25
+ outputs="text",
26
+ title="Whisper Small Konkani",
27
+ description="Realtime demo for Konkani speech recognition using a fine-tuned Whisper small model.",
28
+ )
29
+
30
+
31
+ iface.launch()