tsobolev commited on
Commit
54c7319
1 Parent(s): f7d5ff0

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +36 -7
app.py CHANGED
@@ -1,12 +1,41 @@
1
  import gradio as gr
 
 
 
 
2
 
3
- def greet(name):
4
- return "Hello " + name + "!"
5
 
6
- with gr.Blocks() as demo:
7
- name = gr.Textbox(label="Name")
8
- output = gr.Textbox(label="Output Box")
9
- greet_btn = gr.Button("Greet")
10
- greet_btn.click(fn=greet, inputs=name, outputs=output, api_name="greet")
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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()