【问题标题】:Problems with Google Cloud Speech-to-Text APIGoogle Cloud Speech-to-Text API 的问题
【发布时间】:2020-11-04 17:59:34
【问题描述】:

我正在尝试转录我的电脑和 Google 存储桶上都有的德语播客。我使用this tutorial 作为参考。

这是我的代码:

frame_rate, channels = frame_rate_channel('pod.wav')
gcs_uri = 'gs://callsaudiofiles21/pod.wav'

client = speech.SpeechClient()
audio = types.RecognitionAudio(uri=gcs_uri)

config = types.RecognitionConfig(
encoding=enums.RecognitionConfig.AudioEncoding.LINEAR16,
sample_rate_hertz=frame_rate,
language_code='de-DE')

transcript = ''

operation = client.long_running_recognize(config, audio)
response = operation.result(timeout=10000)

for result in response.results:
    transcript += result.alternatives[0].transcript

但它停在operation 行,输出TypeError: long_running_recognize() takes from 1 to 2 positional arguments but 3 were given。该教程是一年前的,所以从那以后 API 中肯定发生了一些变化。不过我不确定要修改什么。

【问题讨论】:

    标签: python api google-cloud-platform speech-recognition speech-to-text


    【解决方案1】:

    看起来您使用的是旧的库版本。

    来自Google async recognizion example,这两个选项似乎是等价的:

        operation = client.long_running_recognize(
            request={"config": config, "audio": audio}
        )
    
    

        operation = client.long_running_recognize(config=config, audio=audio)
    

    顺便说一句 - 也可以看看官方 Google Codelab for Speech to text - 他们总是有最新的例子。

    【讨论】:

      【解决方案2】:

      你试过了吗:

      operation = client.long_running_recognize(
              request={"config": config, "audio": audio}
          )
      

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2019-04-16
        • 2019-03-15
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多