Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -240,16 +240,16 @@ def recognize_speech_malayalam_model1(audio_file):
|
|
240 |
return text_value +" -----------------> " + converted_text
|
241 |
|
242 |
## Function to handle speech recognition
|
243 |
-
|
244 |
-
|
245 |
-
|
246 |
-
|
247 |
-
|
248 |
-
|
249 |
-
|
250 |
-
|
251 |
-
|
252 |
-
|
253 |
|
254 |
def sel_lng(lng, mic=None, file=None):
|
255 |
if mic is not None:
|
@@ -261,8 +261,8 @@ def sel_lng(lng, mic=None, file=None):
|
|
261 |
|
262 |
if lng == "malayalam_model1":
|
263 |
return recognize_speech_malayalam_model1(audio)
|
264 |
-
|
265 |
-
|
266 |
|
267 |
|
268 |
demo=gr.Interface(
|
@@ -270,7 +270,7 @@ demo=gr.Interface(
|
|
270 |
|
271 |
inputs=[
|
272 |
gr.Dropdown([
|
273 |
-
"malayalam_model1"],label="Select Model"),
|
274 |
gr.Audio(sources=["microphone","upload"], type="filepath"),
|
275 |
],
|
276 |
outputs=[
|
|
|
240 |
return text_value +" -----------------> " + converted_text
|
241 |
|
242 |
## Function to handle speech recognition
|
243 |
+
def recognize_speech_malayalam2(audio_file):
|
244 |
+
audio, sr = librosa.load(audio_file, sr=16000)
|
245 |
+
audio = high_pass_filter(audio, sr)
|
246 |
+
audio = apply_wiener_filter(audio)
|
247 |
+
denoised_audio = wavelet_denoise(audio)
|
248 |
+
result = asr_model_malayalam(denoised_audio)
|
249 |
+
text_value = result['text']
|
250 |
+
cleaned_text = text_value.replace("[UNK]", "")
|
251 |
+
converted_text=convert2numkn(cleaned_text,kanlex)
|
252 |
+
return cleaned_text +" -----------------> " + converted_text
|
253 |
|
254 |
def sel_lng(lng, mic=None, file=None):
|
255 |
if mic is not None:
|
|
|
261 |
|
262 |
if lng == "malayalam_model1":
|
263 |
return recognize_speech_malayalam_model1(audio)
|
264 |
+
elif lng == "malayalam_model2":
|
265 |
+
return recognize_speech_malayalam_model2(audio)
|
266 |
|
267 |
|
268 |
demo=gr.Interface(
|
|
|
270 |
|
271 |
inputs=[
|
272 |
gr.Dropdown([
|
273 |
+
"malayalam_model1",'malayalam_model2'],label="Select Model"),
|
274 |
gr.Audio(sources=["microphone","upload"], type="filepath"),
|
275 |
],
|
276 |
outputs=[
|