PiperTTS as OpenAI-compatible endpoint #232
phineas-pta
started this conversation in
Show and tell
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
A lightweight FastAPI service that wraps Piper in an OpenAI-compatible
/v1/audio/speechendpoint.original code: https://github.com/Kamil-Krawiec/piper-tts-http-server/blob/master/server.py by @Kamil-Krawiec
i simplified the code and add some features:
TensorrtExecutionProvider,CUDAExecutionProvider,MIGraphXExecutionProvider,OpenVINOExecutionProvider,CoreMLExecutionProvider,DmlExecutionProvider,CPUExecutionProviderinstallation
basic dependencies:
for nvidia cuda:
for amd rocm (linux only): grab
onnxruntime-migraphxwheel from https://repo.radeon.com/rocm/manylinux/for intel openvino:
pip uninstall -y onnxruntime pip install openvino==2025.4.1 onnxruntime-openvino # at the time of writing onnxruntime only support openvino up to v2025.4.1for macos: basic dependencies should be good
usage
download file: https://gist.github.com/phineas-pta/7d08a3ac21d64e67ed5fa6b47e93c097#file-pipertts_openai-py
launch the server with:
other applications can now connect to
http://localhost:5000/v1to use Piper TTSexample of my use case: read aloud epub file in browser
--allow-corslimits
streaming
wav-format audio only, cannot save to file nor change audio formatif u want, take a look at: https://github.com/remsky/Kokoro-FastAPI/blob/master/api/src/routers/openai_compatible.py
edit 1 change some links
Beta Was this translation helpful? Give feedback.
All reactions