Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[azure-cognitiveservices-speech]: Speech Recognition with an audio file #17377

Closed
hamzahamidi opened this issue Mar 16, 2021 · 1 comment
Closed
Labels
customer-reported Issues that are reported by GitHub users external to the Azure organization. needs-triage Workflow: This is a new issue that needs to be triaged to the appropriate team. question The issue doesn't require a change to the product in order to be resolved. Most issues start as that

Comments

@hamzahamidi
Copy link

  • Package Name: azure-cognitiveservices-speech
  • Package Version: 1.15.0
  • Operating System: Ubuntu 20.04
  • Python Version: 3.8.5 64bits

Describe the bug
I'm getting the following error when trying to complete the 08 - Speech.ipynb notebook in the mslearn-ai900:

---------------------------------------------------------------------------
RuntimeError                              Traceback (most recent call last)
<ipython-input-10-884de35ac39c> in <module>
      8 
      9 # Configure speech recognizer
---> 10 speech_config = SpeechConfig(cog_key, cog_location)
     11 audio_config = AudioConfig(filename=audio_file) # Use file instead of default (microphone)
     12 speech_recognizer = SpeechRecognizer(speech_config, audio_config)

~/.local/lib/python3.8/site-packages/azure/cognitiveservices/speech/speech.py in __init__(self, subscription, region, endpoint, host, auth_token, speech_recognition_language)
     57             speech_recognition_language: OptionalStr = None):
     58 
---> 59         self._impl = self._get_impl(impl.SpeechConfig, subscription, region, endpoint, host, auth_token,
     60                 speech_recognition_language)
     61 

~/.local/lib/python3.8/site-packages/azure/cognitiveservices/speech/speech.py in _get_impl(config_type, subscription, region, endpoint, host, auth_token, speech_recognition_language)
    148             if endpoint is not None or host is not None or auth_token is not None:
    149                 raise ValueError(generic_error_message)
--> 150             _impl = config_type._from_subscription(subscription, region)
    151         elif region is not None and auth_token is not None:
    152             if endpoint is not None or host is not None or subscription is not None:

RuntimeError: Exception with an error code: 0x5 (SPXERR_INVALID_ARG)
[CALL STACK BEGIN]

/home/hamza/.local/lib/python3.8/site-packages/azure/cognitiveservices/speech/libMicrosoft.CognitiveServices.Speech.core.so(+0x211d2b) [0x7fd25cc49d2b]
/home/hamza/.local/lib/python3.8/site-packages/azure/cognitiveservices/speech/libMicrosoft.CognitiveServices.Speech.core.so(+0x1a29ae) [0x7fd25cbda9ae]
/home/hamza/.local/lib/python3.8/site-packages/azure/cognitiveservices/speech/libMicrosoft.CognitiveServices.Speech.core.so(speech_config_from_subscription_internal+0xd5) [0x7fd25cb780bd]
/home/hamza/.local/lib/python3.8/site-packages/azure/cognitiveservices/speech/_speech_py_impl.so(+0xd94fc) [0x7fd25d5294fc]
/usr/bin/python3(PyCFunction_Call+0xfa) [0x5f305a]
/usr/bin/python3(_PyObject_MakeTpCall+0x296) [0x5f3446]
/usr/bin/python3(_PyEval_EvalFrameDefault+0x5dc0) [0x56f600]
/usr/bin/python3(_PyFunction_Vectorcall+0x1b6) [0x5f5e56]
/usr/bin/python3(_PyEval_EvalFrameDefault+0x5757) [0x56ef97]
/usr/bin/python3(_PyEval_EvalCodeWithName+0x26a) [0x56822a]
/usr/bin/python3(_PyFunction_Vectorcall+0x393) [0x5f6033]
/usr/bin/python3() [0x59b764]
/usr/bin/python3(_PyObject_MakeTpCall+0x1ff) [0x5f33af]
/usr/bin/python3(_PyEval_EvalFrameDefault+0x598a) [0x56f1ca]
/usr/bin/python3(_PyEval_EvalCodeWithName+0x26a) [0x56822a]
/usr/bin/python3(PyEval_EvalCode+0x27) [0x68c1e7]
/usr/bin/python3() [0x5ff1f4]
[CALL STACK END]

To Reproduce
Here's the full code:

import os
from playsound import playsound
from azure.cognitiveservices.speech import SpeechConfig, SpeechRecognizer, AudioConfig

# Get spoken command from audio file
file_name = 'light-on.wav'
audio_file = os.path.join('data', 'speech', file_name)

# Configure speech recognizer
speech_config = SpeechConfig(cog_key, cog_location)
audio_config = AudioConfig(filename=audio_file) # Use file instead of default (microphone)
speech_recognizer = SpeechRecognizer(speech_config, audio_config)

# Use a one-time, synchronous call to transcribe the speech
speech = speech_recognizer.recognize_once()

# Play audio and show transcribed text
playsound(audio_file)
print(speech.text)
@ghost ghost added needs-triage Workflow: This is a new issue that needs to be triaged to the appropriate team. customer-reported Issues that are reported by GitHub users external to the Azure organization. question The issue doesn't require a change to the product in order to be resolved. Most issues start as that labels Mar 16, 2021
@hamzahamidi
Copy link
Author

Never mind. I confused cog_location with cog_endpoint.

openapi-sdkautomation bot pushed a commit to AzureSDKAutomation/azure-sdk-for-python that referenced this issue Jan 25, 2022
[Hub Generated] Review request for Microsoft.AzureStackHCI to add version stable/2022-01-01 (Azure#17377)

* Adds base for updating Microsoft.AzureStackHCI from version stable/2021-09-01 to version 2022-01-01

* Updates readme

* Updates API version in new specs and examples

* remove readonly attribute

* added example file

* Format the files
@github-actions github-actions bot locked and limited conversation to collaborators Apr 12, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
customer-reported Issues that are reported by GitHub users external to the Azure organization. needs-triage Workflow: This is a new issue that needs to be triaged to the appropriate team. question The issue doesn't require a change to the product in order to be resolved. Most issues start as that
Projects
None yet
Development

No branches or pull requests

1 participant