Below is the code,
call_name1="test.wav"
blob_client1=blob_service_client.get_blob_client("bucket/audio",call_name1)
print(blob_client1)
streamdownloader=blob_client1.download_blob()
stream = BytesIO()
streamfinal=streamdownloader.download_to_stream(stream)
print(streamfinal)
speech_key, service_region = "12345", "eastus"
speech_config = speechsdk.SpeechConfig(subscription=speech_key, region=service_region)
audio_input = speechsdk.audio.AudioConfig(filename=streamfinal)
Error,
TypeError Traceback (most recent call last)
<ipython-input-6-a402ae91606a> in <module>
44 speech_config = speechsdk.SpeechConfig(subscription=speech_key, region=service_region)
45
---> 46 audio_input = speechsdk.audio.AudioConfig(filename=streamfinal)
C:\ProgramData\Anaconda3\lib\site-packages\azure\cognitiveservices\speech\audio.py in __init__(self, use_default_microphone, filename, stream, device_name)
213
214 if filename is not None:
--> 215 self._impl = impl.AudioConfig._from_wav_file_input(filename)
216 return
217 if stream is not None:
TypeError: in method 'AudioConfig__from_wav_file_input', argument 1 of type 'std::string const &'
Please help us in reading the audio files from storage container as input in Azure speech api. Thank you!!
As ewong said in the comment, You need to get the
streaminstead of String.download_to_streamis used to download the contents of this blob to a stream. But notazure.cognitiveservices.speech.audio.AudioInputStreamwhatAudioConfigneed.I cannot find the workaround about converting stream to AudioInputStream. So, It seems only the way that downloads the audio file to the local from Storage Blob and then uploads it by AudioConfig.