Spaces:
Running
Running
stream : add "single_segment" option
Browse filesForce the entire audio chunk to be transcribed into a single segment
- examples/stream/stream.cpp +1 -0
- whisper.cpp +6 -4
- whisper.h +1 -0
examples/stream/stream.cpp
CHANGED
|
@@ -328,6 +328,7 @@ int main(int argc, char ** argv) {
|
|
| 328 |
wparams.print_timestamps = !params.no_timestamps;
|
| 329 |
wparams.translate = params.translate;
|
| 330 |
wparams.no_context = params.no_context;
|
|
|
|
| 331 |
wparams.language = params.language.c_str();
|
| 332 |
wparams.n_threads = params.n_threads;
|
| 333 |
|
|
|
|
| 328 |
wparams.print_timestamps = !params.no_timestamps;
|
| 329 |
wparams.translate = params.translate;
|
| 330 |
wparams.no_context = params.no_context;
|
| 331 |
+
wparams.single_segment = true;
|
| 332 |
wparams.language = params.language.c_str();
|
| 333 |
wparams.n_threads = params.n_threads;
|
| 334 |
|
whisper.cpp
CHANGED
|
@@ -2392,6 +2392,7 @@ struct whisper_full_params whisper_full_default_params(enum whisper_sampling_str
|
|
| 2392 |
|
| 2393 |
/*.translate =*/ false,
|
| 2394 |
/*.no_context =*/ false,
|
|
|
|
| 2395 |
/*.print_special_tokens =*/ false,
|
| 2396 |
/*.print_progress =*/ true,
|
| 2397 |
/*.print_realtime =*/ false,
|
|
@@ -2432,6 +2433,7 @@ struct whisper_full_params whisper_full_default_params(enum whisper_sampling_str
|
|
| 2432 |
|
| 2433 |
/*.translate =*/ false,
|
| 2434 |
/*.no_context =*/ false,
|
|
|
|
| 2435 |
/*.print_special_tokens =*/ false,
|
| 2436 |
/*.print_progress =*/ true,
|
| 2437 |
/*.print_realtime =*/ false,
|
|
@@ -2693,10 +2695,10 @@ int whisper_full(
|
|
| 2693 |
}
|
| 2694 |
}
|
| 2695 |
|
| 2696 |
-
|
| 2697 |
-
|
| 2698 |
-
|
| 2699 |
-
|
| 2700 |
|
| 2701 |
break;
|
| 2702 |
}
|
|
|
|
| 2392 |
|
| 2393 |
/*.translate =*/ false,
|
| 2394 |
/*.no_context =*/ false,
|
| 2395 |
+
/*.single_segment =*/ false,
|
| 2396 |
/*.print_special_tokens =*/ false,
|
| 2397 |
/*.print_progress =*/ true,
|
| 2398 |
/*.print_realtime =*/ false,
|
|
|
|
| 2433 |
|
| 2434 |
/*.translate =*/ false,
|
| 2435 |
/*.no_context =*/ false,
|
| 2436 |
+
/*.single_segment =*/ false,
|
| 2437 |
/*.print_special_tokens =*/ false,
|
| 2438 |
/*.print_progress =*/ true,
|
| 2439 |
/*.print_realtime =*/ false,
|
|
|
|
| 2695 |
}
|
| 2696 |
}
|
| 2697 |
|
| 2698 |
+
if (params.single_segment) {
|
| 2699 |
+
result_len = i + 1;
|
| 2700 |
+
seek_delta = 100*WHISPER_CHUNK_SIZE;
|
| 2701 |
+
}
|
| 2702 |
|
| 2703 |
break;
|
| 2704 |
}
|
whisper.h
CHANGED
|
@@ -194,6 +194,7 @@ extern "C" {
|
|
| 194 |
|
| 195 |
bool translate;
|
| 196 |
bool no_context;
|
|
|
|
| 197 |
bool print_special_tokens;
|
| 198 |
bool print_progress;
|
| 199 |
bool print_realtime;
|
|
|
|
| 194 |
|
| 195 |
bool translate;
|
| 196 |
bool no_context;
|
| 197 |
+
bool single_segment; // force single segment output (useful for streaming)
|
| 198 |
bool print_special_tokens;
|
| 199 |
bool print_progress;
|
| 200 |
bool print_realtime;
|