ggerganov commited on
Commit
58fce09
·
unverified ·
1 Parent(s): ba9fc0a

stream : add "--capture" option to select capture device (ref #10)

Browse files
Files changed (1) hide show
  1. examples/stream/stream.cpp +9 -5
examples/stream/stream.cpp CHANGED
@@ -35,10 +35,11 @@ std::string to_timestamp(int64_t t) {
35
 
36
  // command-line parameters
37
  struct whisper_params {
38
- int32_t seed = -1; // RNG seed, not used currently
39
- int32_t n_threads = std::min(4, (int32_t) std::thread::hardware_concurrency());
40
- int32_t step_ms = 3000;
41
- int32_t length_ms = 10000;
 
42
 
43
  bool verbose = false;
44
  bool translate = false;
@@ -65,6 +66,8 @@ bool whisper_params_parse(int argc, char ** argv, whisper_params & params) {
65
  params.step_ms = std::stoi(argv[++i]);
66
  } else if (arg == "--length") {
67
  params.length_ms = std::stoi(argv[++i]);
 
 
68
  } else if (arg == "-v" || arg == "--verbose") {
69
  params.verbose = true;
70
  } else if (arg == "--translate") {
@@ -109,6 +112,7 @@ void whisper_print_usage(int argc, char ** argv, const whisper_params & params)
109
  fprintf(stderr, " -t N, --threads N number of threads to use during computation (default: %d)\n", params.n_threads);
110
  fprintf(stderr, " --step N audio step size in milliseconds (default: %d)\n", params.step_ms);
111
  fprintf(stderr, " --length N audio length in milliseconds (default: %d)\n", params.length_ms);
 
112
  fprintf(stderr, " -v, --verbose verbose output\n");
113
  fprintf(stderr, " --translate translate from source language to english\n");
114
  fprintf(stderr, " -kc, --keep-context keep text context from earlier audio (default: false)\n");
@@ -201,7 +205,7 @@ int main(int argc, char ** argv) {
201
 
202
  // init audio
203
 
204
- if (!audio_sdl_init(-1)) {
205
  fprintf(stderr, "%s: audio_sdl_init() failed!\n", __func__);
206
  return 1;
207
  }
 
35
 
36
  // command-line parameters
37
  struct whisper_params {
38
+ int32_t seed = -1; // RNG seed, not used currently
39
+ int32_t n_threads = std::min(4, (int32_t) std::thread::hardware_concurrency());
40
+ int32_t step_ms = 3000;
41
+ int32_t length_ms = 10000;
42
+ int32_t capture_id = -1;
43
 
44
  bool verbose = false;
45
  bool translate = false;
 
66
  params.step_ms = std::stoi(argv[++i]);
67
  } else if (arg == "--length") {
68
  params.length_ms = std::stoi(argv[++i]);
69
+ } else if (arg == "-c" || arg == "--capture") {
70
+ params.capture_id = std::stoi(argv[++i]);
71
  } else if (arg == "-v" || arg == "--verbose") {
72
  params.verbose = true;
73
  } else if (arg == "--translate") {
 
112
  fprintf(stderr, " -t N, --threads N number of threads to use during computation (default: %d)\n", params.n_threads);
113
  fprintf(stderr, " --step N audio step size in milliseconds (default: %d)\n", params.step_ms);
114
  fprintf(stderr, " --length N audio length in milliseconds (default: %d)\n", params.length_ms);
115
+ fprintf(stderr, " -c ID, --capture ID capture device ID (default: -1)\n");
116
  fprintf(stderr, " -v, --verbose verbose output\n");
117
  fprintf(stderr, " --translate translate from source language to english\n");
118
  fprintf(stderr, " -kc, --keep-context keep text context from earlier audio (default: false)\n");
 
205
 
206
  // init audio
207
 
208
+ if (!audio_sdl_init(params.capture_id)) {
209
  fprintf(stderr, "%s: audio_sdl_init() failed!\n", __func__);
210
  return 1;
211
  }