Skip to main content

A fully custom, offline Text-to-Speech system for the Twi language

Project description

Kalakan TTS

A fully custom, offline Text-to-Speech system for the Twi language.

Features

  • Specialized for Twi language with proper handling of special characters (ɛ, ɔ, Ɔ, tonal markers)
  • Complete text processing pipeline with Twi-specific tokenization and phoneme mapping
  • High-quality acoustic models:
    • Tacotron2: Attention-based sequence-to-sequence model
    • FastSpeech2: Non-autoregressive model with explicit duration modeling
    • Transformer-TTS: Transformer-based sequence-to-sequence model
  • Multiple vocoders:
    • Griffin-Lim: Simple phase reconstruction algorithm
    • HiFi-GAN: High-fidelity GAN-based vocoder
    • MelGAN: Fast GAN-based vocoder
    • WaveGlow: Flow-based generative model
  • Production-ready API with REST and gRPC interfaces
  • Comprehensive training infrastructure with experiment tracking and data augmentation
  • Advanced dataset preparation with metadata generation, phoneme conversion, and quality control
  • Optimized for both cloud and edge deployment

Installation

Basic Installation

pip install kalakan-tts

Development Installation

git clone https://github.com/kalakan-ai/kalakan-tts.git
cd kalakan-tts
pip install -e ".[dev,api,training]"

Quick Start

Text-to-Speech Synthesis

from kalakan.synthesis.synthesizer import Synthesizer

# Initialize the synthesizer with specific models
synthesizer = Synthesizer(
    acoustic_model="/path/to/acoustic_model.pt",  # or use a model name like "tacotron2", "fastspeech2", "transformer_tts"
    vocoder="/path/to/vocoder.pt",  # or use a model name like "griffin_lim", "hifigan", "melgan", "waveglow"
    device="cuda:0",  # or "cpu"
)

# Generate audio from Twi text
audio = synthesizer.synthesize(
    text="Akwaaba! Wo ho te sɛn?",
    normalize=True,
    clean=True,
    speed=1.0,  # Control speech speed (for FastSpeech2)
    pitch=1.0,  # Control pitch (for FastSpeech2)
    energy=1.0,  # Control energy/volume (for FastSpeech2)
)

# Save the audio to a file
synthesizer.save_audio(audio, "output.wav")

Command Line Interface

# Using the demo script
python demo.py --text "Akwaaba! Wo ho te sɛn?" --output output.wav --acoustic_model /path/to/acoustic_model.pt --vocoder /path/to/vocoder.pt

# Start the REST API server
python -m kalakan.api.server --host 0.0.0.0 --port 8000 --acoustic_model /path/to/acoustic_model.pt --vocoder /path/to/vocoder.pt

# Start the gRPC API server
python -m kalakan.api.grpc_api --host 0.0.0.0 --port 50051 --acoustic_model /path/to/acoustic_model.pt --vocoder /path/to/vocoder.pt

API Clients

# REST API client
python rest_client.py --text "Akwaaba! Wo ho te sɛn?" --output output.wav --host localhost --port 8000

# gRPC API client
python grpc_client.py --text "Akwaaba! Wo ho te sɛn?" --output output.wav --host localhost --port 50051

Dataset Preparation

Kalakan TTS includes a comprehensive metadata generation tool for preparing TTS datasets:

Basic Metadata Generation

# Generate basic metadata for a dataset
kalakan gen-metadata --input-dir /path/to/dataset --verbose

Advanced Features

# Generate metadata with phonemes, dataset splitting, and quality control
kalakan gen-metadata \
    --input-dir /path/to/dataset \
    --generate-phonemes \
    --split-dataset \
    --val-ratio 0.2 \
    --test-ratio 0.1 \
    --output-format both \
    --include-stats \
    --check-duplicates \
    --remove-duplicates \
    --normalize-text \
    --clean-text \
    --speaker-id "speaker_001" \
    --verbose

Key Features

  • Phoneme Generation: Automatic G2P conversion for Twi text
  • Text Normalization: Cleaning and standardization of text content
  • Dataset Splitting: Automatic train/validation/test splits
  • Quality Control: Duration filtering, duplicate detection, and validation
  • Multiple Formats: CSV and JSON output support
  • Comprehensive Statistics: Detailed dataset analytics

For detailed documentation, see docs/metadata_generation_guide.md.

Text Normalization

Kalakan TTS includes a powerful text normalization tool for preparing Twi text:

Basic Text Normalization

# Normalize Twi text directly
kalakan norm --text "Dr. Kwame na Prof. Ama bɛba ha 25 mu."

File Processing

# Normalize text from files with various options
kalakan norm \
    --file input.txt \
    --output normalized.txt \
    --format json \
    --show-diff \
    --verbose

Key Features

  • Abbreviation Expansion: "Dr." → "doctor", "Prof." → "professor"
  • Number Conversion: "25" → text representation
  • Special Character Normalization: Proper handling of Twi characters (ɛ, ɔ)
  • Multiple Output Formats: Text, JSON, CSV
  • Batch Processing: Process multiple files at once
  • Interactive File Selection: GUI file picker
  • Difference Visualization: See what changed during normalization

Documentation

For detailed documentation, visit docs/.

License

Apache License 2.0

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

kalakan_tts-1.0.0.tar.gz (192.6 kB view details)

Uploaded Source

Built Distribution

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

kalakan_tts-1.0.0-py3-none-any.whl (125.0 kB view details)

Uploaded Python 3

File details

Details for the file kalakan_tts-1.0.0.tar.gz.

File metadata

  • Download URL: kalakan_tts-1.0.0.tar.gz
  • Upload date:
  • Size: 192.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.11.0

File hashes

Hashes for kalakan_tts-1.0.0.tar.gz
Algorithm Hash digest
SHA256 24d921eb0aa8e360d0a7ab792a8b7226dc30ff8fbd4056ef156a064281327e8d
MD5 be5bf932a86d2cf118f155757b38337d
BLAKE2b-256 13e0b22f9d58da2974adea9540455f7dc28e2bcbc39cdc8233cc3df64902e26d

See more details on using hashes here.

File details

Details for the file kalakan_tts-1.0.0-py3-none-any.whl.

File metadata

  • Download URL: kalakan_tts-1.0.0-py3-none-any.whl
  • Upload date:
  • Size: 125.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.11.0

File hashes

Hashes for kalakan_tts-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 5cbc4fdc7af0685f6ee414222535b92d0ec3e1d16e0aefa2cbbbd185bd2d9eb5
MD5 c34aaa8537ead91a06d4aad95a76f161
BLAKE2b-256 8f328ccd0889361e2df384228796c4b36e1f2f08e1ae54f8d9f1dd51a0391abd

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