【问题标题】:using enhanced model in google cloud speech api在谷歌云语音 api 中使用增强模型
【发布时间】:2018-04-28 12:18:31
【问题描述】:

我正在尝试使用 Google Speech API 上的增强模型,例如:

gcs_uri="gs://mybucket/averylongaudiofile.ogg"

client = speech.SpeechClient()

audio = types.RecognitionAudio(uri=gcs_uri)
config = types.RecognitionConfig(
        encoding=enums.RecognitionConfig.AudioEncoding.OGG_OPUS,
        language_code='en-US',
        sample_rate_hertz=48000,
        use_enhanced=True,
        model='phone_call',
        enable_word_time_offsets=True,
        enable_automatic_punctuation=True)

operation = client.long_running_recognize(config, audio)

我已在我的项目的“云语音 API”设置中启用数据记录,以便能够使用增强模型

当我运行它时,它会抛出以下错误:

Traceback (most recent call last):   File "./transcribe.py", line 126, in <module>
    enable_automatic_punctuation=True) ValueError: Protocol message RecognitionConfig has no "use_enhanced" field.

有什么建议吗?

【问题讨论】:

    标签: python python-3.x google-cloud-speech


    【解决方案1】:

    您可以在v1p1beta1 package 的 RecognitionConfig 类型中使用“use_enhanced”。

    为了能够运行您的示例,您只需将您拥有的导入修改为如下所示:

    import google.cloud.speech_v1p1beta1 as speech
    gcs_uri="gs://mybucket/averylongaudiofile.ogg"
    
    client = speech.SpeechClient()
    audio = speech.types.RecognitionAudio(uri=gcs_uri)
    config = speech.types.RecognitionConfig(
            encoding=speech.enums.RecognitionConfig.AudioEncoding.OGG_OPUS,
            language_code='en-US',
            sample_rate_hertz=48000,
            use_enhanced=True,
            model='phone_call',
            enable_word_time_offsets=True,
            enable_automatic_punctuation=True)
    operation = client.long_running_recognize(config, audio)
    

    【讨论】:

      猜你喜欢
      • 2023-04-09
      • 2017-03-08
      • 2017-05-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-07-08
      • 1970-01-01
      相关资源
      最近更新 更多