diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index eee3a93..d716811 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,22 @@ 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=Release + cmake --build build + + - name: Upload Build Artifacts + uses: actions/upload-artifact@v4 + with: + name: ${{ runner.os }}-msvc-build + path: build/ diff --git a/examples/cli/CMakeLists.txt b/examples/cli/CMakeLists.txt index 2aaefcf..f288221 100644 --- a/examples/cli/CMakeLists.txt +++ b/examples/cli/CMakeLists.txt @@ -10,8 +10,21 @@ add_executable(${TARGET} vad.h ) -find_package(SDL2) -if (SDL2_FOUND) +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) endif() 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/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 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..3460842 100644 --- a/src/models/dummy/model.cpp +++ b/src/models/dummy/model.cpp @@ -1,6 +1,7 @@ #include "model.h" -#include +#include +#include #include void dummy_runner::generate(const char * sentence, tts_response & output, const generation_configuration &) { @@ -9,10 +10,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(); 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