Added try/except on recognize_google method for audio without any detected speech

This commit is contained in:
Mathieu 2021-08-28 16:11:36 +02:00
parent b0c515761c
commit 63e37858cf

View File

@ -30,11 +30,15 @@ def process_audio_request():
r = sr.Recognizer()
audio = sr.AudioData(frame_data, sample_rate, sample_width)
try:
result_stt = r.recognize_google(audio, language=languages_utils.get_language_only_country())
return jsonify(
intent_manager.recognise(result_stt, request.headers.get('Client-Ip'), request.headers.get('Client-Port')))
except sr.UnknownValueError:
print("[Error] No speech detected in the send audio!")
def get_data_in_request(flask_request):
data_str = str(flask_request.data.decode('utf8')).replace('"', '\"').replace("\'", "'")