Skip to content

Commit

Permalink
command : fix build + fix README + add bold printing
Browse files Browse the repository at this point in the history
  • Loading branch information
ggerganov committed Nov 25, 2022
1 parent bc88eb1 commit 0be27bb
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
4 changes: 2 additions & 2 deletions examples/command/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@
This is a basic Voice Assistant example that accepts voice commands from the microphone.
More info is available in [issue #171](https://github.com/ggerganov/whisper.cpp/issues/171).

```java
```bash
# Run with default arguments and small model
./command -m ./models/ggml-small.en.bin -t 8

# On Raspberry Pi, use tiny or base models + "-ac 768" for better performance
./bin/command -m ../models/ggml-tiny.en.bin -ac 768
./command -m ./models/ggml-tiny.en.bin -ac 768 -t 4 -c 0
```

## Building
Expand Down
14 changes: 7 additions & 7 deletions examples/command/command.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,12 @@

#include <cassert>
#include <cstdio>
#include <fstream>
#include <mutex>
#include <regex>
#include <string>
#include <thread>
#include <vector>
#include <fstream>
#include <regex>

// command-line parameters
struct whisper_params {
Expand Down Expand Up @@ -561,7 +562,7 @@ int main(int argc, char ** argv) {

if (ask_prompt) {
fprintf(stdout, "\n");
fprintf(stdout, "%s: Say the following phrase: '%s'\n", __func__, k_prompt.c_str());
fprintf(stdout, "%s: Say the following phrase: '%s%s%s'\n", __func__, "\033[1m", k_prompt.c_str(), "\033[0m");
fprintf(stdout, "\n");

ask_prompt = false;
Expand All @@ -573,14 +574,14 @@ int main(int argc, char ** argv) {
audio.get(2000, pcmf32_cur);

if (vad_simple(pcmf32_cur, WHISPER_SAMPLE_RATE, 1000, params.vad_thold, params.freq_thold, params.print_energy)) {
fprintf(stdout, "%s: Speech detected!\n", __func__);
fprintf(stdout, "%s: Speech detected! Processing ...\n", __func__);

if (!have_prompt) {
audio.get(params.prompt_ms, pcmf32_cur);

const auto txt = ::trim(::transcribe(ctx, params, pcmf32_cur, prob0, t_ms));

fprintf(stdout, "%s: Heard '%s', (prob = %6.3f, t = %d ms)\n", __func__, txt.c_str(), prob0, (int) t_ms);
fprintf(stdout, "%s: Heard '%s%s%s', (t = %d ms)\n", __func__, "\033[1m", txt.c_str(), "\033[0m", (int) t_ms);

const float sim = similarity(txt, k_prompt);

Expand All @@ -605,7 +606,6 @@ int main(int argc, char ** argv) {

const auto txt = ::trim(::transcribe(ctx, params, pcmf32_cur, prob, t_ms));

printf("prob0 = %6.3f, prob = %6.3f, t = %d ms\n", prob0, prob, (int) t_ms);
prob = 100.0f*(prob - prob0);

//fprintf(stdout, "%s: heard '%s'\n", __func__, txt.c_str());
Expand All @@ -628,7 +628,7 @@ int main(int argc, char ** argv) {

const std::string command = ::trim(txt.substr(best_len));

fprintf(stdout, "%s: Command '%s', (prob = %6.3f, t = %d ms)\n", __func__, command.c_str(), prob, (int) t_ms);
fprintf(stdout, "%s: Command '%s%s%s', (t = %d ms)\n", __func__, "\033[1m", command.c_str(), "\033[0m", (int) t_ms);
fprintf(stdout, "\n");
}

Expand Down

0 comments on commit 0be27bb

Please sign in to comment.