Skip to content

Commit 170b2fa

Browse files
authored
whisper : add no_context parameter to whisper_params (#3045)
1 parent f8a3509 commit 170b2fa

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

examples/server/server.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,7 @@ struct whisper_params {
7979
bool use_gpu = true;
8080
bool flash_attn = false;
8181
bool suppress_nst = false;
82+
bool no_context = false;
8283

8384
std::string language = "en";
8485
std::string prompt = "";
@@ -140,6 +141,7 @@ void whisper_print_usage(int /*argc*/, char ** argv, const whisper_params & para
140141
fprintf(stderr, " --convert, [%-7s] Convert audio to WAV, requires ffmpeg on the server\n", sparams.ffmpeg_converter ? "true" : "false");
141142
fprintf(stderr, " -sns, --suppress-nst [%-7s] suppress non-speech tokens\n", params.suppress_nst ? "true" : "false");
142143
fprintf(stderr, " -nth N, --no-speech-thold N [%-7.2f] no speech threshold\n", params.no_speech_thold);
144+
fprintf(stderr, " -nc, --no-context [%-7s] do not use previous audio context\n", params.no_context ? "true" : "false");
143145
fprintf(stderr, "\n");
144146
}
145147

@@ -186,6 +188,7 @@ bool whisper_params_parse(int argc, char ** argv, whisper_params & params, serve
186188
else if (arg == "-fa" || arg == "--flash-attn") { params.flash_attn = true; }
187189
else if (arg == "-sns" || arg == "--suppress-nst") { params.suppress_nst = true; }
188190
else if (arg == "-nth" || arg == "--no-speech-thold") { params.no_speech_thold = std::stof(argv[++i]); }
191+
else if (arg == "-nc" || arg == "--no-context") { params.no_context = true; }
189192

190193
// server params
191194
else if ( arg == "--port") { sparams.port = std::stoi(argv[++i]); }
@@ -506,6 +509,10 @@ void get_req_parameters(const Request & req, whisper_params & params)
506509
{
507510
params.suppress_nst = parse_str_to_bool(req.get_file_value("suppress_nst").content);
508511
}
512+
if (req.has_file("no_context"))
513+
{
514+
params.no_context = parse_str_to_bool(req.get_file_value("no_context").content);
515+
}
509516
}
510517

511518
} // namespace
@@ -818,6 +825,7 @@ int main(int argc, char ** argv) {
818825

819826
wparams.no_timestamps = params.no_timestamps;
820827
wparams.token_timestamps = !params.no_timestamps && params.response_format == vjson_format;
828+
wparams.no_context = params.no_context;
821829

822830
wparams.suppress_nst = params.suppress_nst;
823831

0 commit comments

Comments
 (0)