File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -522,12 +522,20 @@ const VoiceInput = {
522522 if ( isProcessing . value ) return
523523 try {
524524 const stream = await navigator . mediaDevices . getUserMedia ( { audio : true } )
525+ recordingStartTime . value = Date . now ( )
525526 mediaRecorder = new MediaRecorder ( stream )
526527 audioChunks = [ ]
527528 mediaRecorder . ondataavailable = event => {
528529 audioChunks . push ( event . data )
529530 }
530531 mediaRecorder . onstop = async ( ) => {
532+ // Ignore recordings less than 1 second - likely unintentional
533+ const recordingDuration = Date . now ( ) - recordingStartTime . value
534+ if ( recordingDuration < 1000 ) {
535+ console . debug ( `Recording too short (${ recordingDuration } ms), ignoring` )
536+ isProcessing . value = false
537+ return
538+ }
531539 const audioBlob = new Blob ( audioChunks , { type : 'audio/webm' } )
532540 const fileName = `voice-${ Date . now ( ) } .webm`
533541
You can’t perform that action at this time.
0 commit comments