mirror of
https://github.com/ggerganov/whisper.cpp.git
synced 2024-12-26 16:48:50 +01:00
stream : add "--capture" option to select capture device (ref #10)
This commit is contained in:
parent
eba62e0fa1
commit
5a9e4260a6
@ -35,10 +35,11 @@ std::string to_timestamp(int64_t t) {
|
|||||||
|
|
||||||
// command-line parameters
|
// command-line parameters
|
||||||
struct whisper_params {
|
struct whisper_params {
|
||||||
int32_t seed = -1; // RNG seed, not used currently
|
int32_t seed = -1; // RNG seed, not used currently
|
||||||
int32_t n_threads = std::min(4, (int32_t) std::thread::hardware_concurrency());
|
int32_t n_threads = std::min(4, (int32_t) std::thread::hardware_concurrency());
|
||||||
int32_t step_ms = 3000;
|
int32_t step_ms = 3000;
|
||||||
int32_t length_ms = 10000;
|
int32_t length_ms = 10000;
|
||||||
|
int32_t capture_id = -1;
|
||||||
|
|
||||||
bool verbose = false;
|
bool verbose = false;
|
||||||
bool translate = false;
|
bool translate = false;
|
||||||
@ -65,6 +66,8 @@ bool whisper_params_parse(int argc, char ** argv, whisper_params & params) {
|
|||||||
params.step_ms = std::stoi(argv[++i]);
|
params.step_ms = std::stoi(argv[++i]);
|
||||||
} else if (arg == "--length") {
|
} else if (arg == "--length") {
|
||||||
params.length_ms = std::stoi(argv[++i]);
|
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") {
|
} else if (arg == "-v" || arg == "--verbose") {
|
||||||
params.verbose = true;
|
params.verbose = true;
|
||||||
} else if (arg == "--translate") {
|
} else if (arg == "--translate") {
|
||||||
@ -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, " -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, " --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, " --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, " -v, --verbose verbose output\n");
|
||||||
fprintf(stderr, " --translate translate from source language to english\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");
|
fprintf(stderr, " -kc, --keep-context keep text context from earlier audio (default: false)\n");
|
||||||
@ -201,7 +205,7 @@ int main(int argc, char ** argv) {
|
|||||||
|
|
||||||
// init audio
|
// init audio
|
||||||
|
|
||||||
if (!audio_sdl_init(-1)) {
|
if (!audio_sdl_init(params.capture_id)) {
|
||||||
fprintf(stderr, "%s: audio_sdl_init() failed!\n", __func__);
|
fprintf(stderr, "%s: audio_sdl_init() failed!\n", __func__);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user