Skip to content

Commit 1134217

Browse files
authored
fix: s2t demo app crashes (#610)
## Description Changes: - reorder data member declarations ### Introduces a breaking change? - [ ] Yes - [x] No ### Type of change - [x] Bug fix (change which fixes an issue) - [ ] New feature (change which adds functionality) - [ ] Documentation update (improves or adds clarity to existing documentation) - [ ] Other (chores, tests, code style improvements etc.) ### Tested on - [x] iOS - [x] Android ### Checklist - [x] I have performed a self-review of my code - [x] I have commented my code, particularly in hard-to-understand areas - [ ] I have updated the documentation accordingly - [x] My changes generate no new warnings
1 parent e0a6cdb commit 1134217

File tree

2 files changed

+3
-6
lines changed

2 files changed

+3
-6
lines changed

packages/react-native-executorch/common/rnexecutorch/models/speech_to_text/SpeechToText.cpp

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -85,8 +85,6 @@ void SpeechToText::stream(std::shared_ptr<jsi::Function> callback,
8585
});
8686
};
8787

88-
this->resetStreamState();
89-
9088
this->isStreaming = true;
9189
while (this->isStreaming) {
9290
if (!this->readyToProcess ||
@@ -102,14 +100,13 @@ void SpeechToText::stream(std::shared_ptr<jsi::Function> callback,
102100

103101
std::string committed = this->processor->finish();
104102
nativeCallback(committed, "", true);
103+
104+
this->resetStreamState();
105105
}
106106

107107
void SpeechToText::streamStop() { this->isStreaming = false; }
108108

109109
void SpeechToText::streamInsert(std::span<float> waveform) {
110-
if (!this->isStreaming) {
111-
throw std::runtime_error("Streaming is not started");
112-
}
113110
this->processor->insertAudioChunk(waveform);
114111
this->readyToProcess = true;
115112
}

packages/react-native-executorch/common/rnexecutorch/models/speech_to_text/SpeechToText.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,13 +29,13 @@ class SpeechToText {
2929
void streamInsert(std::span<float> waveform);
3030

3131
private:
32+
std::shared_ptr<react::CallInvoker> callInvoker;
3233
std::unique_ptr<BaseModel> encoder;
3334
std::unique_ptr<BaseModel> decoder;
3435
std::unique_ptr<TokenizerModule> tokenizer;
3536
std::unique_ptr<asr::ASR> asr;
3637

3738
// Stream
38-
std::shared_ptr<react::CallInvoker> callInvoker;
3939
std::unique_ptr<stream::OnlineASRProcessor> processor;
4040
bool isStreaming;
4141
bool readyToProcess;

0 commit comments

Comments
 (0)