Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Improve stt response time
  • Loading branch information
chriswritescode-dev committed Feb 1, 2026
commit d9d1869980320cce438b7494008aec68265c54f9
2 changes: 2 additions & 0 deletions frontend/src/hooks/useSTT.ts
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,8 @@ export function useSTT(userId = 'default') {
audioRecorder.current = new AudioRecorder()
}

audioRecorder.current.warmup()

setupAudioRecorder(audioRecorder.current)

return () => {
Expand Down
25 changes: 25 additions & 0 deletions frontend/src/lib/audioRecorder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,26 @@ export class AudioRecorder {
)
}

async warmup(): Promise<boolean> {
if (!AudioRecorder.isSupported()) {
return false
}

try {
const stream = await navigator.mediaDevices.getUserMedia({
audio: {
echoCancellation: true,
noiseSuppression: true,
autoGainControl: true,
},
})
stream.getTracks().forEach(track => track.stop())
return true
} catch {
return false
}
}

getState(): AudioRecorderState {
return this.state
}
Expand Down Expand Up @@ -186,3 +206,8 @@ export function getAudioRecorder(): AudioRecorder {
export function isAudioRecordingSupported(): boolean {
return AudioRecorder.isSupported()
}

export async function warmupAudioRecorder(): Promise<boolean> {
const recorder = getAudioRecorder()
return recorder.warmup()
}