【问题标题】:Having a problem calling the function AudioConfig.FromWavFileInput through python library通过 python 库调用函数 AudioConfig.FromWavFileInput 时出现问题
【发布时间】:2020-06-11 23:33:13
【问题描述】:

我正在尝试使用 Azure 认知语音服务处理 .wav 文件。我正在使用下面的脚本。当我尝试通过调用 AudioConfig.FromWavFileInput() 来设置 wav 文件时,我收到一个异常,提示“类型对象 'AudioConfig' 没有属性 'FromWavFileInput'”。文档说该函数存在,至少在 .net 库中。 cognitiveservices-speech python library 是否存在 FromWaveFileInput?如何使用 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)

【问题讨论】:

    标签: python azure speech-recognition azure-machine-learning-studio


    【解决方案1】:

    这就像一个魅力

    audio_filename = "something.wav"
    audio_input =speechsdk.audio.AudioConfig(filename=audio_filename)
    

    【讨论】:

      【解决方案2】:

      确实如你所说。我在 GitHub repo Azure-Samples/cognitive-services-speech-sdk 上搜索了关键字 AudioConfigFromWavFileInput,除了 Java、C# 和 C++ 之外,没有任何 Python 代码。

      所以根据我的经验,有两种解决方法。

      1. 将 C++ 代码包装为 Python extension module,或与 C++/Java 代码通信。
      2. 直接使用Speech service REST APIsrequests,对 Python 和 Azure 语音服务来说很简单。

      【讨论】:

        猜你喜欢
        • 2021-11-05
        • 1970-01-01
        • 2021-10-06
        • 1970-01-01
        • 2019-12-20
        • 1970-01-01
        • 1970-01-01
        • 2021-08-22
        • 1970-01-01
        相关资源
        最近更新 更多