【问题标题】:azure speech to text api utterance over 15 secondsazure 语音到文本 api 话语超过 15 秒
【发布时间】:2019-07-07 19:42:30
【问题描述】:

我正在尝试研究如何在 python 中将 Azure 语音设置为文本 SDK API,以在 15 秒内识别文件。

我从这里的 python quickstart 尝试了这段代码:

https://github.com/Azure-Samples/cognitive-services-speech-sdk/blob/master/quickstart/python/quickstart.py

        speech_config = speechsdk.SpeechConfig(subscription=cls.speech_key, region=cls.service_region )
        audio_config = speechsdk.audio.AudioConfig(filename=file_name)
        speech_recognizer = speechsdk.SpeechRecognizer(speech_config=speech_config, audio_config=audio_config)
        result = speech_recognizer.recognize_once()

        if result.reason == speechsdk.ResultReason.RecognizedSpeech:
            response_str = result.text
            # print("Recognized: {}".format(result.text))
        elif result.reason == speechsdk.ResultReason.NoMatch:
            response_str = result.no_match_details
            print("No speech could be recognized: {}".format(result.no_match_details))
        elif result.reason == speechsdk.ResultReason.Canceled:
            cancellation_details = result.cancellation_details
            response_str = cancellation_details.reason
            print("Speech Recognition canceled: {}".format(cancellation_details.reason))
            if cancellation_details.reason == speechsdk.CancellationReason.Error:
                response_str = cancellation_details.error_details
                print("Error details: {}".format(cancellation_details.error_details))

一切正常,除了仅识别前 15 秒这一事实。然而,这个页面:https://docs.microsoft.com/en-us/azure/cognitive-services/speech-service/speech-to-text 说如果我使用 SDK api(而不是 REST),可以转录更长的话语。

我的问题是:

  1. 如何设置参数以接受较长的话语
  2. 在哪里可以找到有关输出类型的 python api 设置的详细信息。理想情况下,如果识别器返回具有识别可信度且不带标点符号的 JSON。

任何想法将不胜感激

【问题讨论】:

  • 您好,您的问题有什么进展吗?我的回答对您有帮助吗?

标签: python-3.x azure api speech-to-text


【解决方案1】:

1.如何设置参数以接受较长的话语

事实上,你已经在你的问题中找到了证据。这个doc已经表明你需要使用连续转录。

所以,官方python示例使用recognize_once(),你需要使用start_continuous_recognition()方法来替换它。请看这个link:

2.在哪里可以找到关于输出类型的python api 设置的详细信息。理想情况下,如果识别器返回 JSON 识别信心,没有标点符号。

您可以使用代码查看json结构:speech_recognizer.recognize_once().json()

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2023-03-03
    • 2017-10-29
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-06-20
    • 1970-01-01
    相关资源
    最近更新 更多