gpt4 book ai didi

speech-recognition - 模块 'google.cloud.speech_v1p1beta1.types' 没有 'RecognitionAudio' 成员

转载 作者:行者123 更新时间:2023-12-03 17:30:41 28 4
gpt4 key购买 nike

尝试运行示例代码,但出现此错误”

Module 'google.cloud.speech_v1p1beta1.types' has no 'RecognitionAudio' member

环境:python3x,linux,安装和更新的 google-cloud lib
pip install --upgrade google-cloud-speech.

安装了以下
  • 谷歌云 (0.34.0)
  • 谷歌云语音 (0.36.3)


  • 不知道还有什么要检查的。如果您有任何建议会很棒
    import argparse
    import io

    def transcribe_file_with_enhanced_model():
    """Transcribe the given audio file using an enhanced model."""
    # [START speech_transcribe_enhanced_model_beta]
    from google.cloud import speech_v1p1beta1 as speech
    client = speech.SpeechClient()

    speech_file = 'resources/commercial_mono.wav'

    with io.open(speech_file, 'rb') as audio_file:
    content = audio_file.read()

    audio = speech.types.RecognitionAudio(content=content)

    config = speech.types.RecognitionConfig(
    encoding=speech.enums.RecognitionConfig.AudioEncoding.LINEAR16,
    sample_rate_hertz=8000,
    language_code='en-US',
    # Enhanced models are only available to projects that
    # opt in for audio data collection.
    use_enhanced=True,
    # A model must be specified to use enhanced model.
    model='phone_call')

    response = client.recognize(config, audio)

    for i, result in enumerate(response.results):
    alternative = result.alternatives[0]
    print('-' * 20)
    print('First alternative of result {}'.format(i))
    print('Transcript: {}'.format(alternative.transcript))
    # [END speech_transcribe_enhanced_model_beta]

    最佳答案

    我认为您的版本是 "google.cloud.speech_v1"。安装google-cloud-speech 2.0.0

    pip uninstall google-cloud-speech


    pip install google-cloud-speech

    关于speech-recognition - 模块 'google.cloud.speech_v1p1beta1.types' 没有 'RecognitionAudio' 成员,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54660907/

    28 4 0
    Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
    广告合作:1813099741@qq.com 6ren.com