首页 文章

google-cloud-speech speech.types.RecognitionConfig

提问于
浏览
0

我目前正在运行Debian 8 Jessie,使用Python 2.7和当前的google-cloud-speech和存储(今天升级) . 当我尝试配置它失败时:

ValueError:协议消息RecognitionConfig没有“enable_automatic_punctuation”字段 .

来自这个电话:

config = speech.types.RecognitionConfig(
    encoding=speech.enums.RecognitionConfig.AudioEncoding.LINEAR16,
    sample_rate_hertz=8000,
    language_code='en-US',
    # Enable automatic punctuation
    enable_automatic_punctuation=True)

该呼叫直接从“https://cloud.google.com/speech-to-text/docs/automatic-punctuation#speech-enhanced-model-python”复制/粘贴 .

咦?

1 回答

  • 0

    enable_automatic_punctuation 仅在导入 speech_v1p1beta1 而不是 speech_v1 时可用 . 比较betanon betaRecognitionConfig 文档 .

    此外,在您链接的相同示例中,如果单击View on Github,则可以看到以下导入:

    from google.cloud import speech_v1p1beta1 as speech

    另外,related to this topic .

    EDIT

    此外,该代码在Python 3上,并且您使用的是Python 2.7,请注意这一点 .

相关问题