Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions examples/cli/cli.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@ struct whisper_params {

// Voice Activity Detection (VAD) parameters
bool vad = false;
bool stable_timestamps = false;
std::string vad_model = "";
float vad_threshold = 0.5f;
int vad_min_speech_duration_ms = 250;
Expand Down Expand Up @@ -210,6 +211,7 @@ static bool whisper_params_parse(int argc, char ** argv, whisper_params & params
else if ( arg == "--grammar-penalty") { params.grammar_penalty = std::stof(ARGV_NEXT); }
// Voice Activity Detection (VAD)
else if ( arg == "--vad") { params.vad = true; }
else if ( arg == "--stable-timestamps") { params.stable_timestamps = true; }
else if (arg == "-vm" || arg == "--vad-model") { params.vad_model = ARGV_NEXT; }
else if (arg == "-vt" || arg == "--vad-threshold") { params.vad_threshold = std::stof(ARGV_NEXT); }
else if (arg == "-vspd" || arg == "--vad-min-speech-duration-ms") { params.vad_min_speech_duration_ms = std::stoi(ARGV_NEXT); }
Expand Down Expand Up @@ -293,6 +295,7 @@ static void whisper_print_usage(int /*argc*/, char ** argv, const whisper_params
// Voice Activity Detection (VAD) parameters
fprintf(stderr, "\nVoice Activity Detection (VAD) options:\n");
fprintf(stderr, " --vad [%-7s] enable Voice Activity Detection (VAD)\n", params.vad ? "true" : "false");
fprintf(stderr, " --stable-timestamps [%-7s] enable stable timestamps\n", params.stable_timestamps ? "true" : "false");
fprintf(stderr, " -vm FNAME, --vad-model FNAME [%-7s] VAD model path\n", params.vad_model.c_str());
fprintf(stderr, " -vt N, --vad-threshold N [%-7.2f] VAD threshold for speech recognition\n", params.vad_threshold);
fprintf(stderr, " -vspd N, --vad-min-speech-duration-ms N [%-7d] VAD min speech duration (0.0-1.0)\n", params.vad_min_speech_duration_ms);
Expand Down Expand Up @@ -1211,6 +1214,7 @@ int main(int argc, char ** argv) {

wparams.suppress_nst = params.suppress_nst;

wparams.stable_timestamps = params.stable_timestamps;
wparams.vad = params.vad;
wparams.vad_model_path = params.vad_model.c_str();

Expand Down
4 changes: 4 additions & 0 deletions include/whisper.h
Original file line number Diff line number Diff line change
Expand Up @@ -583,6 +583,10 @@ extern "C" {
size_t i_start_rule;
float grammar_penalty;

// Stable timestamps - snap word boundaries to speech edges using VAD
// Requires vad_model_path to be set. Forces vad=true, token_timestamps=true, max_initial_ts=0.
bool stable_timestamps;

// Voice Activity Detection (VAD) params
bool vad; // Enable VAD
const char * vad_model_path; // Path to VAD model
Expand Down
3 changes: 3 additions & 0 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,9 @@ endif()
add_library(whisper
../include/whisper.h
whisper-arch.h
whisper-state.h
whisper-stable.h
whisper-stable.cpp
whisper.cpp
)

Expand Down
Loading