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.2.0.tar.gz (10.3 kB view details)

Uploaded Source

Built Distribution

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

Uploaded Python 3

File details

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

File metadata

  • Download URL: ospeech-1.2.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.2.0.tar.gz
Algorithm Hash digest
SHA256 b3a850155ad76bf4bbdbd12a0168eabd1c49685667f1854998bb0d5ba049a421
MD5 7852fabc10acf333dc4e3dc587b05ac5
BLAKE2b-256 042bd2cae000ec786d44d0e8981ae3f7d55983df979fe89d3538a57db6c66e8f

See more details on using hashes here.

File details

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

File metadata

  • Download URL: ospeech-1.2.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.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 0d2b7341295d003125899f0bef55a1a95ca4510379c5fb74c88205fad51056b7
MD5 7ca2a7d51a3dcb5aec93b2465e00e54e
BLAKE2b-256 457178a1db95abb6cbbae9ba66478036e4cbfebf136f637f2c9945dcd2970799

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