Skip to content
Open
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
12 changes: 12 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ project(omnivoice-ggml LANGUAGES C CXX)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)

option(OV_WEBSERVER "build webserver" ON)

# version.h: embed git commit hash into all binaries.
# runs on every build, only rewrites if the hash changed.
set(VERSION_OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/version.h")
Expand Down Expand Up @@ -139,6 +141,16 @@ add_executable(omnivoice-tts tools/omnivoice-tts.cpp)
target_link_libraries(omnivoice-tts PRIVATE omnivoice-core)
link_ggml_backends(omnivoice-tts)

# omnivoice-tts-server : an HTTP webserver backed by the TTS pipeline
if(OV_WEBSERVER)
find_package(httplib REQUIRED)
find_package(nlohmann_json REQUIRED)

add_executable(omnivoice-tts-server tools/omnivoice-tts-server.cpp)
target_link_libraries(omnivoice-tts-server PRIVATE omnivoice-core httplib::httplib nlohmann_json::nlohmann_json)
link_ggml_backends(omnivoice-tts-server)
endif()

# test-abi-c : pure C99 smoke test that locks in the public ABI contract.
# Compiles omnivoice.h with a C compiler under -Wall -Werror -pedantic and
# links against the static lib. The test never loads a model ; failure
Expand Down
32 changes: 32 additions & 0 deletions examples/client.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
#!/bin/bash

set -eu

if ! command -v jq; then
echo "This script requires 'jq', please install it before you proceed"
exit 1
fi

if [ $# -lt 1 ]; then
echo "Usage $0 input [lang format instructions]"
echo "Environment variables:"
echo
echo -e "OMNIVOICE_SERVER\tHTTP server URL (default: http://127.0.0.1:1234)"
echo -e "OMNIVOICE_OUTPUT\tOutput path (default: output.wav)"
echo -e "OV_TIMEOUT\tClient request timeout in seconds (default: 300)"
exit 255
fi

: "${OV_SERVER:=http://127.0.0.1:1234}"
: "${OV_OUTPUT:=output.wav}"
: "${OV_TIMEOUT:=300}"
PAYLOAD=$(jq -cn --arg input "$1" --arg lang "${2:-}" --arg format "${3:-}" --arg instructions "${4:-}" \
'if $input != "" then {input: $input} else . end +
if $lang != "" then {lang: $lang} else . end +
if $format != "" then {format: $format} else . end +
if $instructions != "" then {instructions: $instructions} else . end')

exec curl -v --max-time $OV_TIMEOUT --request POST \
--header "Content-Type: application/json" \
--data "$PAYLOAD" "$OV_SERVER"/v1/audio/speech \
--output "$OV_OUTPUT"
10 changes: 10 additions & 0 deletions examples/server.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#!/bin/bash

set -eu

exec ../build/omnivoice-tts-server \
--listen-ip 127.0.0.1 \
--model ../models/omnivoice-base-Q8_0.gguf \
--codec ../models/omnivoice-tokenizer-Q8_0.gguf \
--instruct "male, young adult, moderate pitch" \
--lang English "$@"
Loading