Update app.py
Browse files
app.py
CHANGED
@@ -2,19 +2,28 @@ import gradio as gr
|
|
2 |
from transformers import pipeline
|
3 |
import numpy as np
|
4 |
|
5 |
-
|
|
|
|
|
6 |
|
7 |
-
|
|
|
|
|
|
|
8 |
sr, y = audio
|
9 |
y = y.astype(np.float32)
|
10 |
y /= np.max(np.abs(y))
|
11 |
-
|
12 |
-
|
|
|
|
|
|
|
|
|
13 |
|
14 |
|
15 |
demo = gr.Interface(
|
16 |
transcribe,
|
17 |
-
gr.Audio(source="microphone"),
|
18 |
"text",
|
19 |
)
|
20 |
|
|
|
2 |
from transformers import pipeline
|
3 |
import numpy as np
|
4 |
|
5 |
+
transcriber_hindi = pipeline("automatic-speech-recognition", model="ai4bharat/indicwav2vec-hindi")
|
6 |
+
transcriber_bang = pipeline("automatic-speech-recognition", model="ai4bharat/indicwav2vec_v1_bengali")
|
7 |
+
transcriber_odia = pipeline("automatic-speech-recognition", model="ai4bharat/indicwav2vec-odia")
|
8 |
|
9 |
+
|
10 |
+
def transcribe(audio,lang = "hindi"):
|
11 |
+
|
12 |
+
|
13 |
sr, y = audio
|
14 |
y = y.astype(np.float32)
|
15 |
y /= np.max(np.abs(y))
|
16 |
+
if lang == "hindi":
|
17 |
+
return transcriber_hindi({"sampling_rate": sr, "raw": y})["text"]
|
18 |
+
if lang == "bangali":
|
19 |
+
return transcriber_bang({"sampling_rate": sr, "raw": y})["text"]
|
20 |
+
if lang == "odia":
|
21 |
+
return transcriber_odia({"sampling_rate": sr, "raw": y})["text"]
|
22 |
|
23 |
|
24 |
demo = gr.Interface(
|
25 |
transcribe,
|
26 |
+
[gr.Audio(source="microphone"),gr.radio(["hindi","bangali","odia"])
|
27 |
"text",
|
28 |
)
|
29 |
|