moeru-ai/airi · warning
Web Speech API recognition did not start immediately. This m
Error message
Web Speech API recognition did not start immediately. This might be due to:
What it means
This is a diagnostic `console.warn` (not an exception) emitted by `streamWebSpeechAPITranscription` when `startRecognition()` returned false, meaning the Web Speech API `recognition.start()` did not succeed immediately. It lists the three likely causes: missing microphone permission, an already-running recognition instance, or the browser requiring a user gesture. The stream is not rejected here; the code deliberately waits for permission or user action instead of retrying.
Source
Thrown at packages/provider-inference/src/providers/local/browser-web-speech-api/provider.ts:457
}
recognition.onsoundend = () => {
console.info('Web Speech API sound ended')
}
recognition.onaudioend = () => {
console.info('Web Speech API audio capture ended')
}
recognition.onnomatch = () => {
console.info('Web Speech API: No speech match')
}
const started = startRecognition()
if (!started) {
// If immediate start failed, it might be a permission issue
// Web Speech API will prompt for permission automatically, so we just log
console.warn('Web Speech API recognition did not start immediately. This might be due to:')
console.warn('1. Microphone permission not granted - browser should prompt automatically')
console.warn('2. Recognition already running - this is normal if called multiple times')
console.warn('3. Browser requires user gesture - ensure microphone was enabled by user action')
// Don't retry immediately - wait for permission or user action
// The recognition instance is already created, so it can be started later if needed
}
return {
fullStream,
text: deferredText.promise,
textStream,
recognition: recognitionInstance,
}
}
View on GitHub (pinned to f679616c34)
Solutions
- Trigger the transcription call from an explicit user gesture (button click) so the mic permission prompt can be shown and granted.
- Check mic permission state with `navigator.permissions.query({ name: 'microphone' })` and guide the user to grant access in site settings.
- Ensure only one recognition instance runs at a time; call `stop()` before starting a new session.
- Check the DevTools console for the preceding 'recognition start failed' warning, which names the concrete cause.
Example fix
// before
const result = await streamWebSpeechAPITranscription(...)
// after
const perm = await navigator.permissions.query({ name: 'microphone' })
if (perm.state !== 'granted') {
await requestMicPermissionViaUserGesture() // must run inside a click handler
}
const result = await streamWebSpeechAPITranscription(...) Defensive patterns
Strategy: retry
Validate before calling
const canUseSpeech = typeof window !== 'undefined' && ('SpeechRecognition' in window || 'webkitSpeechRecognition' in window)
const perm = await navigator.permissions.query({ name: 'microphone' })
if (perm.state === 'denied') throw new Error('Microphone permission denied') Type guard
function isSpeechApiSupported(): boolean { return typeof window !== 'undefined' && ('SpeechRecognition' in window || 'webkitSpeechRecognition' in window) } Try / catch
try {
const session = await streamWebSpeechAPITranscription(...)
} catch (error) {
if (error instanceof Error && error.message.includes('permission')) {
showMicPermissionHelp(); return
}
// non-fatal: start may simply be deferred — await session.text with timeout
throw error
} Prevention
- Always start transcription from a user gesture so the mic prompt can appear.
- Pre-check microphone permission with the Permissions API and surface a settings hint when denied.
- Verify Web Speech API support in the target browser/WebView before offering voice input.
- Watch the session streams for error events rather than relying on immediate start success.
When it happens
Trigger: Calling `streamWebSpeechAPITranscription` (via `result`) in a browser where `recognition.start()` fails synchronously or asynchronously and the error is not classified as 'already started' or 'permission denied' by the handler, so `startRecognition` returns false.
Common situations: Calling transcription before any user interaction on a page that requires a gesture; the browser's mic permission prompt is pending or was dismissed; the recognizer was started twice without stopping the first instance; running in a browser/WebView without full Web Speech API support.
Related errors
- 2. Recognition already running - this is normal if called mu
- 1. Microphone permission not granted - browser should prompt
- Web Speech API error:
- Web Speech API: Microphone access issue. Please check microp
- 1. Microphone permission not granted - browser should prompt
AI-assisted analysis of moeru-ai/airi@f679616c34 (2026-09-08).
Data as JSON: /api/errors/b3c772e2642f936b.
Report an issue: GitHub.