Skip to content

Commit 7c911c3

Browse files
MateWWmkopcinsmsluszniakJakubGoneraNorbertKlockiewicz
authored
fix: make sure we are not combining chunks when only one chunk provided (#334)
## Description <!-- Provide a concise and descriptive summary of the changes implemented in this PR. --> When I tried to use new whisper release I've noticed that it's for some reason falling into infinite `generating` state. I've done investigation and it turned out that simply I was recording single word what was not longer than 1 chunk. In result it was causing some silent error which prevented model from being triggered. This guard resolves the issue for me. ### Type of change - [x] Bug fix (non-breaking change which fixes an issue) - [ ] New feature (non-breaking change which adds functionality) - [ ] Breaking change (fix or feature that would cause existing functionality to not work as expected) - [ ] Documentation update (improves or adds clarity to existing documentation) ### Tested on - [x] iOS - [ ] Android ### Testing instructions <!-- Provide step-by-step instructions on how to test your changes. Include setup details if necessary. --> I cannot share the code but just simply provide very short waveform to `transcribe` method of `useSpeechToText` hook ### Screenshots <!-- Add screenshots here, if applicable --> | Before | After | | --- | --- | | <video src="https://github.com/user-attachments/assets/41754d72-31bb-457a-90ec-f6e4447d0fd8" /> | <video src="https://github.com/user-attachments/assets/03df1a87-d3c1-4ba7-8aaa-f8a47cd91613" /> | ### Checklist - [x] I have performed a self-review of my code - [x] My changes generate no new warnings ### Additional notes <!-- Include any additional information, assumptions, or context that reviewers might need to understand this PR. --> --------- Co-authored-by: Mateusz Kopcinski <120639731+mkopcins@users.noreply.github.com> Co-authored-by: Mateusz Sluszniak <56299341+msluszniak@users.noreply.github.com> Co-authored-by: Jakub Gonera <38468585+JakubGonera@users.noreply.github.com> Co-authored-by: Norbert Klockiewicz <Nklockiewicz12@gmail.com> Co-authored-by: pweglik <36445788+pweglik@users.noreply.github.com>
1 parent 0870f93 commit 7c911c3

1 file changed

Lines changed: 2 additions & 0 deletions

File tree

packages/react-native-executorch/src/controllers/SpeechToTextController.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -279,6 +279,8 @@ export class SpeechToTextController {
279279

280280
// if last chunk is too short combine it with second to last to improve quality
281281
private validateAndFixLastChunk() {
282+
if (this.chunks.length < 2) return;
283+
282284
const lastChunkLength = this.chunks.at(-1)!.length / SECOND;
283285
const secondToLastChunkLength = this.chunks.at(-2)!.length / SECOND;
284286
if (lastChunkLength < 5 && secondToLastChunkLength + lastChunkLength < 30) {

0 commit comments

Comments
 (0)