【问题标题】:google-cloud-speech speech.types.RecognitionConfiggoogle-cloud-speech speech.types.RecognitionConfig
【发布时间】:2018-06-13 18:28:33
【问题描述】:

我目前在 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”复制/粘贴的。

嗯?

【问题讨论】:

  • from google.cloud import speech_v1p1beta1 as speech 了吗

标签: config google-cloud-speech


【解决方案1】:

enable_automatic_punctuation 仅在您导入 speech_v1p1beta1 而不是 speech_v1 时可用。比较 RecognitionConfigbetanon beta 的文档。

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

from google.cloud import speech_v1p1beta1 as speech

另外,related to this topic

编辑

另外,该代码在 Python 3 上,而您使用的是 Python 2.7,请注意这一点。

【讨论】:

  • 啊唧!!!! Python3 使成功执行成为可能。非常感谢先生。
猜你喜欢
  • 2017-11-01
  • 1970-01-01
  • 2019-04-16
  • 1970-01-01
  • 1970-01-01
  • 2017-09-26
  • 2020-11-10
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多