Minimum dependency inference library for OptiSpeech TTS models
Project description
ospeech
Minimum dependency inference library for OptiSpeech TTS model.
About OptiSpeech
OptiSpeech is ment to be an efficient, lightweight and fast text-to-speech model for on-device text-to-speech.
Install
This package can be installed using pip
:
$ pip install ospeech
If you want to run the ospeech
command from anywhere, try:
$ pipx install ospeech
Most models are trained with IPA phonemized text. To use these models, install ospeech
with the espeak
feature, which pulls-in piper-phonemize:
pip install ospeech[espeak]
If you want a gradio interface, install with the gradio
feature:
pip install ospeech[gradio]
Usage
Obtaining models
$ ospeech-models --help
usage: ospeech-models [-h] {ls,dl} ...
List and download ospeech models from HuggingFace.
positional arguments:
{ls,dl}
ls List available models
dl Download ospeech models from HuggingFace
options:
-h, --help show this help message and exit
To list available models:
$ ospeech-models ls
Lang | Speaker | ID
---------------------------------------------------------------------
en-us | lightspeech-hfc-female | en-us-lightspeech-hfc-female
en-us | convnext-tts-hfc-female | en-us-convnext-tts-hfc-female
---------------------------------------------------------------------
Using the model ID, use the following command to download a model:
$ ospeech-models dl en-us-lightspeech-hfc-female .
Downloading `en-us-lightspeech-hfc-female.onnx`
Downloading: 100%| | 38/38 [00:02<?, ?MB/s]
Command line usage
$ ospeech --help
usage: ospeech [-h] [--d-factor D_FACTOR] [--p-factor P_FACTOR] [--e-factor E_FACTOR] [--no-split] [--cuda]
onnx_path text output_dir
ONNX inference of OptiSpeech
positional arguments:
onnx_path Path to the exported OptiSpeech ONNX model
text Text to speak
output_dir Directory to write generated audio to.
options:
-h, --help show this help message and exit
--d-factor D_FACTOR Scale to control speech rate.
--p-factor P_FACTOR Scale to control pitch.
--e-factor E_FACTOR Scale to control energy.
--no-split Don't split input text into sentences.
--cuda Use GPU for inference
If you want to run with the gradio interface:
$ ospeech-gradio --help
usage: ospeech-gradio [-h] [-s] [--host HOST] [--port PORT] [--char-limit CHAR_LIMIT] onnx_file_path
positional arguments:
onnx_file_path Path to model ONNX file
options:
-h, --help show this help message and exit
-s, --share Generate gradio share link
--host HOST Host to serve the app on.
--port PORT Port to serve the app on.
--char-limit CHAR_LIMIT
Input text character limit.
Python API
import soundfile as sf
from ospeech import OptiSpeechONNXModel
model_path = "./optispeech-en-us-lightspeech.onnx"
sentence = "OptiSpeech is awesome!"
model = OptiSpeechONNXModel.from_onnx_file_path(model_path)
model_inputs= onx.prepare_input(sentence)
outputs = onx.synthesise(model_inputs)
for (idx, wav) in enumerate(outputs):
# Wav is a float array
sf.write(f"output-{idx}.wav", wav, model.sample_rate)
Licence
Copyright (c) Musharraf Omer. MIT Licence. See LICENSE for more details.
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file ospeech-1.3.0.tar.gz
.
File metadata
- Download URL: ospeech-1.3.0.tar.gz
- Upload date:
- Size: 12.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.12.4
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1294b91210a85bcccdedcef9a9961854a1209d65823a9dbba3d5a5a605393884 |
|
MD5 | c4ffd450f3f7e3be2789b71feec3ceba |
|
BLAKE2b-256 | b25ace1460d6fd3a2020c7d38ab0e91796e5d8af16ae4011ec1913a3bbba32ba |
File details
Details for the file ospeech-1.3.0-py3-none-any.whl
.
File metadata
- Download URL: ospeech-1.3.0-py3-none-any.whl
- Upload date:
- Size: 14.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.12.4
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | ed46ac1b8e257c302f4fae20ec7ba3deab8eea9f27b571f6a3fbc661e795ef0a |
|
MD5 | a02d7dae6af4f62b4b471080419d4305 |
|
BLAKE2b-256 | 952e638195c3222cef34a57c745e703179bd8b3e8b7e9a18a146803629899ba4 |