From 79a9462d1190d48a2cb80fffc0bd8c33301f7833 Mon Sep 17 00:00:00 2001 From: Duncan Ogilvie Date: Mon, 1 Sep 2025 17:10:21 +0200 Subject: [PATCH 1/8] Fix build on Windows (MSVC) --- examples/cli/CMakeLists.txt | 17 +++++++++++++---- examples/server/server.cpp | 6 +++--- src/models/CMakeLists.txt | 4 +--- src/models/dummy/model.cpp | 6 +++--- 4 files changed, 20 insertions(+), 13 deletions(-) diff --git a/examples/cli/CMakeLists.txt b/examples/cli/CMakeLists.txt index 2aaefcf..19ceb56 100644 --- a/examples/cli/CMakeLists.txt +++ b/examples/cli/CMakeLists.txt @@ -10,10 +10,19 @@ add_executable(${TARGET} vad.h ) -find_package(SDL2) -if (SDL2_FOUND) - target_link_libraries(${TARGET} PRIVATE SDL2::SDL2) - set_source_files_properties(playback.cpp PROPERTIES COMPILE_FLAGS -DSDL2_INSTALL=1) +find_package(SDL2 QUIET) +if (NOT SDL2_FOUND) + include(FetchContent) + message(STATUS "Could not find SDL2, fetching from git...") + FetchContent_Declare( + SDL2 + GIT_REPOSITORY https://github.com/libsdl-org/SDL.git + GIT_TAG release-2.32.8 + ) + FetchContent_MakeAvailable(SDL2) endif() +target_link_libraries(${TARGET} PRIVATE SDL2::SDL2) +set_source_files_properties(playback.cpp PROPERTIES COMPILE_FLAGS -DSDL2_INSTALL=1) + target_link_libraries(${TARGET} PRIVATE ggml tts) diff --git a/examples/server/server.cpp b/examples/server/server.cpp index dbcc719..e1cd99b 100644 --- a/examples/server/server.cpp +++ b/examples/server/server.cpp @@ -484,7 +484,7 @@ int main(int argc, const char ** argv) { if (std::filesystem::is_directory(model_path)) { for (auto const &entry : std::filesystem::directory_iterator(model_path)) { if (!entry.is_directory() && entry.path().extension() == ".gguf") { - const std::string id = entry.path().stem(); + const std::string id = entry.path().stem().string(); model_map[id] = entry.path().string(); } } @@ -494,7 +494,7 @@ int main(int argc, const char ** argv) { } } else { const std::filesystem::path path = model_path; - model_map[path.stem()] = path; + model_map[path.stem().string()] = path.string(); } auto model_creation = std::chrono::duration_cast( @@ -503,7 +503,7 @@ int main(int argc, const char ** argv) { std::string default_model = ""; if (args.get_string_param("--default-model") != "") { - const std::string model = std::filesystem::path { args.get_string_param("--default-model") }.stem(); + const std::string model = std::filesystem::path { args.get_string_param("--default-model") }.stem().string(); if (model_map.contains(model)) { default_model = model; } else { diff --git a/src/models/CMakeLists.txt b/src/models/CMakeLists.txt index 348c4e4..35c09f9 100644 --- a/src/models/CMakeLists.txt +++ b/src/models/CMakeLists.txt @@ -4,9 +4,7 @@ target_sources(tts PRIVATE ) add_subdirectory(dia) -if (LINUX) - add_subdirectory(dummy) -endif () +add_subdirectory(dummy) add_subdirectory(kokoro) add_subdirectory(orpheus) add_subdirectory(parler) diff --git a/src/models/dummy/model.cpp b/src/models/dummy/model.cpp index bce8c2c..7555034 100644 --- a/src/models/dummy/model.cpp +++ b/src/models/dummy/model.cpp @@ -1,6 +1,6 @@ #include "model.h" -#include +#include #include void dummy_runner::generate(const char * sentence, tts_response & output, const generation_configuration &) { @@ -9,10 +9,10 @@ void dummy_runner::generate(const char * sentence, tts_response & output, const const size_t N{ strlen(sentence) }; outputs = make_unique_for_overwrite(output.n_outputs = N * SAMPLING_RATE); for (size_t i{}; i < N; ++i) { - const float wavelength{static_cast(SAMPLING_RATE / M_PI / 2) / (200 + sentence[i]) }; + const float wavelength{static_cast(SAMPLING_RATE / std::numbers::pi / 2) / (200 + sentence[i]) }; float * buf = &outputs[i * SAMPLING_RATE]; for (size_t j{}; j < SAMPLING_RATE; ++j) { - buf[j] = sin(j * static_cast(M_PI / SAMPLING_RATE)) * sin(j / wavelength); + buf[j] = sin(j * static_cast(std::numbers::pi / SAMPLING_RATE)) * sin(j / wavelength); } } output.data = outputs.get(); From cf5c6319212a11804c6bcd60e0623c09bd5c434b Mon Sep 17 00:00:00 2001 From: Duncan Ogilvie Date: Mon, 1 Sep 2025 17:12:51 +0200 Subject: [PATCH 2/8] GitHub Actions for Windows --- .github/workflows/build.yml | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index eee3a93..f0bad36 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -7,7 +7,7 @@ on: branches: [ "main" ] jobs: - build: + build-linux: strategy: matrix: c_compiler: [gcc, clang] @@ -58,3 +58,16 @@ jobs: with: name: ${{ runner.os }}-${{ matrix.c_compiler }}-build path: ${{ steps.strings.outputs.build-output-dir }} + + build-windows: + runs-on: windows-latest + steps: + - uses: actions/checkout@v5 + with: + submodules: recursive + - name: Enable Developer Command Prompt + uses: ilammy/msvc-dev-cmd@0b201ec74fa43914dc39ae48a89fd1d8cb592756 # v1.13.0 + - name: build + run: | + cmake -B build -G Ninja -DCMAKE_C_COMPILER=cl -DCMAKE_CXX_COMPILER=cl -DCMAKE_BUILD_TYPE=Debug + cmake --build build From 0a75acf2e341b3a56afc1ff62ee215b990733253 Mon Sep 17 00:00:00 2001 From: Duncan Ogilvie Date: Mon, 1 Sep 2025 23:05:11 +0200 Subject: [PATCH 3/8] Add option for SDL in cli example --- examples/cli/CMakeLists.txt | 30 +++++++++++++++++------------- 1 file changed, 17 insertions(+), 13 deletions(-) diff --git a/examples/cli/CMakeLists.txt b/examples/cli/CMakeLists.txt index 19ceb56..f288221 100644 --- a/examples/cli/CMakeLists.txt +++ b/examples/cli/CMakeLists.txt @@ -10,19 +10,23 @@ add_executable(${TARGET} vad.h ) -find_package(SDL2 QUIET) -if (NOT SDL2_FOUND) - include(FetchContent) - message(STATUS "Could not find SDL2, fetching from git...") - FetchContent_Declare( - SDL2 - GIT_REPOSITORY https://github.com/libsdl-org/SDL.git - GIT_TAG release-2.32.8 - ) - FetchContent_MakeAvailable(SDL2) -endif() +option(TTS_CLI_SDL "TTS.cpp: build the example cli with SDL" ON) + +if(TTS_CLI_SDL) + find_package(SDL2 QUIET) + if (NOT SDL2_FOUND) + include(FetchContent) + message(STATUS "Could not find SDL2, fetching from git...") + FetchContent_Declare( + SDL2 + GIT_REPOSITORY https://github.com/libsdl-org/SDL.git + GIT_TAG release-2.32.8 + ) + FetchContent_MakeAvailable(SDL2) + endif() -target_link_libraries(${TARGET} PRIVATE SDL2::SDL2) -set_source_files_properties(playback.cpp PROPERTIES COMPILE_FLAGS -DSDL2_INSTALL=1) + target_link_libraries(${TARGET} PRIVATE SDL2::SDL2) + set_source_files_properties(playback.cpp PROPERTIES COMPILE_FLAGS -DSDL2_INSTALL=1) +endif() target_link_libraries(${TARGET} PRIVATE ggml tts) From 3e33e8b6ca4a27cd01f85440093679728c3151fd Mon Sep 17 00:00:00 2001 From: Duncan Ogilvie Date: Mon, 1 Sep 2025 23:09:11 +0200 Subject: [PATCH 4/8] Replace other occurrences of M_PI with std::numbers::pi --- src/models/kokoro/model.cpp | 2 +- src/util.cpp | 2 +- src/util.h | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/models/kokoro/model.cpp b/src/models/kokoro/model.cpp index 345bcd4..ceb23a8 100644 --- a/src/models/kokoro/model.cpp +++ b/src/models/kokoro/model.cpp @@ -385,7 +385,7 @@ void kokoro_model::post_load_assign() { sampling_factor_scalar->data = (void *)((uint8_t *) ggml_backend_buffer_get_base(buf) + offset); size_t scsize = ggml_nbytes(sampling_factor_scalar); // while it might appear that the upsampling_rate could be used here, the interpolation rate (i.e. the upsampling scale) is actually independent in the kokoro model implementation. - float sample_scalar = upsample_scale*2.0f*M_PI; + float sample_scalar = upsample_scale*2.0f*std::numbers::pi; ggml_backend_tensor_set(sampling_factor_scalar, &sample_scalar, 0, scsize); offset += scsize; post_load_tensor_bytes = 300 + offset - original_offset; diff --git a/src/util.cpp b/src/util.cpp index 9068c70..1f875ef 100644 --- a/src/util.cpp +++ b/src/util.cpp @@ -131,7 +131,7 @@ struct ggml_tensor * istft(ggml_context * ctx, struct ggml_tensor * a, struct gg void hann_window(size_t n_fft, std::vector & tgt) { for (int i = 0; i < n_fft; i++) { - float v = pow(sin(M_PI * (double)i / (double) n_fft), 2.0); + float v = pow(sin(std::numbers::pi * (double)i / (double) n_fft), 2.0); tgt.push_back(v); } } diff --git a/src/util.h b/src/util.h index 42b2164..30c1b3d 100644 --- a/src/util.h +++ b/src/util.h @@ -1,8 +1,8 @@ #ifndef util_h #define util_h -#define _USE_MATH_DEFINES -#include +#include +#include #include #include #include From c840a3b3004af2de6350b761a7fa22d225c306bf Mon Sep 17 00:00:00 2001 From: Duncan Ogilvie Date: Fri, 5 Sep 2025 15:39:41 +0200 Subject: [PATCH 5/8] Build on Windows in Release mode in CI --- .github/workflows/build.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index f0bad36..00a3405 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -69,5 +69,5 @@ jobs: uses: ilammy/msvc-dev-cmd@0b201ec74fa43914dc39ae48a89fd1d8cb592756 # v1.13.0 - name: build run: | - cmake -B build -G Ninja -DCMAKE_C_COMPILER=cl -DCMAKE_CXX_COMPILER=cl -DCMAKE_BUILD_TYPE=Debug + cmake -B build -G Ninja -DCMAKE_C_COMPILER=cl -DCMAKE_CXX_COMPILER=cl -DCMAKE_BUILD_TYPE=Release cmake --build build From 08f1633f8f34067e0199fe629127b7537f4e35dd Mon Sep 17 00:00:00 2001 From: Duncan Ogilvie Date: Fri, 5 Sep 2025 15:40:04 +0200 Subject: [PATCH 6/8] Fix exception when running gguf encoder on Windows --- py-gguf/tts_encoders/orpheus_gguf_encoder.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/py-gguf/tts_encoders/orpheus_gguf_encoder.py b/py-gguf/tts_encoders/orpheus_gguf_encoder.py index 89b9317..f75df8d 100644 --- a/py-gguf/tts_encoders/orpheus_gguf_encoder.py +++ b/py-gguf/tts_encoders/orpheus_gguf_encoder.py @@ -82,7 +82,7 @@ def tokenizer_json(self) -> Dict: f"Failed with exception, {e}, attempting to obtain tokenizer.json via repository '{self.repo_id}'." ) raise e - with open(conf_path, "r+") as f: + with open(conf_path, "r+", encoding="utf-8") as f: self._tokenizer_json = json.load(f) return self._tokenizer_json @@ -143,7 +143,7 @@ def prepare_snac_tensors(self): def prepare_rope_frequencies(self): """ - Because Llama-3 like Rotary Positional Embeddings are not currently supported out-of-the-box in GGML, + Because Llama-3 like Rotary Positional Embeddings are not currently supported out-of-the-box in GGML, we need to encode the rope frequency vectors to use directly. """ base = self.model.config.rope_theta From ea05768b545458e479c28952aa341227ecba8b34 Mon Sep 17 00:00:00 2001 From: Duncan Ogilvie Date: Fri, 5 Sep 2025 19:46:54 +0200 Subject: [PATCH 7/8] Attempt to fix CI build --- src/models/dummy/model.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/models/dummy/model.cpp b/src/models/dummy/model.cpp index 7555034..3460842 100644 --- a/src/models/dummy/model.cpp +++ b/src/models/dummy/model.cpp @@ -1,5 +1,6 @@ #include "model.h" +#include #include #include From d58a7673f3cf4f607c144c36d7f464184be4b6cb Mon Sep 17 00:00:00 2001 From: Duncan Ogilvie Date: Fri, 19 Sep 2025 17:52:53 +0200 Subject: [PATCH 8/8] Update .github/workflows/build.yml Co-authored-by: ecyht2 <94816144+ecyht2@users.noreply.github.com> --- .github/workflows/build.yml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 00a3405..d716811 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -71,3 +71,9 @@ jobs: run: | cmake -B build -G Ninja -DCMAKE_C_COMPILER=cl -DCMAKE_CXX_COMPILER=cl -DCMAKE_BUILD_TYPE=Release cmake --build build + + - name: Upload Build Artifacts + uses: actions/upload-artifact@v4 + with: + name: ${{ runner.os }}-msvc-build + path: build/