通过 python 库调用函数 AudioConfig.FromWavFileInput 时出现问题
Having a problem calling the function AudioConfig.FromWavFileInput through python library
我正在尝试使用 Azure 认知语音服务处理 .wav 文件。我正在使用下面的脚本。当我尝试通过调用 AudioConfig.FromWavFileInput(). The documentation says the function exists, at least in the .net library. Does FromWaveFileInput exist for the cognitiveservices-speech python library 来设置 wav 文件时,出现异常 "type object 'AudioConfig' has no attribute 'FromWavFileInput'"?如何使用 python 处理音频文件?
import azure.cognitiveservices.speech as speechsdk
speechKey = 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx'
service_region = 'eastus2'
#### # Creates an instance of a speech config with specified subscription key and service region.
#### # Replace with your own subscription key and service region (e.g., "westus").
speech_config = speechsdk.SpeechConfig(subscription=speechKey, region=service_region)
audioInput = speechsdk.AudioConfig.FromWavFileInput('RainSpain.wav')
#### # Creates a recognizer with the given settings
speech_recognizer = speechsdk.SpeechRecognizer(speech_config=speech_config, audio_input=audioInput)
确实如你所说。我在 GitHub repo Azure-Samples/cognitive-services-speech-sdk
, there is not any Python codes about it except for Java, C#, and C++.
上搜索关键字 AudioConfig
& FromWavFileInput
所以根据我的经验,有两种解决方法。
- 将 C++ 代码包装为 Python extension module,或与 C++/Java 代码通信。
- 直接使用Speech service REST APIs with
requests
,Python和Azure Speech Service很简单。
这很有魅力
audio_filename = "something.wav"
audio_input =speechsdk.audio.AudioConfig(filename=audio_filename)
我正在尝试使用 Azure 认知语音服务处理 .wav 文件。我正在使用下面的脚本。当我尝试通过调用 AudioConfig.FromWavFileInput(). The documentation says the function exists, at least in the .net library. Does FromWaveFileInput exist for the cognitiveservices-speech python library 来设置 wav 文件时,出现异常 "type object 'AudioConfig' has no attribute 'FromWavFileInput'"?如何使用 python 处理音频文件?
import azure.cognitiveservices.speech as speechsdk
speechKey = 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx'
service_region = 'eastus2'
#### # Creates an instance of a speech config with specified subscription key and service region.
#### # Replace with your own subscription key and service region (e.g., "westus").
speech_config = speechsdk.SpeechConfig(subscription=speechKey, region=service_region)
audioInput = speechsdk.AudioConfig.FromWavFileInput('RainSpain.wav')
#### # Creates a recognizer with the given settings
speech_recognizer = speechsdk.SpeechRecognizer(speech_config=speech_config, audio_input=audioInput)
确实如你所说。我在 GitHub repo Azure-Samples/cognitive-services-speech-sdk
, there is not any Python codes about it except for Java, C#, and C++.
AudioConfig
& FromWavFileInput
所以根据我的经验,有两种解决方法。
- 将 C++ 代码包装为 Python extension module,或与 C++/Java 代码通信。
- 直接使用Speech service REST APIs with
requests
,Python和Azure Speech Service很简单。
这很有魅力
audio_filename = "something.wav"
audio_input =speechsdk.audio.AudioConfig(filename=audio_filename)