【发布时间】:2020-09-14 14:50:05
【问题描述】:
我正在尝试使用 Azure 认知服务和 Python 创建自定义唤醒词。我正在关注快速入门教程 -
我已经使用语音工作室生成了关键字模型,现在我正在尝试在 Python 中实现它。快速入门有 C# 示例,其中使用 CognitiveServices.Speech、CognitiveServices.Speech.Audio。 .NET 有 KeywordRecognizer 类来实现关键字识别。
在 Python 中,没有 KeywordRecognizer 类,但是有一个 Recognizer,它有 start_keyword_recognition 方法。
最初我使用它如下 -
keywordModel = speechsdk.KeywordRecognitionModel("hello_raven.table")
#audioConfig = audiosdk.AudioConfig(use_default_microphone = True)
keywordRecognizer = speechsdk.Recognizer()
result = keywordRecognizer.start_keyword_recognition(keywordModel)
当我执行它时,我得到了以下错误 -
AttributeError: 'Recognizer' 对象没有属性 '_impl'
当我提到speech.py时,它有以下关键字识别的实现-
def start_keyword_recognition(self, model: KeywordRecognitionModel):
"""
Synchronously initiates keyword recognition operation.
:param model: the keyword recognition model that specifies the keyword to be recognized.
"""
return self._impl.start_keyword_recognition(model._impl)
识别器类具有返回 _impl 的静态方法,但它使用 _from_config 方法,我无法在 Speech.py 中找到该方法。
- 我们能否立即使用识别器类和 start_keyword_recognition 方法。
- 如果没有,请向我提供有关如何实现它的任何指示。
如果需要更多详细信息,请告诉我。
@staticmethod
def _get_impl(reco_type, speech_config, audio_config):
if audio_config is not None:
_impl = reco_type._from_config(speech_config._impl, audio_config._impl)
else:
_impl = reco_type._from_config(speech_config._impl, None)
return _impl
【问题讨论】:
标签: python speech-recognition azure-speech