Skip to content

Commit 3d1fb6e

Browse files
committed
refactor(speech): drop quantized whisper variants; migrate speech screens
- `models.speech_to_text.whisper_{tiny,base,small}_en` switch from `pair(base, quantized)` to `base(...)`. The quantized whisper builds are slated for removal (#1134-followup) — picking them up by default was wrong even before they go away. - `apps/speech/screens/{TextToSpeechScreen,TextToSpeechLLMScreen,Quiz}.tsx` migrated from the bare `KOKORO_*` constants to `models.text_to_speech.<lang>.<voice>()`. - `SpeechToTextScreen` and `voice_chat` pickers drop the "Whisper Tiny Q" duplicate entry now that there's a single Whisper Tiny variant.
1 parent 5187c6a commit 3d1fb6e

6 files changed

Lines changed: 34 additions & 67 deletions

File tree

apps/llm/app/voice_chat/index.tsx

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -43,10 +43,6 @@ const LLM_MODELS: ModelOption<LLMModelSources>[] = [
4343
const STT_MODELS: ModelOption<STTModelSources>[] = [
4444
{
4545
label: 'Whisper Tiny',
46-
value: models.speech_to_text.whisper_tiny_en({ quant: false }),
47-
},
48-
{
49-
label: 'Whisper Tiny Q',
5046
value: models.speech_to_text.whisper_tiny_en(),
5147
},
5248
{
@@ -73,7 +69,7 @@ function VoiceChatScreen() {
7369
models.llm.qwen3_0_6b()
7470
);
7571
const [selectedSTT, setSelectedSTT] = useState<STTModelSources>(
76-
models.speech_to_text.whisper_tiny_en({ quant: false })
72+
models.speech_to_text.whisper_tiny_en()
7773
);
7874
const [error, setError] = useState<string | null>(null);
7975

apps/speech/screens/Quiz.tsx

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,7 @@ import Animated, {
1717
runOnJS,
1818
} from 'react-native-reanimated';
1919
import { SafeAreaProvider, SafeAreaView } from 'react-native-safe-area-context';
20-
import {
21-
KOKORO_AMERICAN_ENGLISH_MALE_SANTA,
22-
useTextToSpeech,
23-
} from 'react-native-executorch';
20+
import { models, useTextToSpeech } from 'react-native-executorch';
2421
import {
2522
AudioManager,
2623
AudioContext,
@@ -59,7 +56,7 @@ const createAudioBufferFromVector = (
5956

6057
export const Quiz = ({ onBack }: { onBack: () => void }) => {
6158
// --- Hooks & State ---
62-
const model = useTextToSpeech(KOKORO_AMERICAN_ENGLISH_MALE_SANTA);
59+
const model = useTextToSpeech(models.text_to_speech.en_us.santa());
6360

6461
const [shuffledQuestions] = useState(() => shuffleArray(QUESTIONS));
6562
const [currentIndex, setCurrentIndex] = useState(0);

apps/speech/screens/SpeechToTextScreen.tsx

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,6 @@ type STTModelSources = SpeechToTextProps['model'];
2525
const MODELS: ModelOption<STTModelSources>[] = [
2626
{
2727
label: 'Whisper Tiny',
28-
value: speechToText.whisper_tiny_en({ quant: false }),
29-
},
30-
{
31-
label: 'Whisper Tiny Q',
3228
value: speechToText.whisper_tiny_en(),
3329
},
3430
{
@@ -57,7 +53,7 @@ const isSimulator = DeviceInfo.isEmulatorSync();
5753

5854
export const SpeechToTextScreen = ({ onBack }: { onBack: () => void }) => {
5955
const [selectedModel, setSelectedModel] = useState<STTModelSources>(
60-
speechToText.whisper_tiny_en({ quant: false })
56+
speechToText.whisper_tiny_en()
6157
);
6258

6359
const model = useSpeechToText({

apps/speech/screens/TextToSpeechLLMScreen.tsx

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,7 @@ import {
99
import { SafeAreaProvider, SafeAreaView } from 'react-native-safe-area-context';
1010
import FontAwesome from '@expo/vector-icons/FontAwesome';
1111
import SWMIcon from '../assets/swm_icon.svg';
12-
import {
13-
useLLM,
14-
useTextToSpeech,
15-
KOKORO_AMERICAN_ENGLISH_FEMALE_HEART,
16-
LLAMA3_2_1B_QLORA,
17-
} from 'react-native-executorch';
12+
import { models, useLLM, useTextToSpeech } from 'react-native-executorch';
1813
import {
1914
AudioManager,
2015
AudioContext,
@@ -52,8 +47,8 @@ const createAudioBufferFromVector = (
5247
export const TextToSpeechLLMScreen = ({ onBack }: TextToSpeechLLMProps) => {
5348
const [displayText, setDisplayText] = useState('');
5449
const [isTtsStreaming, setIsTtsStreaming] = useState(false);
55-
const llm = useLLM({ model: LLAMA3_2_1B_QLORA });
56-
const tts = useTextToSpeech(KOKORO_AMERICAN_ENGLISH_FEMALE_HEART);
50+
const llm = useLLM({ model: models.llm.llama3_2_1b() });
51+
const tts = useTextToSpeech(models.text_to_speech.en_us.heart());
5752

5853
const processedLengthRef = useRef(0);
5954
const audioContextRef = useRef<AudioContext | null>(null);

apps/speech/screens/TextToSpeechScreen.tsx

Lines changed: 24 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -10,52 +10,35 @@ import {
1010
} from 'react-native';
1111
import { SafeAreaProvider, SafeAreaView } from 'react-native-safe-area-context';
1212
import {
13+
models,
1314
useTextToSpeech,
1415
TextToSpeechModelConfig,
15-
KOKORO_AMERICAN_ENGLISH_FEMALE_HEART,
16-
KOKORO_AMERICAN_ENGLISH_FEMALE_RIVER,
17-
KOKORO_AMERICAN_ENGLISH_FEMALE_SARAH,
18-
KOKORO_AMERICAN_ENGLISH_MALE_ADAM,
19-
KOKORO_AMERICAN_ENGLISH_MALE_MICHAEL,
20-
KOKORO_AMERICAN_ENGLISH_MALE_SANTA,
21-
KOKORO_BRITISH_ENGLISH_FEMALE_EMMA,
22-
KOKORO_BRITISH_ENGLISH_MALE_DANIEL,
23-
KOKORO_FRENCH_FEMALE_SIWIS,
24-
KOKORO_SPANISH_FEMALE_DORA,
25-
KOKORO_SPANISH_MALE_ALEX,
26-
KOKORO_ITALIAN_FEMALE_SARA,
27-
KOKORO_ITALIAN_MALE_NICOLA,
28-
KOKORO_PORTUGUESE_FEMALE_DORA,
29-
KOKORO_PORTUGUESE_MALE_SANTA,
30-
KOKORO_GERMAN_FEMALE_ANNA,
31-
KOKORO_POLISH_MALE_MATEUSZ,
32-
KOKORO_HINDI_FEMALE_ALPHA,
33-
KOKORO_HINDI_MALE_OMEGA,
34-
KOKORO_HINDI_MALE_PSI,
3516
} from 'react-native-executorch';
3617
import { ModelPicker, ModelOption } from '../components/ModelPicker';
3718

19+
const tts = models.text_to_speech;
20+
3821
const VOICES: ModelOption<TextToSpeechModelConfig>[] = [
39-
{ label: '🇺🇸 AF Heart', value: KOKORO_AMERICAN_ENGLISH_FEMALE_HEART },
40-
{ label: '🇺🇸 AF River', value: KOKORO_AMERICAN_ENGLISH_FEMALE_RIVER },
41-
{ label: '🇺🇸 AF Sarah', value: KOKORO_AMERICAN_ENGLISH_FEMALE_SARAH },
42-
{ label: '🇺🇸 AM Adam', value: KOKORO_AMERICAN_ENGLISH_MALE_ADAM },
43-
{ label: '🇺🇸 AM Michael', value: KOKORO_AMERICAN_ENGLISH_MALE_MICHAEL },
44-
{ label: '🇺🇸 AM Santa', value: KOKORO_AMERICAN_ENGLISH_MALE_SANTA },
45-
{ label: '🇬🇧 BF Emma', value: KOKORO_BRITISH_ENGLISH_FEMALE_EMMA },
46-
{ label: '🇬🇧 BM Daniel', value: KOKORO_BRITISH_ENGLISH_MALE_DANIEL },
47-
{ label: '🇫🇷 FF Siwis', value: KOKORO_FRENCH_FEMALE_SIWIS },
48-
{ label: '🇪🇸 EF Dora', value: KOKORO_SPANISH_FEMALE_DORA },
49-
{ label: '🇪🇸 EM Alex', value: KOKORO_SPANISH_MALE_ALEX },
50-
{ label: '🇮🇹 IF Sara', value: KOKORO_ITALIAN_FEMALE_SARA },
51-
{ label: '🇮🇹 IM Nicola', value: KOKORO_ITALIAN_MALE_NICOLA },
52-
{ label: '🇵🇹 PF Dora', value: KOKORO_PORTUGUESE_FEMALE_DORA },
53-
{ label: '🇵🇹 PM Santa', value: KOKORO_PORTUGUESE_MALE_SANTA },
54-
{ label: '🇩🇪 DF Anna', value: KOKORO_GERMAN_FEMALE_ANNA },
55-
{ label: '🇵🇱 PM Mateusz', value: KOKORO_POLISH_MALE_MATEUSZ },
56-
{ label: '🇮🇳 HF Alpha', value: KOKORO_HINDI_FEMALE_ALPHA },
57-
{ label: '🇮🇳 HM Omega', value: KOKORO_HINDI_MALE_OMEGA },
58-
{ label: '🇮🇳 HM Psi', value: KOKORO_HINDI_MALE_PSI },
22+
{ label: '🇺🇸 AF Heart', value: tts.en_us.heart() },
23+
{ label: '🇺🇸 AF River', value: tts.en_us.river() },
24+
{ label: '🇺🇸 AF Sarah', value: tts.en_us.sarah() },
25+
{ label: '🇺🇸 AM Adam', value: tts.en_us.adam() },
26+
{ label: '🇺🇸 AM Michael', value: tts.en_us.michael() },
27+
{ label: '🇺🇸 AM Santa', value: tts.en_us.santa() },
28+
{ label: '🇬🇧 BF Emma', value: tts.en_gb.emma() },
29+
{ label: '🇬🇧 BM Daniel', value: tts.en_gb.daniel() },
30+
{ label: '🇫🇷 FF Siwis', value: tts.fr.siwis() },
31+
{ label: '🇪🇸 EF Dora', value: tts.es.dora() },
32+
{ label: '🇪🇸 EM Alex', value: tts.es.alex() },
33+
{ label: '🇮🇹 IF Sara', value: tts.it.sara() },
34+
{ label: '🇮🇹 IM Nicola', value: tts.it.nicola() },
35+
{ label: '🇵🇹 PF Dora', value: tts.pt.dora() },
36+
{ label: '🇵🇹 PM Santa', value: tts.pt.santa() },
37+
{ label: '🇩🇪 DF Anna', value: tts.de.anna() },
38+
{ label: '🇵🇱 PM Mateusz', value: tts.pl.mateusz() },
39+
{ label: '🇮🇳 HF Alpha', value: tts.hi.alpha() },
40+
{ label: '🇮🇳 HM Omega', value: tts.hi.omega() },
41+
{ label: '🇮🇳 HM Psi', value: tts.hi.psi() },
5942
];
6043

6144
import FontAwesome from '@expo/vector-icons/FontAwesome';
@@ -95,7 +78,7 @@ const createAudioBufferFromVector = (
9578

9679
export const TextToSpeechScreen = ({ onBack }: { onBack: () => void }) => {
9780
const [selectedSpeaker, setSelectedSpeaker] =
98-
useState<TextToSpeechModelConfig>(KOKORO_AMERICAN_ENGLISH_FEMALE_HEART);
81+
useState<TextToSpeechModelConfig>(tts.en_us.heart());
9982

10083
const model = useTextToSpeech(selectedSpeaker);
10184

packages/react-native-executorch/src/constants/modelRegistry.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -486,9 +486,9 @@ export const models = {
486486
udnie: variant(STYLE_TRANSFER_UDNIE_VARIANTS, COREML_ON_IOS),
487487
},
488488
speech_to_text: {
489-
whisper_tiny_en: pair(M.WHISPER_TINY_EN, M.WHISPER_TINY_EN_QUANTIZED),
490-
whisper_base_en: pair(M.WHISPER_BASE_EN, M.WHISPER_BASE_EN_QUANTIZED),
491-
whisper_small_en: pair(M.WHISPER_SMALL_EN, M.WHISPER_SMALL_EN_QUANTIZED),
489+
whisper_tiny_en: base(M.WHISPER_TINY_EN),
490+
whisper_base_en: base(M.WHISPER_BASE_EN),
491+
whisper_small_en: base(M.WHISPER_SMALL_EN),
492492
whisper_tiny: base(M.WHISPER_TINY),
493493
whisper_base: base(M.WHISPER_BASE),
494494
whisper_small: base(M.WHISPER_SMALL),

0 commit comments

Comments
 (0)