File tree Expand file tree Collapse file tree
packages/react-native-executorch/common/rnexecutorch/models/speech_to_text/whisper Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1- #include < algorithm>
2- #include < array>
3- #include < numeric>
4- #include < random>
5-
61#include " ASR.h"
72#include " Constants.h"
83#include " Params.h"
116#include < rnexecutorch/data_processing/Numerical.h>
127#include < rnexecutorch/data_processing/gzip.h>
138
9+ #include < algorithm>
10+ #include < array>
11+ #include < numeric>
12+ #include < random>
13+ #include < ranges>
14+
1415namespace rnexecutorch ::models::speech_to_text::whisper {
1516
1617using executorch::runtime::etensor::ScalarType;
@@ -451,7 +452,7 @@ ASR::estimateWordLevelTimestampsLinear(std::span<const uint64_t> tokens,
451452 puncts += w.back ();
452453 w.pop_back ();
453454 }
454- std::reverse (puncts. begin (), puncts. end () );
455+ std::ranges:: reverse (puncts);
455456
456457 // Add the core word.
457458 wordObjs.emplace_back (std::move (w), wStart, wEnd);
Original file line number Diff line number Diff line change 11#include " OnlineASR.h"
2+ #include " Constants.h"
3+ #include " Params.h"
4+ #include " Utils.h"
25
36#include < algorithm>
47#include < iterator>
58#include < ranges>
69#include < utility>
710
8- #include " Constants.h"
9- #include " Params.h"
10- #include " Utils.h"
11-
1211namespace rnexecutorch ::models::speech_to_text::whisper::stream {
1312
1413OnlineASR::OnlineASR (const ASR *asr) : asr_(asr) {
@@ -41,8 +40,8 @@ void OnlineASR::insertAudioChunk(std::span<const float> audio) {
4140}
4241
4342ProcessResult OnlineASR::process (const DecodingOptions &options) {
44- constexpr float kStreamSafeBufferMaxSamples =
45- params::kStreamSafeBufferDuration * constants::kSamplingRate ;
43+ constexpr size_t kStreamSafeBufferMaxSamples = static_cast < size_t >(
44+ params::kStreamSafeBufferDuration * constants::kSamplingRate ) ;
4645
4746 std::vector<float > audioCopy;
4847
@@ -115,8 +114,7 @@ ProcessResult OnlineASR::process(const DecodingOptions &options) {
115114 // in a 'good' spot - where it will remove a significant audio chunk, yet
116115 // won't affect most recent, unfinished speech samples.
117116 size_t bufferSize = audioBuffer_.size ();
118- if (std::cmp_greater<size_t , size_t >(bufferSize,
119- kStreamSafeBufferMaxSamples )) {
117+ if (bufferSize > kStreamSafeBufferMaxSamples ) {
120118 auto newCommitted = commitAndClean (words);
121119
122120 committed.insert (committed.end (),
You can’t perform that action at this time.
0 commit comments