Skip to content

Commit

Permalink
stream : add "single_segment" option
Browse files Browse the repository at this point in the history
Force the entire audio chunk to be transcribed into a single segment
ggerganov committed Nov 20, 2022
1 parent ea3344e commit b10d751
Showing 3 changed files with 8 additions and 4 deletions.
1 change: 1 addition & 0 deletions examples/stream/stream.cpp
Original file line number Diff line number Diff line change
@@ -328,6 +328,7 @@ int main(int argc, char ** argv) {
wparams.print_timestamps = !params.no_timestamps;
wparams.translate = params.translate;
wparams.no_context = params.no_context;
wparams.single_segment = true;
wparams.language = params.language.c_str();
wparams.n_threads = params.n_threads;

10 changes: 6 additions & 4 deletions whisper.cpp
Original file line number Diff line number Diff line change
@@ -2386,6 +2386,7 @@ struct whisper_full_params whisper_full_default_params(enum whisper_sampling_str

/*.translate =*/ false,
/*.no_context =*/ false,
/*.single_segment =*/ false,
/*.print_special_tokens =*/ false,
/*.print_progress =*/ true,
/*.print_realtime =*/ false,
@@ -2426,6 +2427,7 @@ struct whisper_full_params whisper_full_default_params(enum whisper_sampling_str

/*.translate =*/ false,
/*.no_context =*/ false,
/*.single_segment =*/ false,
/*.print_special_tokens =*/ false,
/*.print_progress =*/ true,
/*.print_realtime =*/ false,
@@ -2687,10 +2689,10 @@ int whisper_full(
}
}

// TODO: TMP TO MAKE STREAM WORK ON RPI4 ===
result_len = i + 1;
seek_delta = 100*WHISPER_CHUNK_SIZE;
// =========================================
if (params.single_segment) {
result_len = i + 1;
seek_delta = 100*WHISPER_CHUNK_SIZE;
}

break;
}
1 change: 1 addition & 0 deletions whisper.h
Original file line number Diff line number Diff line change
@@ -194,6 +194,7 @@ extern "C" {

bool translate;
bool no_context;
bool single_segment; // force single segment output (useful for streaming)
bool print_special_tokens;
bool print_progress;
bool print_realtime;

0 comments on commit b10d751

Please sign in to comment.