-
Notifications
You must be signed in to change notification settings - Fork 78
feat!: major performance & accuracy improvements in speech-to-text module #1132
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
IgorSwat
wants to merge
8
commits into
main
Choose a base branch
from
@is/speech-to-text-ultimate
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
b8276eb
Optimal streaming algorithm
IgorSwat 5b1c7b6
Merge branch '@is/speech-to-text-ultimate' of https://github.com/soft…
IgorSwat a82e6fc
Revert back to 100ms refresh rate
IgorSwat eccda55
Add CoreML whisper models
IgorSwat 0f77124
Update model urls
IgorSwat 6c6545d
Change default model for iOS devices
IgorSwat 1dfafbe
Add explicit timeout parameter
IgorSwat 66fde0e
Concurrency fixes & automatic cleaunp
IgorSwat File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -14,21 +14,25 @@ import { SafeAreaProvider, SafeAreaView } from 'react-native-safe-area-context'; | |
| import { | ||
| useSpeechToText, | ||
| WHISPER_TINY_EN, | ||
| WHISPER_TINY_EN_QUANTIZED, | ||
| WHISPER_TINY_EN_COREML, | ||
| WHISPER_BASE_EN, | ||
| WHISPER_BASE_EN_COREML, | ||
| WHISPER_SMALL_EN, | ||
| TranscriptionResult, | ||
| SpeechToTextProps, | ||
| WHISPER_SMALL_EN_COREML, | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. why this is added after |
||
| } from 'react-native-executorch'; | ||
| import { ModelPicker, ModelOption } from '../components/ModelPicker'; | ||
|
|
||
| type STTModelSources = SpeechToTextProps['model']; | ||
|
|
||
| const MODELS: ModelOption<STTModelSources>[] = [ | ||
| { label: 'Whisper Tiny', value: WHISPER_TINY_EN }, | ||
| { label: 'Whisper Tiny Q', value: WHISPER_TINY_EN_QUANTIZED }, | ||
| { label: 'Whisper Base', value: WHISPER_BASE_EN }, | ||
| { label: 'Whisper Small', value: WHISPER_SMALL_EN }, | ||
| { label: 'Whisper Tiny EN (XNNPACK)', value: WHISPER_TINY_EN }, | ||
| { label: 'Whisper Tiny EN (CoreML)', value: WHISPER_TINY_EN_COREML }, | ||
| { label: 'Whisper Base EN (XNNPACK)', value: WHISPER_BASE_EN }, | ||
| { label: 'Whisper Base EN (CoreML)', value: WHISPER_BASE_EN_COREML }, | ||
| { label: 'Whisper Small EN (XNNPACK)', value: WHISPER_SMALL_EN }, | ||
| { label: 'Whisper Small EN (CoreML)', value: WHISPER_SMALL_EN_COREML }, | ||
| ]; | ||
| import FontAwesome from '@expo/vector-icons/FontAwesome'; | ||
| import { | ||
|
|
@@ -45,9 +49,12 @@ import ErrorBanner from '../components/ErrorBanner'; | |
|
|
||
| const isSimulator = DeviceInfo.isEmulatorSync(); | ||
|
|
||
| const DEFAULT_MODEL = | ||
| Platform.OS === 'ios' ? WHISPER_BASE_EN_COREML : WHISPER_TINY_EN; | ||
|
|
||
| export const SpeechToTextScreen = ({ onBack }: { onBack: () => void }) => { | ||
| const [selectedModel, setSelectedModel] = | ||
| useState<STTModelSources>(WHISPER_TINY_EN); | ||
| useState<STTModelSources>(DEFAULT_MODEL); | ||
|
|
||
| const model = useSpeechToText({ | ||
| model: selectedModel, | ||
|
|
@@ -148,7 +155,7 @@ export const SpeechToTextScreen = ({ onBack }: { onBack: () => void }) => { | |
| recorder.current.onAudioReady( | ||
| { | ||
| sampleRate, | ||
| bufferLength: 0.1 * sampleRate, | ||
| bufferLength: 0.1 * sampleRate, // 100 ms | ||
| channelCount: 1, | ||
| }, | ||
| ({ buffer }) => { | ||
|
|
@@ -178,6 +185,7 @@ export const SpeechToTextScreen = ({ onBack }: { onBack: () => void }) => { | |
| try { | ||
| const streamIter = model.stream({ | ||
| verbose: enableTimestamps, | ||
| timeout: 100, | ||
| }); | ||
|
|
||
| for await (const { committed, nonCommitted } of streamIter) { | ||
|
|
||
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
hey, why is that? We virtually never want to downgrade packages in demo apps.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
audio-api 0.12.0causes build fails on iOS, and I think it's the same issue @benITo47 had when testing the 1.2.0 binaries some time ago.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you please name when you have these fails? I don't have any on iOS simulator.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tested on physical device.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@mdydek could you look at this one? Maybe you have an intuition behind this error? @IgorSwat do you have iOS 26.2 on your physical device?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, I even have 26.4.