]> git.djapps.eu Git - pkg/ggml/sources/whisper.cpp/commitdiff
command : fix build + fix README + add bold printing
authorGeorgi Gerganov <redacted>
Fri, 25 Nov 2022 17:53:50 +0000 (19:53 +0200)
committerGeorgi Gerganov <redacted>
Fri, 25 Nov 2022 17:53:50 +0000 (19:53 +0200)
examples/command/README.md
examples/command/command.cpp

index b4d62e480493f981e5fa55d51a384209b14cae4d..e955bdc85ab570be4a1b9a43b25da77c940ec281 100644 (file)
@@ -3,12 +3,12 @@
 This is a basic Voice Assistant example that accepts voice commands from the microphone.\r
 More info is available in [issue #171](https://github.com/ggerganov/whisper.cpp/issues/171).\r
 \r
-```java\r
+```bash\r
 # Run with default arguments and small model\r
 ./command -m ./models/ggml-small.en.bin -t 8\r
 \r
 # On Raspberry Pi, use tiny or base models + "-ac 768" for better performance\r
-./bin/command -m ../models/ggml-tiny.en.bin -ac 768\r
+./command -m ./models/ggml-tiny.en.bin -ac 768 -t 4 -c 0\r
 ```\r
 \r
 ## Building\r
index 9a9bde983b3b6a4f8ea44f25b3c0f60cf9e8f792..03a37bc2240d69e0d08939062131f687d2539eb4 100644 (file)
 
 #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");
                 }