Google 语音 API 空答案

Google Speech API Empty Answer

为了测试,我使用了 Google 演讲示例 api (https://cloud.google.com/speech-to-text/docs/reference/rest/v1/speech/recognize) 我在那里尝试了一个 .ogg 文件 这个 (https://www.dropbox.com/s/lw66x3g143mtnsl/SpeechToText.ogg?dl=0) 我将音频文件转换为 16000Hz 这是完整的请求

{
  "audio": {
  "content": " content "
  },
  "config": {
  "encoding": "OGG_OPUS",
  "languageCode": "de-DE",
  "sampleRateHertz": 16000
  }
}

然后我用Base64编码器(https://www.giftofspeed.com/base64-encoder/)转换了aduio文件,所以这里的内容太长了。 现在我的问题只是一个空洞的答案。我得到了代码 200,但没有别的

谢谢大家的回答!

您引用的 .ogg 文件 URL 是使用编解码器 Vorbis 而非 Opus 编码的。在将音频文件提供给 Google 的服务

之前,您可以使用 opus-tools 将其编码为 Opus 文件

这是我用来将您的文件识别为 Vorbis 的调试:

opusinfo

$ opusinfo SpeechToText.ogg 
Processing file "SpeechToText.ogg"...

Use ogginfo for more information on this file.
New logical stream (#1, serial: ffe6c0ca): type Vorbis
Logical stream 1 ended

ffmpeg

$ ffmpeg -i SpeechToText.ogg 
ffmpeg version 3.4.2 Copyright (c) 2000-2018 the FFmpeg developers
Input #0, ogg, from 'SpeechToText.ogg':
  Duration: 00:00:03.41, start: 0.000000, bitrate: 116 kb/s
    Stream #0:0: Audio: vorbis, 16000 Hz, stereo, fltp, 160 kb/s
    Metadata:
      ENCODER         : Lavc58.18.100 libvorbis