Skip to content

Commit

Permalink
Re-Enable Speech Recognition on Safari (still untested on iPhones)
Browse files Browse the repository at this point in the history
  • Loading branch information
enricoros committed Sep 19, 2023
1 parent 7f49ddb commit 34d5a32
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 7 deletions.
8 changes: 4 additions & 4 deletions src/common/components/useSpeechRecognition.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import * as React from 'react';

import { isChromeOnDesktopWindows, isSafariOriPhone } from '~/common/util/pwaUtils';
import { isChromeOnDesktopWindows, isIPhone } from '~/common/util/pwaUtils';
import { useUIPreferencesStore } from '~/common/state/store-ui';


Expand All @@ -12,7 +12,7 @@ export interface SpeechResult {


export function maySpeechRecognitionWork() {
return !isSafariOriPhone() && !!getSpeechRecognition();
return !isIPhone() && !!getSpeechRecognition();
}

/**
Expand Down Expand Up @@ -47,8 +47,8 @@ export const useSpeechRecognition = (onResultCallback: (result: SpeechResult) =>
}

// skip speech recognition on iPhones and Safari browsers - because of sub-par quality
if (isSafariOriPhone()) {
console.log('Speech recognition is disabled on iPhones and Safari browsers.');
if (isIPhone()) {
console.log('Speech recognition is disabled (not yet tested) on iPhones.');
return;
}

Expand Down
7 changes: 4 additions & 3 deletions src/common/util/pwaUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,11 @@ export function isPwa(): boolean {
// return true;
// };

export function isSafariOriPhone(): boolean {
const isSafari = /^((?!chrome|android).)*safari/i.test(navigator.userAgent);
export function isIPhone(): boolean {
// const isSafari = /^((?!chrome|android).)*safari/i.test(navigator.userAgent);
// noinspection UnnecessaryLocalVariableJS
const isiPhone = /iPhone|iPod/.test(navigator.userAgent);
return isSafari || isiPhone;
return /*isSafari ||*/ isiPhone;
}

export const isChromeOnDesktopWindows = (): boolean => {
Expand Down

1 comment on commit 34d5a32

@vercel
Copy link

@vercel vercel bot commented on 34d5a32 Sep 19, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

big-agi – ./

big-agi-git-main-enricoros.vercel.app
get.big-agi.com
big-agi-enricoros.vercel.app

Please sign in to comment.