hello
deployed an Flask app in Azure Webb App,
the app uses azure.cognitiveservices.speech library in a function to open mic and recognize audio:
def record_audio():
language = None
auto_detect_source_language_config = speechsdk.languageconfig.AutoDetectSourceLanguageConfig(
languages=["it-IT", "en-US", "en-GB"])
speech_recognizer = speechsdk.SpeechRecognizer(speech_config=speech_config,
auto_detect_source_language_config=auto_detect_source_language_config)
result = speech_recognizer.recognize_once()
if result.reason == speechsdk.ResultReason.RecognizedSpeech:
language = result.properties[speechsdk.PropertyId.SpeechServiceConnection_AutoDetectSourceLanguageResult].split("-")[0]
question_text = result.text #grabbing the text of the audio given by user
answer = search_azure_api_speak_version(question_text, API_URL) #calling the api to get the text version of the answer
if answer.strip():
translated = translate_text(answer_cleaned, language)#translating..
audio_data = text_to_speech(translated, language)#converting in audio
return question_text, audio_data #returning the audio and the question pair
return "", text_to_speech("No answer found for the question.",language)
elif result.reason == speechsdk.ResultReason.NoMatch:
return "No speech could be recognized", ""
elif not speechsdk.audio.AudioConfig().is_microphone_available():
return "Microphone not available. Please ensure that a microphone is connected.", ""
elif result.reason == speechsdk.ResultReason.Canceled:
cancellation_details = result.cancellation_details
print(f"Speech Recognition canceled: {cancellation_details.reason}")
if cancellation_details.reason == speechsdk.CancellationReason.Error:
return f"Error details: {cancellation_details.error_details}", "", ""
return "", "", ""
else:
return "Speech recognition failed", ""
Locally everything is ok, it can open the mic, but in cloud i get the error(full error):
{"error":"An unexpected error occurred while processing the audio: Exception with error code: \n
[CALL STACK BEGIN]\n\n/tmp/8dbe12210ad515c/antenv/lib/python3.11/site-packages/azure/cognitiveservices/speech/libMicrosoft.CognitiveServices.Speech.core.so
(+0x193021) [0x798a3b7b7021]\n/tmp/8dbe12210ad515c/antenv/lib/python3.11/site-packages/azure/cognitiveservices/speech/libMicrosoft.CognitiveServices.Speech.
core.so(+0xe9b41)
Speech.core.so(+0x1d9678) [0x798a3b7fd678]\n/tmp/8dbe12210ad515c/antenv/lib/python3.11/site-packages/azure/cognitiveservices/speech/lib
Microsoft.CognitiveServices.Speech.core.so(+0xf61e8) [0x798a3b71a1e8]\n/tmp/8dbe12210ad515c/antenv/lib/python3.11/site-packages/azure/cognitiveservices/speech/libMicrosoft.CognitiveServices.Speech.core.so(+0x18f338) [0x798a3b7b3338]\n/tmp/8dbe12210ad515c/antenv/lib/python3.11/site-packages/azure/cognitiveservices/speech/libMicrosoft.CognitiveServices.Speech.core.so(+0x192cc5) [0x798a3b7b6cc5]\n/tmp/8dbe12210ad515c/antenv/lib/python3.11/site-packages/azure/cognitiveservices/speech/lib
just wondering if is possible to do the same in Web App service as in locally.
thanks!