ggerganov commited on
Commit
f70b793
·
unverified ·
1 Parent(s): 4d3c293

command : fix build + fix README + add bold printing

Browse files
examples/command/README.md CHANGED
@@ -3,12 +3,12 @@
3
  This is a basic Voice Assistant example that accepts voice commands from the microphone.
4
  More info is available in [issue #171](https://github.com/ggerganov/whisper.cpp/issues/171).
5
 
6
- ```java
7
  # Run with default arguments and small model
8
  ./command -m ./models/ggml-small.en.bin -t 8
9
 
10
  # On Raspberry Pi, use tiny or base models + "-ac 768" for better performance
11
- ./bin/command -m ../models/ggml-tiny.en.bin -ac 768
12
  ```
13
 
14
  ## Building
 
3
  This is a basic Voice Assistant example that accepts voice commands from the microphone.
4
  More info is available in [issue #171](https://github.com/ggerganov/whisper.cpp/issues/171).
5
 
6
+ ```bash
7
  # Run with default arguments and small model
8
  ./command -m ./models/ggml-small.en.bin -t 8
9
 
10
  # On Raspberry Pi, use tiny or base models + "-ac 768" for better performance
11
+ ./command -m ./models/ggml-tiny.en.bin -ac 768 -t 4 -c 0
12
  ```
13
 
14
  ## Building
examples/command/command.cpp CHANGED
@@ -13,11 +13,12 @@
13
 
14
  #include <cassert>
15
  #include <cstdio>
 
 
 
16
  #include <string>
17
  #include <thread>
18
  #include <vector>
19
- #include <fstream>
20
- #include <regex>
21
 
22
  // command-line parameters
23
  struct whisper_params {
@@ -561,7 +562,7 @@ int main(int argc, char ** argv) {
561
 
562
  if (ask_prompt) {
563
  fprintf(stdout, "\n");
564
- fprintf(stdout, "%s: Say the following phrase: '%s'\n", __func__, k_prompt.c_str());
565
  fprintf(stdout, "\n");
566
 
567
  ask_prompt = false;
@@ -573,14 +574,14 @@ int main(int argc, char ** argv) {
573
  audio.get(2000, pcmf32_cur);
574
 
575
  if (vad_simple(pcmf32_cur, WHISPER_SAMPLE_RATE, 1000, params.vad_thold, params.freq_thold, params.print_energy)) {
576
- fprintf(stdout, "%s: Speech detected!\n", __func__);
577
 
578
  if (!have_prompt) {
579
  audio.get(params.prompt_ms, pcmf32_cur);
580
 
581
  const auto txt = ::trim(::transcribe(ctx, params, pcmf32_cur, prob0, t_ms));
582
 
583
- fprintf(stdout, "%s: Heard '%s', (prob = %6.3f, t = %d ms)\n", __func__, txt.c_str(), prob0, (int) t_ms);
584
 
585
  const float sim = similarity(txt, k_prompt);
586
 
@@ -605,7 +606,6 @@ int main(int argc, char ** argv) {
605
 
606
  const auto txt = ::trim(::transcribe(ctx, params, pcmf32_cur, prob, t_ms));
607
 
608
- printf("prob0 = %6.3f, prob = %6.3f, t = %d ms\n", prob0, prob, (int) t_ms);
609
  prob = 100.0f*(prob - prob0);
610
 
611
  //fprintf(stdout, "%s: heard '%s'\n", __func__, txt.c_str());
@@ -628,7 +628,7 @@ int main(int argc, char ** argv) {
628
 
629
  const std::string command = ::trim(txt.substr(best_len));
630
 
631
- fprintf(stdout, "%s: Command '%s', (prob = %6.3f, t = %d ms)\n", __func__, command.c_str(), prob, (int) t_ms);
632
  fprintf(stdout, "\n");
633
  }
634
 
 
13
 
14
  #include <cassert>
15
  #include <cstdio>
16
+ #include <fstream>
17
+ #include <mutex>
18
+ #include <regex>
19
  #include <string>
20
  #include <thread>
21
  #include <vector>
 
 
22
 
23
  // command-line parameters
24
  struct whisper_params {
 
562
 
563
  if (ask_prompt) {
564
  fprintf(stdout, "\n");
565
+ fprintf(stdout, "%s: Say the following phrase: '%s%s%s'\n", __func__, "\033[1m", k_prompt.c_str(), "\033[0m");
566
  fprintf(stdout, "\n");
567
 
568
  ask_prompt = false;
 
574
  audio.get(2000, pcmf32_cur);
575
 
576
  if (vad_simple(pcmf32_cur, WHISPER_SAMPLE_RATE, 1000, params.vad_thold, params.freq_thold, params.print_energy)) {
577
+ fprintf(stdout, "%s: Speech detected! Processing ...\n", __func__);
578
 
579
  if (!have_prompt) {
580
  audio.get(params.prompt_ms, pcmf32_cur);
581
 
582
  const auto txt = ::trim(::transcribe(ctx, params, pcmf32_cur, prob0, t_ms));
583
 
584
+ fprintf(stdout, "%s: Heard '%s%s%s', (t = %d ms)\n", __func__, "\033[1m", txt.c_str(), "\033[0m", (int) t_ms);
585
 
586
  const float sim = similarity(txt, k_prompt);
587
 
 
606
 
607
  const auto txt = ::trim(::transcribe(ctx, params, pcmf32_cur, prob, t_ms));
608
 
 
609
  prob = 100.0f*(prob - prob0);
610
 
611
  //fprintf(stdout, "%s: heard '%s'\n", __func__, txt.c_str());
 
628
 
629
  const std::string command = ::trim(txt.substr(best_len));
630
 
631
+ fprintf(stdout, "%s: Command '%s%s%s', (t = %d ms)\n", __func__, "\033[1m", command.c_str(), "\033[0m", (int) t_ms);
632
  fprintf(stdout, "\n");
633
  }
634