Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 20 additions & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ on:
branches: [ "main" ]

jobs:
build:
build-linux:
strategy:
matrix:
c_compiler: [gcc, clang]
Expand Down Expand Up @@ -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/
17 changes: 15 additions & 2 deletions examples/cli/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
6 changes: 3 additions & 3 deletions examples/server/server.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
}
Expand All @@ -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<std::chrono::seconds>(
Expand All @@ -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 {
Expand Down
4 changes: 2 additions & 2 deletions py-gguf/tts_encoders/orpheus_gguf_encoder.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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
Expand Down
4 changes: 1 addition & 3 deletions src/models/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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)
7 changes: 4 additions & 3 deletions src/models/dummy/model.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#include "model.h"

#include <cmath>
#include <math.h>
#include <numbers>
#include <cstring>

void dummy_runner::generate(const char * sentence, tts_response & output, const generation_configuration &) {
Expand All @@ -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<float[]>(output.n_outputs = N * SAMPLING_RATE);
for (size_t i{}; i < N; ++i) {
const float wavelength{static_cast<float>(SAMPLING_RATE / M_PI / 2) / (200 + sentence[i]) };
const float wavelength{static_cast<float>(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<float>(M_PI / SAMPLING_RATE)) * sin(j / wavelength);
buf[j] = sin(j * static_cast<float>(std::numbers::pi / SAMPLING_RATE)) * sin(j / wavelength);
}
}
output.data = outputs.get();
Expand Down
2 changes: 1 addition & 1 deletion src/models/kokoro/model.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion src/util.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<float> & 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);
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/util.h
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
#ifndef util_h
#define util_h

#define _USE_MATH_DEFINES
#include <cmath>
#include <numbers>
#include <math.h>
#include <functional>
#include <random>
#include <stdio.h>
Expand Down
Loading