whisper: add chunk preference and change threading
Change-Id: Ie739345aacd95039a9f035f487a7cab35f442626
diff --git a/WhisperTranscript/TranscriptAudioSubscriber.h b/WhisperTranscript/TranscriptAudioSubscriber.h
index 7f53e3e..d32cb00 100644
--- a/WhisperTranscript/TranscriptAudioSubscriber.h
+++ b/WhisperTranscript/TranscriptAudioSubscriber.h
@@ -37,9 +37,6 @@
namespace jami {
-#define WHISPER_STREAM_SAMPLES_CHUNK 16000 * 10 // 16 KHz * 10 seconds
-#define WHISPER_STREAM_SAMPLES_CHUNK_STEP 16000 * 3 // 16KHz * 3 seconds
-
class TranscriptAudioSubscriber : public Observer<AVFrame*>
{
public:
@@ -65,31 +62,34 @@
// Filter for audio formatting
const std::string filterDescription_ = "[input]aresample=16000,aformat=sample_fmts=s16:channel_layouts=mono";
FrameFilter formatFilter_;
- std::vector<float> currentModelInput_{};
- std::vector<float> futureModelInput_{};
- std::string language_{"auto"};
+ std::array<std::vector<float>, 2> modelInput_ {};
+ int modelIdx_ {0};
+ int waitingPoint_ {1000};
+ std::string language_ {"auto"};
// Data
std::string path_;
// Status variables of the processing
bool firstRun {true};
- bool running {true};
- bool newFrame {false};
+ bool running {false};
- // Stream count
- int samplesCount_ = 0;
+ std::mutex inputLock;
// Model
ModelProcessor modelProcessor_;
// Threading
std::thread processFrameThread;
- std::mutex inputLock;
- std::condition_variable inputCv;
+ void processFrame();
void stop();
+ void start();
// Video processor
- TranscriptVideoSubscriber* mVS_{};
+ TranscriptVideoSubscriber* mVS_ {};
+
+
+ size_t WHISPER_STREAM_SAMPLES_CHUNK = 16000 * 15; // 16 KHz * 15 seconds
+ size_t WHISPER_STREAM_SAMPLES_CHUNK_STEP = 16000 * 3; // 16 KHz * 3 seconds
};
} // namespace jami