【发布时间】:2019-07-07 19:42:30
【问题描述】:
我正在尝试研究如何在 python 中将 Azure 语音设置为文本 SDK API,以在 15 秒内识别文件。
我从这里的 python quickstart 尝试了这段代码:
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),可以转录更长的话语。
我的问题是:
- 如何设置参数以接受较长的话语
- 在哪里可以找到有关输出类型的 python api 设置的详细信息。理想情况下,如果识别器返回具有识别可信度且不带标点符号的 JSON。
任何想法将不胜感激
【问题讨论】:
-
您好,您的问题有什么进展吗?我的回答对您有帮助吗?
标签: python-3.x azure api speech-to-text