{"record":{"id":"8a09dcf03a6a2ed7","repo":"vercel/ai","slug":"the-gemini-live-translation-api-only-supports-16kh","errorCode":null,"errorMessage":"The Gemini Live translation API only supports 16kHz 16-bit PCM input audio.","messagePattern":"The Gemini Live translation API only supports 16kHz 16-bit PCM input audio\\.","errorType":"validation","errorClass":"InvalidArgumentError","httpStatus":null,"severity":"error","filePath":"packages/google/src/speech-translation/google-speech-translation-model.ts","lineNumber":606,"sourceCode":"        targetLanguageCode: targetLanguage,\n        ...(providerOptions?.echoTargetLanguage != null\n          ? { echoTargetLanguage: providerOptions.echoTargetLanguage }\n          : {}),\n      },\n    },\n    inputAudioTranscription: {},\n    outputAudioTranscription: {},\n  };\n}\n\nfunction validateGoogleSpeechTranslationInputAudioFormat(\n  inputAudioFormat: SpeechTranslationModelV4StreamOptions['inputAudioFormat'],\n) {\n  if (\n    inputAudioFormat.type !== 'audio/pcm' ||\n    (inputAudioFormat.rate != null && inputAudioFormat.rate !== 16000)\n  ) {\n    throw new InvalidArgumentError({\n      argument: 'inputAudioFormat',\n      message:\n        'The Gemini Live translation API only supports 16kHz 16-bit PCM input audio.',\n    });\n  }\n}\n","sourceCodeStart":588,"sourceCodeEnd":613,"githubUrl":"https://github.com/vercel/ai/blob/69428b1f8b037e4d118fb4853428d5c4e620493c/packages/google/src/speech-translation/google-speech-translation-model.ts#L588-L613","documentation":"validateGoogleSpeechTranslationInputAudioFormat enforces that audio fed to the Gemini Live translation API is 16-bit PCM at 16 kHz. Any other inputAudioFormat — a different container type, or a PCM sample rate other than 16000 — throws this InvalidArgumentError before the WebSocket session starts. The Live translation endpoint performs no resampling or transcoding on your behalf.","triggerScenarios":"Passing inputAudioFormat with type other than 'audio/pcm' (e.g. 'audio/wav', 'audio/mp3') or type 'audio/pcm' with rate set to anything other than 16000 (e.g. 44100, 48000, 8000).","commonSituations":"Streaming microphone audio captured at 44.1/48 kHz without resampling; feeding compressed files instead of raw PCM; copying inputAudioFormat options from a different transcription provider that accepts arbitrary rates.","solutions":["Resample the audio to 16 kHz mono 16-bit PCM before streaming (e.g. AudioContext at 16000 sampleRate, or sox/ffmpeg server-side).","Set inputAudioFormat: { type: 'audio/pcm', rate: 16000 } explicitly in the stream options.","If you need other formats, transcode first — the API will not accept them."],"exampleFix":"// before\nawait model.doStream({ inputAudioFormat: { type: 'audio/pcm', rate: 48000 }, ... });\n// after\nawait model.doStream({ inputAudioFormat: { type: 'audio/pcm', rate: 16000 }, ... });\n// and resample source audio to 16 kHz before streaming","handlingStrategy":"validation","validationCode":"const fmt = options.inputAudioFormat;\nif (fmt.type !== 'audio/pcm' || (fmt.rate != null && fmt.rate !== 16000)) {\n  throw new Error('Resample audio to 16 kHz 16-bit PCM before streaming translation');\n}","typeGuard":"function isPcm16k(\n  f: SpeechTranslationModelV4StreamOptions['inputAudioFormat'],\n): boolean {\n  return f.type === 'audio/pcm' && (f.rate == null || f.rate === 16000);\n}","tryCatchPattern":null,"preventionTips":["Capture microphone audio with an AudioContext at 16000 Hz sample rate.","Transcode compressed inputs (wav/mp3) to raw 16 kHz mono PCM server-side first.","Always set inputAudioFormat: { type: 'audio/pcm', rate: 16000 } explicitly.","Test the full audio pipeline end-to-end at the target sample rate."],"tags":["audio-format","google","speech-translation","validation"],"backgroundTag":"unsupported-audio-format","analyzedSha":"69428b1f8b037e4d118fb4853428d5c4e620493c","analyzedAt":"2026-08-30T12:32:21.016Z","schemaVersion":2},"datasetVersion":"2026-08-30T13:17:10.514Z"}