【发布时间】:2021-03-03 17:33:35
【问题描述】:
我正在使用 azure 语音到文本服务,使用 python 来处理一堆音频。为了处理音频,这些是执行的步骤-
- 将音频从 Web 服务器下载到本地“C:/audio”驱动器。
- 将下载的音频路径传递给 Speech SDK 的 - Audioconfig(filename ='C:/audio/my_audio.wav')
我想从服务器获取文件并将其直接传递给语音到文本服务,而不是下载到本地机器。为此,
-
我将音频以
bytes的形式存储在这样的音频缓冲区中-raw_audio = my_audio_in_bytes # class <'bytes'> -
然后,我将音频缓冲区传递给 AudioConfig(filename = raw_audio) - 它不起作用。因为它需要一个文件路径
有没有办法将音频缓冲区传递给该服务?
配置python代码:
speech_config = speechsdk.SpeechConfig(subscription=speech_key, region=service_region)
audio_config = speechsdk.audio.AudioConfig(filename='C:/audios/audio1.wav')
speech_recognizer = speechsdk.SpeechRecognizer(speech_config=speech_config, audio_config=audio_config)
【问题讨论】:
-
查看文档。 AudioConfig 函数接受
stream参数,虽然我不能告诉你它想要什么格式。 -
也用流测试过,推/拉流采用原始数据,但最终的成绩单很乱,有很多多余的词。因此,尝试了这种方法。
标签: python speech-to-text azure-speech