Skip to content

Commit

Permalink
stream : add "--capture" option to select capture device (ref ggergan…
Browse files Browse the repository at this point in the history
  • Loading branch information
ggerganov committed Oct 30, 2022
1 parent 6c3eab4 commit 36fb7cf
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions examples/stream/stream.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,11 @@ std::string to_timestamp(int64_t t) {

// command-line parameters
struct whisper_params {
int32_t seed = -1; // RNG seed, not used currently
int32_t n_threads = std::min(4, (int32_t) std::thread::hardware_concurrency());
int32_t step_ms = 3000;
int32_t length_ms = 10000;
int32_t seed = -1; // RNG seed, not used currently
int32_t n_threads = std::min(4, (int32_t) std::thread::hardware_concurrency());
int32_t step_ms = 3000;
int32_t length_ms = 10000;
int32_t capture_id = -1;

bool verbose = false;
bool translate = false;
Expand All @@ -65,6 +66,8 @@ bool whisper_params_parse(int argc, char ** argv, whisper_params & params) {
params.step_ms = std::stoi(argv[++i]);
} else if (arg == "--length") {
params.length_ms = std::stoi(argv[++i]);
} else if (arg == "-c" || arg == "--capture") {
params.capture_id = std::stoi(argv[++i]);
} else if (arg == "-v" || arg == "--verbose") {
params.verbose = true;
} else if (arg == "--translate") {
Expand Down Expand Up @@ -109,6 +112,7 @@ void whisper_print_usage(int argc, char ** argv, const whisper_params & params)
fprintf(stderr, " -t N, --threads N number of threads to use during computation (default: %d)\n", params.n_threads);
fprintf(stderr, " --step N audio step size in milliseconds (default: %d)\n", params.step_ms);
fprintf(stderr, " --length N audio length in milliseconds (default: %d)\n", params.length_ms);
fprintf(stderr, " -c ID, --capture ID capture device ID (default: -1)\n");
fprintf(stderr, " -v, --verbose verbose output\n");
fprintf(stderr, " --translate translate from source language to english\n");
fprintf(stderr, " -kc, --keep-context keep text context from earlier audio (default: false)\n");
Expand Down Expand Up @@ -201,7 +205,7 @@ int main(int argc, char ** argv) {

// init audio

if (!audio_sdl_init(-1)) {
if (!audio_sdl_init(params.capture_id)) {
fprintf(stderr, "%s: audio_sdl_init() failed!\n", __func__);
return 1;
}
Expand Down

0 comments on commit 36fb7cf

Please sign in to comment.