]> git.djapps.eu Git - pkg/ggml/sources/whisper.cpp/commitdiff
talk.wasm : update video link + some minor fixes
authorGeorgi Gerganov <redacted>
Thu, 24 Nov 2022 18:15:07 +0000 (20:15 +0200)
committerGeorgi Gerganov <redacted>
Thu, 24 Nov 2022 18:15:24 +0000 (20:15 +0200)
examples/talk.wasm/emscripten.cpp
examples/talk.wasm/gpt-2.cpp
examples/talk.wasm/index-tmpl.html

index 6bd356474dc3f215bd20a54a5c211b930d982d22..f0add29c062d556bd0ef44409d4d0beeb3e7d440 100644 (file)
@@ -135,11 +135,9 @@ void talk_main(size_t index) {
 
         talk_set_status("processing ...");
 
-        g_force_speak = false;
-
         t_last = t_now;
 
-        {
+        if (!g_force_speak) {
             const auto t_start = std::chrono::high_resolution_clock::now();
 
             int ret = whisper_full(ctx, wparams, pcmf32.data(), pcmf32.size());
@@ -156,18 +154,22 @@ void talk_main(size_t index) {
         {
             std::string text_heard;
 
-            const int n_segments = whisper_full_n_segments(ctx);
-            for (int i = n_segments - 1; i < n_segments; ++i) {
-                const char * text = whisper_full_get_segment_text(ctx, i);
+            if (!g_force_speak) {
+                const int n_segments = whisper_full_n_segments(ctx);
+                for (int i = n_segments - 1; i < n_segments; ++i) {
+                    const char * text = whisper_full_get_segment_text(ctx, i);
 
-                const int64_t t0 = whisper_full_get_segment_t0(ctx, i);
-                const int64_t t1 = whisper_full_get_segment_t1(ctx, i);
+                    const int64_t t0 = whisper_full_get_segment_t0(ctx, i);
+                    const int64_t t1 = whisper_full_get_segment_t1(ctx, i);
 
-                printf ("[%s --> %s]  %s\n", to_timestamp(t0).c_str(), to_timestamp(t1).c_str(), text);
+                    printf ("[%s --> %s]  %s\n", to_timestamp(t0).c_str(), to_timestamp(t1).c_str(), text);
 
-                text_heard += text;
+                    text_heard += text;
+                }
             }
 
+            g_force_speak = false;
+
             // remove text between brackets using regex
             {
                 std::regex re("\\[.*?\\]");
index c6526e44fd6ec7a8406e3acdb28aae74030877fc..0bffe72b24fd414853ebca1ce60af1f350ab6b91 100644 (file)
@@ -812,9 +812,9 @@ I'm fine, thanks. How are you?
 Thanks, I'm fine too. What are you doing?
 I'm just sitting here.
 It's a lovely day, isn't it?
-Yes, it is.
-Did you know that I'm a robot?
-I wasn't aware of that.
+Yes, it is. I love the weather this time of year.
+I wish it would rain a little bit.
+Me too.
 )";
 
     std::mt19937 rng;
index ec1e3b381b186568f39d1dc9b78bc42ee8b7b731..be95b1d3a5dcc361fe0548c4121b8b461cb45ee3 100644 (file)
 
             <br><br>
 
-            Here is a short video of the demo in action: <a href="https://youtu.be/2om-7tFMaNs">https://youtu.be/2om-7tFMaNs</a>
+            Here is a short video of the demo in action: <a href="https://youtu.be/LeWKl8t1-Hc">https://youtu.be/LeWKl8t1-Hc</a>
 
             <br><br>
 
                     context = new AudioContext({
                         sampleRate: 16000,
                         channelCount: 1,
-                        echoCancellation: true,
+                        echoCancellation: false,
                         autoGainControl:  true,
                         noiseSuppression: true,
                     });