Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -1,12 +1,41 @@
|
|
1 |
import gradio as gr
|
|
|
|
|
|
|
|
|
2 |
|
3 |
-
|
4 |
-
return "Hello " + name + "!"
|
5 |
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
11 |
|
12 |
demo.launch()
|
|
|
1 |
import gradio as gr
|
2 |
+
from transformers import WhisperForConditionalGeneration
|
3 |
+
from transformers import WhisperFeatureExtractor
|
4 |
+
from transformers import WhisperTokenizer
|
5 |
+
from transformers import pipeline
|
6 |
|
7 |
+
checkpoint = "tsobolev/whisper-small-ka"
|
|
|
8 |
|
9 |
+
feature_extractor = WhisperFeatureExtractor.from_pretrained(checkpoint)
|
10 |
+
tokenizer = WhisperTokenizer.from_pretrained(checkpoint, language="georgian", task="transcribe")
|
11 |
+
model = WhisperForConditionalGeneration.from_pretrained(checkpoint)
|
12 |
+
forced_decoder_ids = tokenizer.get_decoder_prompt_ids(language="georgian", task="transcribe")
|
13 |
+
|
14 |
+
asr_pipe = pipeline(
|
15 |
+
"automatic-speech-recognition",
|
16 |
+
model=model,
|
17 |
+
feature_extractor=feature_extractor,
|
18 |
+
tokenizer=tokenizer,
|
19 |
+
chunk_length_s=30,
|
20 |
+
stride_length_s=(4, 2)
|
21 |
+
)
|
22 |
+
|
23 |
+
def transcribe_ge(speech):
|
24 |
+
text = asr_pipe(
|
25 |
+
'../input/sounds/geo.wav',
|
26 |
+
generate_kwargs={"forced_decoder_ids": forced_decoder_ids}
|
27 |
+
)["text"]
|
28 |
+
return text
|
29 |
+
|
30 |
+
|
31 |
+
demo = gr.Blocks()
|
32 |
+
|
33 |
+
with demo:
|
34 |
+
audio_file = gr.Audio(type="filepath")
|
35 |
+
text = gr.Textbox()
|
36 |
+
|
37 |
+
b1 = gr.Button("Recognize Georgian")
|
38 |
+
|
39 |
+
b1.click(transcribe_ge, inputs=audio_file, outputs=text)
|
40 |
|
41 |
demo.launch()
|