Skip to content

Commit 8ffd6ac

Browse files
IgorSwatmkopcins
authored andcommitted
chore: switch to fp16 CoreML whisper models (#1224)
Updates Whisper models URLs to match the recently uploaded CoreML fp16 models. The newly uploaded fp16 models are roughly 50% reduced in size and ~30% faster than the old fp32 ones. - [ ] Yes - [x] No - [ ] Bug fix (change which fixes an issue) - [ ] New feature (change which adds functionality) - [ ] Documentation update (improves or adds clarity to existing documentation) - [x] Other (chores, tests, code style improvements etc.) - [x] iOS - [ ] Android <!-- Provide step-by-step instructions on how to test your changes. Include setup details if necessary. --> <!-- Add screenshots here, if applicable --> <!-- Link related issues here using #issue-number --> - [x] I have performed a self-review of my code - [ ] I have commented my code, particularly in hard-to-understand areas - [ ] I have updated the documentation accordingly - [x] My changes generate no new warnings <!-- Include any additional information, assumptions, or context that reviewers might need to understand this PR. -->
1 parent 0e95b89 commit 8ffd6ac

2 files changed

Lines changed: 23 additions & 13 deletions

File tree

‎apps/speech/screens/SpeechToTextScreen.tsx‎

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -22,12 +22,24 @@ import { ModelPicker, ModelOption } from '../components/ModelPicker';
2222
const speechToText = models.speech_to_text;
2323
const vad = models.vad;
2424

25+
const isSimulator = DeviceInfo.isEmulatorSync();
26+
const backend = Platform.OS === 'ios' && !isSimulator ? 'coreml' : 'xnnpack';
27+
2528
type STTModelSources = SpeechToTextProps['model'];
2629

2730
const MODELS: ModelOption<STTModelSources>[] = [
28-
{ label: 'Whisper Tiny EN', value: speechToText.whisper_tiny_en() },
29-
{ label: 'Whisper Base EN', value: speechToText.whisper_base_en() },
30-
{ label: 'Whisper Small EN', value: speechToText.whisper_small_en() },
31+
{
32+
label: 'Whisper Tiny EN',
33+
value: speechToText.whisper_tiny_en({ backend }),
34+
},
35+
{
36+
label: 'Whisper Base EN',
37+
value: speechToText.whisper_base_en({ backend }),
38+
},
39+
{
40+
label: 'Whisper Small EN',
41+
value: speechToText.whisper_small_en({ backend }),
42+
},
3143
];
3244
import FontAwesome from '@expo/vector-icons/FontAwesome';
3345
import {
@@ -42,12 +54,10 @@ import DeviceInfo from 'react-native-device-info';
4254
import { VerboseTranscription } from '../components/VerboseTranscription';
4355
import ErrorBanner from '../components/ErrorBanner';
4456

45-
const isSimulator = DeviceInfo.isEmulatorSync();
46-
4757
export const SpeechToTextScreen = ({ onBack }: { onBack: () => void }) => {
4858
const [selectedModel, setSelectedModel] = useState<STTModelSources>(
49-
Platform.OS === 'ios'
50-
? speechToText.whisper_base_en()
59+
Platform.OS === 'ios' && !isSimulator
60+
? speechToText.whisper_base_en({ backend })
5161
: speechToText.whisper_tiny_en()
5262
);
5363

‎packages/react-native-executorch/src/constants/modelUrls.ts‎

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -816,27 +816,27 @@ export const STYLE_TRANSFER_UDNIE_QUANTIZED = {
816816
// S2T
817817
export const WHISPER_TINY_EN_TOKENIZER = `${URL_PREFIX}-whisper-tiny.en/${VERSION_TAG}/tokenizer.json`;
818818
export const WHISPER_TINY_EN_MODEL_XNNPACK = `${URL_PREFIX}-whisper-tiny.en/${VERSION_TAG}/xnnpack/whisper_tiny_en_xnnpack_fp32.pte`;
819-
export const WHISPER_TINY_EN_MODEL_COREML = `${URL_PREFIX}-whisper-tiny.en/${VERSION_TAG}/coreml/whisper_tiny_en_coreml_fp32.pte`;
819+
export const WHISPER_TINY_EN_MODEL_COREML = `${URL_PREFIX}-whisper-tiny.en/${VERSION_TAG}/coreml/whisper_tiny_en_coreml_fp16.pte`;
820820

821821
export const WHISPER_BASE_EN_TOKENIZER = `${URL_PREFIX}-whisper-base.en/${VERSION_TAG}/tokenizer.json`;
822822
export const WHISPER_BASE_EN_MODEL_XNNPACK = `${URL_PREFIX}-whisper-base.en/${VERSION_TAG}/xnnpack/whisper_base_en_xnnpack_fp32.pte`;
823-
export const WHISPER_BASE_EN_MODEL_COREML = `${URL_PREFIX}-whisper-base.en/${VERSION_TAG}/coreml/whisper_base_en_coreml_fp32.pte`;
823+
export const WHISPER_BASE_EN_MODEL_COREML = `${URL_PREFIX}-whisper-base.en/${VERSION_TAG}/coreml/whisper_base_en_coreml_fp16.pte`;
824824

825825
export const WHISPER_SMALL_EN_TOKENIZER = `${URL_PREFIX}-whisper-small.en/${VERSION_TAG}/tokenizer.json`;
826826
export const WHISPER_SMALL_EN_MODEL_XNNPACK = `${URL_PREFIX}-whisper-small.en/${VERSION_TAG}/xnnpack/whisper_small_en_xnnpack_fp32.pte`;
827-
export const WHISPER_SMALL_EN_MODEL_COREML = `${URL_PREFIX}-whisper-small.en/${VERSION_TAG}/coreml/whisper_small_en_coreml_fp32.pte`;
827+
export const WHISPER_SMALL_EN_MODEL_COREML = `${URL_PREFIX}-whisper-small.en/${VERSION_TAG}/coreml/whisper_small_en_coreml_fp16.pte`;
828828

829829
export const WHISPER_TINY_TOKENIZER = `${URL_PREFIX}-whisper-tiny/${VERSION_TAG}/tokenizer.json`;
830830
export const WHISPER_TINY_MODEL_XNNPACK = `${URL_PREFIX}-whisper-tiny/${VERSION_TAG}/xnnpack/whisper_tiny_xnnpack_fp32.pte`;
831-
export const WHISPER_TINY_MODEL_COREML = `${URL_PREFIX}-whisper-tiny/${VERSION_TAG}/coreml/whisper_tiny_coreml_fp32.pte`;
831+
export const WHISPER_TINY_MODEL_COREML = `${URL_PREFIX}-whisper-tiny/${VERSION_TAG}/coreml/whisper_tiny_coreml_fp16.pte`;
832832

833833
export const WHISPER_BASE_TOKENIZER = `${URL_PREFIX}-whisper-base/${VERSION_TAG}/tokenizer.json`;
834834
export const WHISPER_BASE_MODEL_XNNPACK = `${URL_PREFIX}-whisper-base/${VERSION_TAG}/xnnpack/whisper_base_xnnpack_fp32.pte`;
835-
export const WHISPER_BASE_MODEL_COREML = `${URL_PREFIX}-whisper-base/${VERSION_TAG}/coreml/whisper_base_coreml_fp32.pte`;
835+
export const WHISPER_BASE_MODEL_COREML = `${URL_PREFIX}-whisper-base/${VERSION_TAG}/coreml/whisper_base_coreml_fp16.pte`;
836836

837837
export const WHISPER_SMALL_TOKENIZER = `${URL_PREFIX}-whisper-small/${VERSION_TAG}/tokenizer.json`;
838838
export const WHISPER_SMALL_MODEL_XNNPACK = `${URL_PREFIX}-whisper-small/${VERSION_TAG}/xnnpack/whisper_small_xnnpack_fp32.pte`;
839-
export const WHISPER_SMALL_MODEL_COREML = `${URL_PREFIX}-whisper-small/${VERSION_TAG}/coreml/whisper_small_coreml_fp32.pte`;
839+
export const WHISPER_SMALL_MODEL_COREML = `${URL_PREFIX}-whisper-small/${VERSION_TAG}/coreml/whisper_small_coreml_fp16.pte`;
840840

841841
/**
842842
* @category Models - Speech To Text

0 commit comments

Comments
 (0)