Skip to content

Commit c04c77a

Browse files
authored
Merge pull request #117 from mrexodia/msvc-build
Fix Windows build
2 parents 0f2b6e5 + d58a767 commit c04c77a

File tree

9 files changed

+49
-18
lines changed

9 files changed

+49
-18
lines changed

.github/workflows/build.yml

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ on:
77
branches: [ "main" ]
88

99
jobs:
10-
build:
10+
build-linux:
1111
strategy:
1212
matrix:
1313
c_compiler: [gcc, clang]
@@ -58,3 +58,22 @@ jobs:
5858
with:
5959
name: ${{ runner.os }}-${{ matrix.c_compiler }}-build
6060
path: ${{ steps.strings.outputs.build-output-dir }}
61+
62+
build-windows:
63+
runs-on: windows-latest
64+
steps:
65+
- uses: actions/checkout@v5
66+
with:
67+
submodules: recursive
68+
- name: Enable Developer Command Prompt
69+
uses: ilammy/msvc-dev-cmd@0b201ec74fa43914dc39ae48a89fd1d8cb592756 # v1.13.0
70+
- name: build
71+
run: |
72+
cmake -B build -G Ninja -DCMAKE_C_COMPILER=cl -DCMAKE_CXX_COMPILER=cl -DCMAKE_BUILD_TYPE=Release
73+
cmake --build build
74+
75+
- name: Upload Build Artifacts
76+
uses: actions/upload-artifact@v4
77+
with:
78+
name: ${{ runner.os }}-msvc-build
79+
path: build/

examples/cli/CMakeLists.txt

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,21 @@ add_executable(${TARGET}
1010
vad.h
1111
)
1212

13-
find_package(SDL2)
14-
if (SDL2_FOUND)
13+
option(TTS_CLI_SDL "TTS.cpp: build the example cli with SDL" ON)
14+
15+
if(TTS_CLI_SDL)
16+
find_package(SDL2 QUIET)
17+
if (NOT SDL2_FOUND)
18+
include(FetchContent)
19+
message(STATUS "Could not find SDL2, fetching from git...")
20+
FetchContent_Declare(
21+
SDL2
22+
GIT_REPOSITORY https://github.com/libsdl-org/SDL.git
23+
GIT_TAG release-2.32.8
24+
)
25+
FetchContent_MakeAvailable(SDL2)
26+
endif()
27+
1528
target_link_libraries(${TARGET} PRIVATE SDL2::SDL2)
1629
set_source_files_properties(playback.cpp PROPERTIES COMPILE_FLAGS -DSDL2_INSTALL=1)
1730
endif()

