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
-
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
-
Install the package in editable mode (for development):
pip install -e .
-
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:
- Fork the repository on GitHub.
- Create a new branch for your changes (e.g., python-wrapper).
- Commit your changes with clear messages.
- 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
Release history Release notifications | RSS feed
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
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file yarngpt-0.1.3.tar.gz.
File metadata
- Download URL: yarngpt-0.1.3.tar.gz
- Upload date:
- Size: 21.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.0.0 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b3ac44f9ce0858afcf26b2bf73a6c152f32cea19f122af44de7f987258e7809b
|
|
| MD5 |
adf28852d358f1a5dd34b4ee355fd5ea
|
|
| BLAKE2b-256 |
7213881f0ee2001cfe606ae0a4ac06806c3ca273fea971cd879bfac4830ca46a
|
File details
Details for the file yarngpt-0.1.3-py3-none-any.whl.
File metadata
- Download URL: yarngpt-0.1.3-py3-none-any.whl
- Upload date:
- Size: 22.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.0.0 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b8a9e94a718e498f8670a33f667ce0ec4cc3853efc382f86fc384c38ea8f10da
|
|
| MD5 |
0052acad94e81974804a69e61966ea9a
|
|
| BLAKE2b-256 |
a19b69b59cec7f78722948e4e87e3228f1ca5c3d2bb21ecd3b314ef8a06309ea
|