Skip to main content

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 is pip installable:

$ pip 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

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

ospeech-1.1.0.tar.gz (10.3 kB view details)

Uploaded Source

Built Distribution

ospeech-1.1.0-py3-none-any.whl (12.7 kB view details)

Uploaded Python 3

File details

Details for the file ospeech-1.1.0.tar.gz.

File metadata

  • Download URL: ospeech-1.1.0.tar.gz
  • Upload date:
  • Size: 10.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.12.4

File hashes

Hashes for ospeech-1.1.0.tar.gz
Algorithm Hash digest
SHA256 fcbc2706c883dcfb2538319f54aca98029a7c9762d4627d23788cb24edc42405
MD5 c4ed0942b7d4d1d09aa1b431a26567d0
BLAKE2b-256 14af9b8d07b9dd9f724878d7202c2e5133527618107b8f8db1256d52adec00f6

See more details on using hashes here.

File details

Details for the file ospeech-1.1.0-py3-none-any.whl.

File metadata

  • Download URL: ospeech-1.1.0-py3-none-any.whl
  • Upload date:
  • Size: 12.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.12.4

File hashes

Hashes for ospeech-1.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 a933803b41039e4a5f53f55a7c1bba5a4d83ed184c4fbbe29ed034da1d432004
MD5 22ff0e1c7ba142dbb5c2dcd44b05c041
BLAKE2b-256 25f06c5064e9e15c76281ea16bfcf1c45ab6c8df42e08509f197571763569858

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page