Skip to main content

YarnGPT Python Wrapper Library

Version 0.2.0

  • Added support for local speakers
  • Added support for multiple languages
  • Added support for multiple languages

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: abayomi, 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="abayomi", 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="abayomi", 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

Metadata

Release files for yarngpt 0.2.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for yarngpt 0.2.0
File Size Uploaded
yarngpt-0.2.0.tar.gz 29.7 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for yarngpt 0.2.0
File Interpreter ABI Platform
yarngpt-0.2.0-py3-none-any.whl Python 3 none any Details

Total release size: 64.6 kB

Release files / yarngpt-0.2.0.tar.gz

Download URL yarngpt-0.2.0.tar.gz
Size 29.7 kB
Tags Source
SHA-256 checksum
How to use checksums
118a52c11eb65d7c8a1715c5bbbdfc80ad4a6484f9e6ca2a8ce132013332871a
BLAKE2b-256 checksum
How to use checksums
ef27118c638902bc7d777e80ae4fc330ff9050f4404f516d93bf3448533154e7
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.12.3

Release files / yarngpt-0.2.0-py3-none-any.whl

Download URL yarngpt-0.2.0-py3-none-any.whl
Size 35.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
c51421233e527a4590262ef8499f67dcea6c9ee5d9b2df46b0f1ee17fa667926
BLAKE2b-256 checksum
How to use checksums
9846e475767d10e66a75aa5406c620a5591cbde271794416b02bebd95bcebfe7
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.12.3

Release history Release notifications | RSS feed

This release

0.2.0 This release

2 release files

0.1.9

2 release files

0.1.8

2 release files

0.1.7

2 release files

0.1.6

2 release files

0.1.5

2 release files

0.1.4

2 release files

0.1.3

2 release files

0.1.2

2 release files

0.1.1

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page