examples/server/server.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -484,7 +484,7 @@ int main(int argc, const char ** argv) {
484484
if (std::filesystem::is_directory(model_path)) {
485485
for (auto const &entry : std::filesystem::directory_iterator(model_path)) {
486486
if (!entry.is_directory() && entry.path().extension() == ".gguf") {
487-
const std::string id = entry.path().stem();
487+
const std::string id = entry.path().stem().string();
488488
model_map[id] = entry.path().string();
489489
}
490490
}
@@ -494,7 +494,7 @@ int main(int argc, const char ** argv) {
494494
}
495495
} else {
496496
const std::filesystem::path path = model_path;
497-
model_map[path.stem()] = path;
497+
model_map[path.stem().string()] = path.string();
498498
}
499499

500500
auto model_creation = std::chrono::duration_cast<std::chrono::seconds>(
@@ -503,7 +503,7 @@ int main(int argc, const char ** argv) {
503503

504504
std::string default_model = "";
505505
if (args.get_string_param("--default-model") != "") {
506-
const std::string model = std::filesystem::path { args.get_string_param("--default-model") }.stem();
506+
const std::string model = std::filesystem::path { args.get_string_param("--default-model") }.stem().string();
507507
if (model_map.contains(model)) {
508508
default_model = model;
509509
} else {

py-gguf/tts_encoders/orpheus_gguf_encoder.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ def tokenizer_json(self) -> Dict:
8282
f"Failed with exception, {e}, attempting to obtain tokenizer.json via repository '{self.repo_id}'."
8383
)
8484
raise e
85-
with open(conf_path, "r+") as f:
85+
with open(conf_path, "r+", encoding="utf-8") as f:
8686
self._tokenizer_json = json.load(f)
8787
return self._tokenizer_json
8888

@@ -143,7 +143,7 @@ def prepare_snac_tensors(self):
143143

144144
def prepare_rope_frequencies(self):
145145
"""
146-
Because Llama-3 like Rotary Positional Embeddings are not currently supported out-of-the-box in GGML,
146+
Because Llama-3 like Rotary Positional Embeddings are not currently supported out-of-the-box in GGML,
147147
we need to encode the rope frequency vectors to use directly.
148148
"""
149149
base = self.model.config.rope_theta

src/models/CMakeLists.txt

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,7 @@ target_sources(tts PRIVATE
44
)
55

66
add_subdirectory(dia)
7-
if (LINUX)
8-
add_subdirectory(dummy)
9-
endif ()
7+
add_subdirectory(dummy)
108
add_subdirectory(kokoro)
119
add_subdirectory(orpheus)
1210
add_subdirectory(parler)

src/models/dummy/model.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
#include "model.h"
22

3-
#include <cmath>
3+
#include <math.h>
4+
#include <numbers>
45
#include <cstring>
56

67
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
910
const size_t N{ strlen(sentence) };
1011
outputs = make_unique_for_overwrite<float[]>(output.n_outputs = N * SAMPLING_RATE);
1112
for (size_t i{}; i < N; ++i) {
12-
const float wavelength{static_cast<float>(SAMPLING_RATE / M_PI / 2) / (200 + sentence[i]) };
13+
const float wavelength{static_cast<float>(SAMPLING_RATE / std::numbers::pi / 2) / (200 + sentence[i]) };
1314
float * buf = &outputs[i * SAMPLING_RATE];
1415
for (size_t j{}; j < SAMPLING_RATE; ++j) {
15-
buf[j] = sin(j * static_cast<float>(M_PI / SAMPLING_RATE)) * sin(j / wavelength);
16+
buf[j] = sin(j * static_cast<float>(std::numbers::pi / SAMPLING_RATE)) * sin(j / wavelength);
1617
}
1718
}
1819
output.data = outputs.get();

src/models/kokoro/model.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -385,7 +385,7 @@ void kokoro_model::post_load_assign() {
385385
sampling_factor_scalar->data = (void *)((uint8_t *) ggml_backend_buffer_get_base(buf) + offset);
386386
size_t scsize = ggml_nbytes(sampling_factor_scalar);
387387
// 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.
388-
float sample_scalar = upsample_scale*2.0f*M_PI;
388+
float sample_scalar = upsample_scale*2.0f*std::numbers::pi;
389389
ggml_backend_tensor_set(sampling_factor_scalar, &sample_scalar, 0, scsize);
390390
offset += scsize;
391391
post_load_tensor_bytes = 300 + offset - original_offset;

src/util.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ struct ggml_tensor * istft(ggml_context * ctx, struct ggml_tensor * a, struct gg
131131

132132
void hann_window(size_t n_fft, std::vector<float> & tgt) {
133133
for (int i = 0; i < n_fft; i++) {
134-
float v = pow(sin(M_PI * (double)i / (double) n_fft), 2.0);
134+
float v = pow(sin(std::numbers::pi * (double)i / (double) n_fft), 2.0);
135135
tgt.push_back(v);
136136
}
137137
}

src/util.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
#ifndef util_h
22
#define util_h
33

4-
#define _USE_MATH_DEFINES
5-
#include <cmath>
4+
#include <numbers>
5+
#include <math.h>
66
#include <functional>
77
#include <random>
88
#include <stdio.h>

0 commit comments

Comments
 (0)