Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -47,14 +47,14 @@ processor.feature_extractor._processor_class = "Wav2Vec2ProcessorWithLM"
|
|
47 |
# transcriber_hindi_lm = pipeline("automatic-speech-recognition", model="cdactvm/w2v-bert-tamil_new", tokenizer=processor_with_lm, feature_extractor=processor_with_lm.feature_extractor, decoder=processor_with_lm.decoder)
|
48 |
|
49 |
|
50 |
-
def transcribe_tamil_new(audio):
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
|
59 |
|
60 |
###############################################
|
@@ -93,6 +93,27 @@ def Noise_cancellation_function(audio_file):
|
|
93 |
|
94 |
#################################################
|
95 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
96 |
def sel_lng(lng, mic=None, file=None):
|
97 |
if mic is not None:
|
98 |
audio = mic
|
@@ -102,7 +123,7 @@ def sel_lng(lng, mic=None, file=None):
|
|
102 |
return "You must either provide a mic recording or a file"
|
103 |
|
104 |
if lng == "model_1":
|
105 |
-
return
|
106 |
# elif lng == "model_2":
|
107 |
# return transcribe_hindi_new(audio)
|
108 |
# elif lng== "model_3":
|
|
|
47 |
# transcriber_hindi_lm = pipeline("automatic-speech-recognition", model="cdactvm/w2v-bert-tamil_new", tokenizer=processor_with_lm, feature_extractor=processor_with_lm.feature_extractor, decoder=processor_with_lm.decoder)
|
48 |
|
49 |
|
50 |
+
# def transcribe_tamil_new(audio):
|
51 |
+
# # # Process the audio file
|
52 |
+
# transcript = transcriber_taml_new(audio)
|
53 |
+
# text_value = transcript['text']
|
54 |
+
# processd_doubles=process_doubles(text_value)
|
55 |
+
# replaced_words = replace_words(processd_doubles)
|
56 |
+
# converted_text=text_to_int(replaced_words)
|
57 |
+
# return converted_text
|
58 |
|
59 |
|
60 |
###############################################
|
|
|
93 |
|
94 |
#################################################
|
95 |
|
96 |
+
# Function to handle speech recognition
|
97 |
+
def recognize_speech(audio_file):
|
98 |
+
audio, sr = librosa.load(audio_file, sr=16000)
|
99 |
+
audio = high_pass_filter(audio, sr)
|
100 |
+
audio = apply_wiener_filter(audio)
|
101 |
+
denoised_audio = wavelet_denoise(audio)
|
102 |
+
result = asr_model(denoised_audio)
|
103 |
+
text_value = result['text']
|
104 |
+
cleaned_text = text_value.replace("<s>", "")
|
105 |
+
print(cleaned_text)
|
106 |
+
converted_to_list = convert_to_list(cleaned_text, text_to_list())
|
107 |
+
print(converted_to_list)
|
108 |
+
processed_doubles = process_doubles(converted_to_list)
|
109 |
+
print(processed_doubles)
|
110 |
+
replaced_words = replace_words(processed_doubles)
|
111 |
+
print(replaced_words)
|
112 |
+
converted_text = text_to_int(replaced_words)
|
113 |
+
print(converted_text)
|
114 |
+
return converted_text
|
115 |
+
|
116 |
+
|
117 |
def sel_lng(lng, mic=None, file=None):
|
118 |
if mic is not None:
|
119 |
audio = mic
|
|
|
123 |
return "You must either provide a mic recording or a file"
|
124 |
|
125 |
if lng == "model_1":
|
126 |
+
return recognize_speech(audio)
|
127 |
# elif lng == "model_2":
|
128 |
# return transcribe_hindi_new(audio)
|
129 |
# elif lng== "model_3":
|