From d629c034a4bc86d1021f150efbc1328335dfbfdb Mon Sep 17 00:00:00 2001 From: Georgi Gerganov Date: Mon, 2 Jan 2023 09:54:43 +0200 Subject: [PATCH 1/2] models : fix HF model URL (close #356) --- models/download-ggml-model.cmd | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/models/download-ggml-model.cmd b/models/download-ggml-model.cmd index 9fe56cc..0def31a 100644 --- a/models/download-ggml-model.cmd +++ b/models/download-ggml-model.cmd @@ -40,7 +40,7 @@ if exist "ggml-%model%.bin" ( goto :eof ) -PowerShell -NoProfile -ExecutionPolicy Bypass -Command "Invoke-WebRequest -Uri https://huggingface.co/datasets/ggerganov/whisper.cpp/raw/main/ggml-%model%.bin -OutFile ggml-%model%.bin" +PowerShell -NoProfile -ExecutionPolicy Bypass -Command "Invoke-WebRequest -Uri https://huggingface.co/datasets/ggerganov/whisper.cpp/resolve/main/ggml-%model%.bin -OutFile ggml-%model%.bin" if %ERRORLEVEL% neq 0 ( echo Failed to download ggml model %model% From a466c3404dc62dc221061bb37fb8f78741d749b8 Mon Sep 17 00:00:00 2001 From: Georgi Gerganov Date: Mon, 2 Jan 2023 10:20:50 +0200 Subject: [PATCH 2/2] stream : fix data race on bool + avoid division-by-zero --- examples/stream/stream.cpp | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/examples/stream/stream.cpp b/examples/stream/stream.cpp index 1752fff..9caa614 100644 --- a/examples/stream/stream.cpp +++ b/examples/stream/stream.cpp @@ -8,6 +8,7 @@ #include #include +#include #include #include #include @@ -144,8 +145,8 @@ private: int m_len_ms = 0; int m_sample_rate = 0; - bool m_running = false; - std::mutex m_mutex; + std::atomic_bool m_running; + std::mutex m_mutex; std::vector m_audio; std::vector m_audio_new; @@ -155,6 +156,8 @@ private: audio_async::audio_async(int len_ms) { m_len_ms = len_ms; + + m_running = false; } audio_async::~audio_async() { @@ -427,10 +430,10 @@ int main(int argc, char ** argv) { const int n_samples_keep = (params.keep_ms *1e-3)*WHISPER_SAMPLE_RATE; const int n_samples_30s = (30000 *1e-3)*WHISPER_SAMPLE_RATE; - const int n_new_line = params.length_ms / params.step_ms - 1; // number of steps to print new line - const bool use_vad = n_samples_step <= 0; // sliding window mode uses VAD + const int n_new_line = !use_vad ? params.length_ms / params.step_ms - 1 : 1; // number of steps to print new line + params.no_timestamps = !use_vad; params.no_context = use_vad; params.max_tokens = 0;