Skip to main content

A Python wrapper for YarnGPT text-to-speech model

Project description

YarnGPT Python Wrapper Library

Description

YarnGPT is a Python wrapper for the YarnGPT text-to-speech model, designed to synthesize natural Nigerian-accented English speech using a pure language modeling approach. This library provides a simple API to convert text into audio output, allowing users to select from various preset voices and adjust generation parameters.

Features

  • Supports 12 preset voices (e.g., idera, jude, regina, chinenye, joke, remi, tayo, umar, osagie, onye, emma, and zainab).
  • Utilizes Hugging Face's model caching for efficient model loading.
  • Exposes a straightforward API function: generate_speech(text, speaker, temperature, repetition_penalty, max_length).
  • Allows customization of generation parameters such as temperature, repetition penalty, and maximum token length.
  • Includes unit tests to ensure core functionality.

Installation

  1. Create and activate a virtual environment:

    • On Linux/MacOS:
    python3 -m venv env
    source env/bin/activate
    
    • On Windows:
    python -m venv env
    env\Scripts\activate
    
  2. Install the package in editable mode (for development):

    pip install -e .
    
  3. Alternatively, build and install the distribution:

    python -m build
    pip install dist/yarngpt-0.1.0-py3-none-any.whl
    

Usage

Import the generate_speech function and use it to generate audio:

from yarngpt.core import generate_speech

# Generate speech with the default speaker and settings
audio = generate_speech("Hello, this is a test.", speaker="idera")

# To save the generated audio to a file (requires torchaudio)
import torchaudio
torchaudio.save("output.wav", audio, sample_rate=24000)

Parameter Options

  • text: The input string to convert to speech.
  • speaker: Choose one from the available speakers (e.g., idera, jude, regina, chinenye, joke, remi, tayo, umar, osagie, onye, emma, zainab).
  • temperature: Controls the randomness of generation (default is 0.1). For sampling-based generation, set do_sample=True if needed.
  • repetition_penalty: A factor to reduce repetitive output (default is 1.1).
  • max_length: The maximum length of the generated output tokens (default is 4000).

Testing

Run the unit tests to verify functionality:

python -m unittest discover -s tests

Contributing

Contributions are welcome! To contribute:

  1. Fork the repository on GitHub.
  2. Create a new branch for your changes (e.g., python-wrapper).
  3. Commit your changes with clear messages.
  4. Open a pull request with a detailed description of your changes.

Once merged, your contributions will be credited in the project's contributors list.

License

This project is licensed under the MIT License.

Acknowledgments

  • Built with inspiration from YarnGPT and similar TTS projects.
  • Utilizes Hugging Face's model caching and the transformers library.
  • Special thanks to the open-source community for their ongoing support.

For more details and documentation, visit the GitHub repository: https://github.com/jerryola1

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

yarngpt-0.1.0.tar.gz (8.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

yarngpt-0.1.0-py3-none-any.whl (6.6 kB view details)

Uploaded Python 3

File details

Details for the file yarngpt-0.1.0.tar.gz.

File metadata

  • Download URL: yarngpt-0.1.0.tar.gz
  • Upload date:
  • Size: 8.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.0.0 CPython/3.12.3

File hashes

Hashes for yarngpt-0.1.0.tar.gz
Algorithm Hash digest
SHA256 397d741dca5a6b1f9a60ebebd704d13fc6f8aca51b32a23ab835ff67720ed58b
MD5 645da65db27b55fa3925b72b71c6ed0c
BLAKE2b-256 b0013d1a5e3f52625a66e0e19ef7b1205c81afb0c2e570655f701639f6068186

See more details on using hashes here.

File details

Details for the file yarngpt-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: yarngpt-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 6.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.0.0 CPython/3.12.3

File hashes

Hashes for yarngpt-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 c2f48a5962fb3991c4e5d1cacfd2be084d61f7e784655aaf31cb2c963118db57
MD5 19a174375d1a01d0eceba197ee45d4b0
BLAKE2b-256 07c93ebf3ad0ccd62ee6cf319a2f8d195e1fa2b3130d975f9fabb80f0e4a2afd

See more details on using hashes here.

Supported by

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