Oysiyl commited on
Commit
7568d0b
1 Parent(s): 262b445

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +25 -0
app.py ADDED
@@ -0,0 +1,25 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ from transformers import pipeline
3
+ import numpy as np
4
+
5
+ transcriber = pipeline("automatic-speech-recognition", model="Oysiyl/w2v-bert-2.0-ukrainian-colab-CV16.0")
6
+
7
+ def transcribe(audio):
8
+ sr, y = audio
9
+ y = y.astype(np.float32)
10
+ y /= np.max(np.abs(y))
11
+
12
+ return transcriber({"sampling_rate": sr, "raw": y})["text"]
13
+
14
+
15
+ demo = gr.Interface(
16
+ transcribe,
17
+ gr.Audio(sources=["microphone", "upload"]),
18
+ outputs="text",
19
+ title="Automatic Speech Recognition for Ukrainian language demo",
20
+ description="Say something or upload audiofile!",
21
+ examples=[["asr_example.wav"]],
22
+ cache_examples=True
23
+ )
24
+
25
+ demo.launch()