Skip to main content

A Python wrapper for YarnGPT text-to-speech model with multi-language support

Project description

YarnGPT Python Wrapper Library

Description

YarnGPT is a Python wrapper for the YarnGPT text-to-speech model, designed to synthesize natural Nigerian speech in multiple languages 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, languages, and adjust generation parameters.

Features

  • Supports multiple Nigerian languages: English, Yoruba, Igbo, and Hausa
  • Rich set of voices for each language:
    • English: idera, chinenye, jude, emma, umar, joke, zainab, osagie, remi, tayo
    • Yoruba: adebayo, aisha, folake
    • Igbo: chioma, obinna, adanna
    • Hausa: amina, fatima, ibrahim, yusuf
  • Utilizes Hugging Face's model caching for efficient model loading
  • Exposes a straightforward API function: generate_speech(text, speaker, language, temperature, repetition_penalty, max_length)
  • Allows customization of generation parameters
  • 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:

    pip install yarngpt
    

Usage

Basic usage to generate and save audio:

from yarngpt import generate_speech
import torchaudio

# Generate English speech with default speaker
audio = generate_speech("Hello, this is a test.", language="english")

# Generate Yoruba speech with a Yoruba voice
audio = generate_speech("Bawo ni?", speaker="adebayo", language="yoruba")

# Save the generated audio
torchaudio.save("output.wav", audio, sample_rate=24000)

For Jupyter Notebook users, you can also play the audio directly:

from yarngpt import generate_speech
import torchaudio
from IPython.display import Audio

# Generate speech in different languages
english_audio = generate_speech("Hello!", speaker="idera", language="english")
yoruba_audio = generate_speech("Bawo ni?", speaker="adebayo", language="yoruba")
igbo_audio = generate_speech("Kedu?", speaker="chioma", language="igbo")
hausa_audio = generate_speech("Sannu!", speaker="amina", language="hausa")

# Save and play the audio
torchaudio.save("output.wav", english_audio, sample_rate=24000)
Audio("output.wav")

Parameter Options

  • text: The input string to convert to speech
  • speaker: Choose from available voices by language (see Features section for full list)
  • language: The language for speech generation ("english", "yoruba", "igbo", "hausa")
  • temperature: Controls the randomness of generation (default is 0.1)
  • 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

License

This project is licensed under the MIT License.

Acknowledgments

  • Built as a contribution to yarngpt 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.6.tar.gz (22.6 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.6-py3-none-any.whl (24.0 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: yarngpt-0.1.6.tar.gz
  • Upload date:
  • Size: 22.6 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.6.tar.gz
Algorithm Hash digest
SHA256 198aed4f0c2179e5c4911b18daf4a55574a31ea7b5899fa4eae819e2c6f678f8
MD5 608aebbcb1c595c9e84dc981818e26d4
BLAKE2b-256 f99d73bb0b8abe3779a4f1faa8cd2f3ab3e1463ef0c879418ba3cf20d9c749cb

See more details on using hashes here.

File details

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

File metadata

  • Download URL: yarngpt-0.1.6-py3-none-any.whl
  • Upload date:
  • Size: 24.0 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.6-py3-none-any.whl
Algorithm Hash digest
SHA256 02a59b4a4fc08e67ea2003256ba470d03a9682394bce25c63d97b59815199453
MD5 c46216ce9e995cf519ff2997447712be
BLAKE2b-256 9471100d9020ebbfa9034056fb792caa7bdf5e885b2d81dcacba962e182692c3

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