From: Daniel Bevenius Date: Tue, 30 Sep 2025 14:23:01 +0000 (+0200) Subject: examples : add wchess.wasm to wasm examples build (#3443) X-Git-Tag: upstream/1.8.0~1 X-Git-Url: https://git.djapps.eu/?a=commitdiff_plain;h=5904d00dbb5a5cfc7e27fefa727f79509f6cd37d;p=pkg%2Fggml%2Fsources%2Fwhisper.cpp examples : add wchess.wasm to wasm examples build (#3443) * examples : add wchess.wasm to wasm examples build This commit add the wchess.wasm example to the wasm examples that are deployed to https://ggml.ai/whisper.cpp. Refs: https://github.com/ggml-org/whisper.cpp/issues/3434#issuecomment-3346980420 --- diff --git a/.github/workflows/examples-wasm.yml b/.github/workflows/examples-wasm.yml index 125c106b..ebbbdfe2 100644 --- a/.github/workflows/examples-wasm.yml +++ b/.github/workflows/examples-wasm.yml @@ -67,6 +67,12 @@ jobs: cp ${build_dir}/stream.wasm/{index.html,stream.js,helpers.js} ${target_dir} cp ${build_dir}/libstream.js ${target_dir} + # wchess.wasm + target_dir=staging/wchess.wasm + mkdir -p ${target_dir} + cp -r ${build_dir}/wchess.wasm/{index.html,css,img,js} ${target_dir} + cp ${build_dir}/wchess.wasm.js ${target_dir} + # whisper.wasm (this will be the main example page) target_dir=staging mkdir -p ${target_dir} diff --git a/examples/CMakeLists.txt b/examples/CMakeLists.txt index c37a2e6d..b202ca00 100644 --- a/examples/CMakeLists.txt +++ b/examples/CMakeLists.txt @@ -98,6 +98,7 @@ if (EMSCRIPTEN) add_subdirectory(stream.wasm) add_subdirectory(command.wasm) add_subdirectory(bench.wasm) + add_subdirectory(wchess) elseif(CMAKE_JS_VERSION) add_subdirectory(addon.node) else() diff --git a/examples/bench.wasm/index-tmpl.html b/examples/bench.wasm/index-tmpl.html index 91589c35..3a941747 100644 --- a/examples/bench.wasm/index-tmpl.html +++ b/examples/bench.wasm/index-tmpl.html @@ -42,6 +42,7 @@ bench | stream | command | + wchess |

diff --git a/examples/command.wasm/index-tmpl.html b/examples/command.wasm/index-tmpl.html index 2221e934..b8dabba3 100644 --- a/examples/command.wasm/index-tmpl.html +++ b/examples/command.wasm/index-tmpl.html @@ -42,6 +42,7 @@ bench | stream | command | + wchess |

diff --git a/examples/server.py b/examples/server.py index 14f67722..e47368d8 100644 --- a/examples/server.py +++ b/examples/server.py @@ -47,7 +47,12 @@ class CustomHTTPRequestHandler(http.server.SimpleHTTPRequestHandler): elif actual_path == '/': self.path = '/whisper.wasm/index.html' - elif actual_path.startswith('/bench.wasm/') or actual_path.startswith('/command.wasm/') or actual_path.startswith('/stream.wasm/'): + elif any(actual_path.startswith(prefix) for prefix in ( + '/bench.wasm/', + '/command.wasm/', + '/stream.wasm/', + '/wchess.wasm/' + )): # Keep the path as is, just remove the context root self.path = actual_path # For all other paths under the context root diff --git a/examples/stream.wasm/index-tmpl.html b/examples/stream.wasm/index-tmpl.html index 941f4507..546d30a5 100644 --- a/examples/stream.wasm/index-tmpl.html +++ b/examples/stream.wasm/index-tmpl.html @@ -42,6 +42,7 @@ bench | stream | command | + wchess |

diff --git a/examples/wchess/README.md b/examples/wchess/README.md index 924b8d9a..d9694a1e 100644 --- a/examples/wchess/README.md +++ b/examples/wchess/README.md @@ -2,7 +2,7 @@ Voice-controlled chess using Whisper -Online demo: https://whisper.ggerganov.com/wchess/ +Online demo: https://ggml.ai/whisper.cpp/ https://github.com/ggerganov/whisper.cpp/assets/1991296/c2b2f03c-9684-49f3-8106-357d2d4e67fa diff --git a/examples/wchess/wchess.wasm/CMakeLists.txt b/examples/wchess/wchess.wasm/CMakeLists.txt index 0d3dd908..74689283 100644 --- a/examples/wchess/wchess.wasm/CMakeLists.txt +++ b/examples/wchess/wchess.wasm/CMakeLists.txt @@ -32,11 +32,10 @@ set_target_properties(${TARGET} PROPERTIES LINK_FLAGS " \ -s INITIAL_MEMORY=1024MB \ -s TOTAL_MEMORY=1024MB \ -s FORCE_FILESYSTEM=1 \ - -s EXPORTED_RUNTIME_METHODS=\"['print', 'printErr', 'ccall', 'cwrap', 'HEAPU8']]\" \ + -s EXPORTED_RUNTIME_METHODS=\"['print', 'printErr', 'ccall', 'cwrap', 'HEAPU8']\" \ ${EXTRA_FLAGS} \ ") - add_custom_command( TARGET ${TARGET} POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy_directory diff --git a/examples/wchess/wchess.wasm/index-tmpl.html b/examples/wchess/wchess.wasm/index-tmpl.html index 47452b31..8f251c20 100644 --- a/examples/wchess/wchess.wasm/index-tmpl.html +++ b/examples/wchess/wchess.wasm/index-tmpl.html @@ -120,11 +120,10 @@

More examples: - main | - bench | - stream | - command | - talk | + main | + bench | + stream | + command |

diff --git a/examples/whisper.wasm/index-tmpl.html b/examples/whisper.wasm/index-tmpl.html index d5f1be89..0a7e40e3 100644 --- a/examples/whisper.wasm/index-tmpl.html +++ b/examples/whisper.wasm/index-tmpl.html @@ -52,6 +52,7 @@ bench | stream | command | + wchess |