mirror of https://github.com/buster-so/buster.git
microphone permissions
This commit is contained in:
parent
aea638b04d
commit
8de707db38
|
@ -13,8 +13,8 @@ import { Popover } from '@/components/ui/popover';
|
|||
import { AppSegmented, type AppSegmentedProps } from '@/components/ui/segmented';
|
||||
import { AppTooltip } from '@/components/ui/tooltip';
|
||||
import { Text } from '@/components/ui/typography';
|
||||
import { cn } from '@/lib/utils';
|
||||
import { useSpeechRecognition } from '@/hooks/useSpeechRecognition';
|
||||
import { cn } from '@/lib/utils';
|
||||
|
||||
export type BusterChatInputMode = 'auto' | 'research' | 'deep-research';
|
||||
|
||||
|
@ -73,7 +73,11 @@ export const BusterChatInputButtons = React.memo(
|
|||
{browserSupportsSpeechRecognition && (
|
||||
<AppTooltip
|
||||
title={
|
||||
listening ? (!hasPermission ? 'Audio permissions not enabled' : 'Stop dictation...') : 'Press to dictate...'
|
||||
listening
|
||||
? !hasPermission
|
||||
? 'Audio permissions not enabled'
|
||||
: 'Stop dictation...'
|
||||
: 'Press to dictate...'
|
||||
}
|
||||
>
|
||||
<Button
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
import { useCallback, useEffect, useRef, useState } from 'react';
|
||||
import { openErrorNotification } from '@/context/BusterNotifications';
|
||||
|
||||
// Type definitions for Web Speech API
|
||||
interface SpeechRecognitionErrorEvent extends Event {
|
||||
|
@ -120,12 +121,16 @@ export function useSpeechRecognition(): UseSpeechRecognitionReturn {
|
|||
|
||||
recognition.onerror = (event: SpeechRecognitionErrorEvent) => {
|
||||
console.error('Speech recognition error:', event.error);
|
||||
let message = '';
|
||||
if (event.error.includes('language-not-supported')) {
|
||||
setError('Browser does not support dictation');
|
||||
message = 'Browser does not support dictation';
|
||||
} else {
|
||||
setError(event.error);
|
||||
message = event.error;
|
||||
}
|
||||
|
||||
openErrorNotification({ message });
|
||||
setError(message);
|
||||
|
||||
onStopListening();
|
||||
};
|
||||
|
||||
|
@ -150,7 +155,8 @@ export function useSpeechRecognition(): UseSpeechRecognitionReturn {
|
|||
setTranscript('');
|
||||
recognitionRef.current.start();
|
||||
} catch (error) {
|
||||
console.error('Microphone permission denied:', error);
|
||||
console.error('Microphone error:', error);
|
||||
openErrorNotification({ message: `Microphone permission denied: ${error}` });
|
||||
}
|
||||
}
|
||||
}, [listening]);
|
||||
|
|
Loading…
Reference in New Issue