You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

请求协助解决Google Speech-to-Text采样率配置无效的400错误

Fixing "Invalid recognition 'config': bad sample rate hertz" Error in Google Speech-to-Text API

Looks like that error is pointing to a simple but critical missing piece in your request. Let's break down what's going wrong and fix it right away:

1. The Root Issue

Google's Speech-to-Text API requires you to explicitly define your audio's sample rate in the config object—even if you're using a standard rate like 16000 Hz. Your current request doesn't include the sampleRateHertz field, so the API can't properly parse your 16kHz WAV file.

Also, there's a tiny syntax issue with your enableAutomaticPunctuation value: you passed it as a string "true" instead of a JSON boolean true (no quotes). While this isn't causing your current error, it could lead to unexpected behavior later, so we'll fix that too.

2. Corrected Request JSON

Here's the revised version of your request with both fixes applied:

{
  "config": {
    "enableAutomaticPunctuation": true,
    "encoding": "LINEAR16",
    "languageCode": "en-US",
    "model": "default",
    "sampleRateHertz": 16000
  },
  "audio": {
    "content": "QzpcU3BlZWNoVG9UZXh0XGVuZ2xpc2hcUENNXEVORy1DUk0tRE9XTlRJTUUud2F2"
  }
}

3. Quick Reminders

  • Double-check that sampleRateHertz exactly matches your audio's actual sample rate (16000 Hz in your case). Mismatched values will trigger the same error.
  • JSON boolean values (true/false) should never be wrapped in quotes—use them as raw boolean types.
  • Your encoding: "LINEAR16" is perfect for your PCM 16-bit mono audio, so no changes needed there.

Give this updated request a shot, and it should resolve that 400 error you're hitting.

内容的提问来源于stack exchange,提问作者Tarun

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.07 16:22:54