command : fix build + fix README + add bold printing

pull/194/head
Georgi Gerganov 2 years ago
parent bc88eb13c6
commit 0be27bbd92
No known key found for this signature in database
GPG Key ID: 449E073F9DC10735

@ -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

@ -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 {
@ -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;
@ -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);
@ -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());
@ -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");
}

Loading…
Cancel
Save