Commit
·
078404b
1
Parent(s):
33dd3df
Update app.py
Browse files
app.py
CHANGED
@@ -9,11 +9,12 @@ transcriber_bengali = pipeline("automatic-speech-recognition", model="ai4bharat/
|
|
9 |
transcriber_odia = pipeline("automatic-speech-recognition", model="ai4bharat/indicwav2vec-odia")
|
10 |
transcriber_gujarati = pipeline("automatic-speech-recognition", model="ai4bharat/indicwav2vec_v1_gujarati")
|
11 |
# transcriber_telugu = pipeline("automatic-speech-recognition", model="ai4bharat/indicwav2vec_v1_telugu")
|
12 |
-
transcriber_sinhala = pipeline("automatic-speech-recognition", model="ai4bharat/indicwav2vec_v1_sinhala")
|
13 |
-
transcriber_tamil = pipeline("automatic-speech-recognition", model="ai4bharat/indicwav2vec_v1_tamil")
|
14 |
-
transcriber_nepali = pipeline("automatic-speech-recognition", model="ai4bharat/indicwav2vec_v1_nepali")
|
15 |
-
transcriber_marathi = pipeline("automatic-speech-recognition", model="ai4bharat/indicwav2vec_v1_marathi")
|
16 |
|
|
|
17 |
|
18 |
def resample_to_16k(audio, orig_sr):
|
19 |
y_resampled = librosa.resample(y=audio, orig_sr=orig_sr, target_sr=16000)
|
@@ -24,8 +25,8 @@ def transcribe(audio,lang="hindi"):
|
|
24 |
y = y.astype(np.float32)
|
25 |
y/= np.max(np.abs(y))
|
26 |
y_resampled = resample_to_16k(y,sr)
|
27 |
-
if lang
|
28 |
-
return "No Model","So
|
29 |
pipe= eval(f'transcriber_{lang}')
|
30 |
start_time = time.time()
|
31 |
trans = pipe(y_resampled)
|
@@ -35,7 +36,9 @@ def transcribe(audio,lang="hindi"):
|
|
35 |
|
36 |
demo = gr.Interface(
|
37 |
transcribe,
|
38 |
-
inputs=["microphone",gr.Radio(["hindi","bangali","odia","gujarati"
|
|
|
39 |
outputs=["text","text"],
|
40 |
-
examples=[["./Samples/Hindi_1.mp3","hindi"],["./Samples/Hindi_2.mp3","hindi"],["./Samples/
|
|
|
41 |
demo.launch()
|
|
|
9 |
transcriber_odia = pipeline("automatic-speech-recognition", model="ai4bharat/indicwav2vec-odia")
|
10 |
transcriber_gujarati = pipeline("automatic-speech-recognition", model="ai4bharat/indicwav2vec_v1_gujarati")
|
11 |
# transcriber_telugu = pipeline("automatic-speech-recognition", model="ai4bharat/indicwav2vec_v1_telugu")
|
12 |
+
# transcriber_sinhala = pipeline("automatic-speech-recognition", model="ai4bharat/indicwav2vec_v1_sinhala")
|
13 |
+
# transcriber_tamil = pipeline("automatic-speech-recognition", model="ai4bharat/indicwav2vec_v1_tamil")
|
14 |
+
# transcriber_nepali = pipeline("automatic-speech-recognition", model="ai4bharat/indicwav2vec_v1_nepali")
|
15 |
+
# transcriber_marathi = pipeline("automatic-speech-recognition", model="ai4bharat/indicwav2vec_v1_marathi")
|
16 |
|
17 |
+
languages = ["hindi","bangali","odia","gujarati"]
|
18 |
|
19 |
def resample_to_16k(audio, orig_sr):
|
20 |
y_resampled = librosa.resample(y=audio, orig_sr=orig_sr, target_sr=16000)
|
|
|
25 |
y = y.astype(np.float32)
|
26 |
y/= np.max(np.abs(y))
|
27 |
y_resampled = resample_to_16k(y,sr)
|
28 |
+
if lang not in languages:
|
29 |
+
return "No Model","So Stay tuned!"
|
30 |
pipe= eval(f'transcriber_{lang}')
|
31 |
start_time = time.time()
|
32 |
trans = pipe(y_resampled)
|
|
|
36 |
|
37 |
demo = gr.Interface(
|
38 |
transcribe,
|
39 |
+
inputs=["microphone",gr.Radio(["hindi","bangali","odia","gujarati"],value="hindi")],
|
40 |
+
# inputs=["microphone",gr.Radio(["hindi","bangali","odia","gujarati","telugu","sinhala","tamil","nepali","marathi"],value="hindi")],
|
41 |
outputs=["text","text"],
|
42 |
+
examples=[["./Samples/Hindi_1.mp3","hindi"],["./Samples/Hindi_2.mp3","hindi"],["./Samples/Tamil_2.mp3","hindi"],["./Samples/climate ex short.wav","hindi"]])
|
43 |
+
# examples=[["./Samples/Hindi_1.mp3","hindi"],["./Samples/Hindi_2.mp3","hindi"],["./Samples/Tamil_1.mp3","tamil"],["./Samples/Tamil_2.mp3","hindi"],["./Samples/Nepal_1.mp3","nepali"],["./Samples/Nepal_2.mp3","nepali"],["./Samples/Marathi_1.mp3","marathi"],["./Samples/Marathi_2.mp3","marathi"],["./Samples/climate ex short.wav","hindi"]])
|
44 |
demo.launch()
|