Enable Speech Recognition on IPhone

This commit is contained in:
Enrico Ros
2023-11-02 16:22:31 -07:00
parent 16be43edcc
commit b7e40cfb6b
3 changed files with 6 additions and 3 deletions
+3 -2
View File
@@ -152,9 +152,10 @@ export function CallWizard(props: { strict?: boolean, conversationId: string, ch
<StatusCard
icon={<MicIcon />}
text={
(overriddenRecognition ? 'Speech recognition should be good to go.' : 'There might be a speech recognition issue.')
((overriddenRecognition && !recognition.warnings.length) ? 'Speech recognition should be good to go.' : 'There might be a speech recognition issue.')
+ (recognition.isApiAvailable ? '' : ' Your browser does not support the speech recognition API.')
+ (recognition.isDeviceNotSupported ? ' Your device does not provide this feature (IPhone?).' : '')
+ (recognition.isDeviceNotSupported ? ' Your device does not provide this feature.' : '')
+ (recognition.warnings.length ? ' ⚠️ ' + recognition.warnings.join(' · ') : '')
}
button={overriddenRecognition ? undefined : (
<Button variant='outlined' onClick={handleOverrideRecognition} sx={{ mx: 1 }}>
+1
View File
@@ -16,6 +16,7 @@ export interface CapabilityBrowserSpeechRecognition {
mayWork: boolean; // Is the SpeechRecognition API available in the user's browser and device
isApiAvailable: boolean; // Is the SpeechRecognition API available in the user's browser
isDeviceNotSupported: boolean; // Is the user's device not supported (e.g., iPhone)
warnings: string[];
}
export { browserSpeechRecognitionCapability as useCapabilityBrowserSpeechRecognition } from './useSpeechRecognition';
@@ -17,11 +17,12 @@ let cachedCapability: CapabilityBrowserSpeechRecognition | null = null;
export const browserSpeechRecognitionCapability = (): CapabilityBrowserSpeechRecognition => {
if (!cachedCapability) {
const isApiAvailable = !!getSpeechRecognition();
const isDeviceNotSupported = isIPhone();
const isDeviceNotSupported = false;
cachedCapability = {
mayWork: isApiAvailable && !isDeviceNotSupported,
isApiAvailable,
isDeviceNotSupported,
warnings: isIPhone() ? ['Not tested on this browser/device.'] : [],
};
}
return cachedCapability;