Skip to main content

A package to make kokoro simpler to work with

Project description

SimplerKokoro

SimplerKokoro

Effortless speech synthesis with Kokoro, in Python.
PyPI - Python Version PyPI - Version GitHub last commit PyPI Downloads PyPI - License

View on PyPI

📚 Table of Contents


✨ Features

  • Simple interface for generating speech audio and subtitles
  • Supports all Kokoro voices
  • Outputs valid SRT subtitles
  • Automatic Model Management

📦 Requirements

  • Python 3.10+
  • torch
  • kokoro
  • soundfile

All dependencies except Python are installed automatically.


🚀 Installation

From PyPI:

pip install Simpler-Kokoro

Or clone the repo and install locally:

git clone https://github.com/WilleIshere/SimplerKokoro.git
cd SimplerKokoro
pip install .

🧑‍💻 Examples

You can find runnable example scripts in the examples/ folder:


🛠️ Usage

Basic Example
from Simpler_Kokoro import SimplerKokoro

# Create an instance
sk = SimplerKokoro()

# List available voices
voices = sk.list_voices()
print("Available voices:", [v['name'] for v in voices])

# Generate speech
sk.generate(
    text="Hello, this is a test of the Simpler Kokoro voice synthesis.",
    voice=voices[0]['name'], # Make sure to specify the name of the voice
    output_path="output.wav"
)
Generate Speech with Subtitles
sk = SimplerKokoro()

sk.generate(
    text="Hello, this is a test. This is another sentence.",
    voice=voices[0]['name'],
    output_path="output.wav",
    write_subtitles=True,
    subtitles_path="output.srt",
    subtititles_word_level=True
)
Generate Speech with Custom Speed
sk = SimplerKokoro()

sk.generate(
    text="This is spoken faster than normal.",
    voice=voices[1]['name'],
    output_path="fast_output.wav",
    speed=1.5
)
Specify a Path to Download Models
sk = SimplerKokoro(models_dir="Folder-to-put-models-in") # Put the models dir here

sk.generate(
    text="Thats a cool model directory.",
    voice=voices[1]['name'],
    output_path="fast_output.wav",
)

🖥️ Command Line Interface (CLI)

You can use the library in the command line too.

Example:

python -m Simpler_Kokoro <command> [options]

Commands and Options

Command Description Options
list-voices List available Kokoro voices --repo, --models_dir, --log_level
generate Generate speech audio from text --text (required), --voice (required), --output (required), --speed, --write_subtitles, --subtitles_path, --subtitles_word_level, --repo, --models_dir, --log_level

Global options:

Option Description Default
--repo HuggingFace repo to use for models hexgrad/Kokoro-82M
--models_dir Directory to store model files models
--log_level Logging level (DEBUG, INFO, WARNING, ERROR, CRITICAL) INFO

Generate command options:

Option Description Default
--text Text to synthesize (required)
--voice Voice name to use (required)
--output Output WAV file path (required)
--speed Speech speed multiplier 1.0
--write_subtitles Write SRT subtitles False
--subtitles_path Path to save subtitles subtitles.srt
--subtitles_word_level Word-level subtitles False

📂 Example Output Files

  • output.wav: The synthesized speech audio file.
  • output.srt: Subtitles in SRT format (if write_subtitles=True).
Sample SRT output
1
00:00:00,000 --> 00:00:01,200
Hello,

2
00:00:01,200 --> 00:00:02,500
this is a test.

3
00:00:02,500 --> 00:00:04,000
This is another sentence.

🏗️ Build from Source

To build the package from source:

git clone https://github.com/WilleIshere/SimplerKokoro.git
cd SimplerKokoro
pip install build
python -m build

This will create distribution files in the dist/ directory:

  • .whl (wheel) file for pip installation
  • .tar.gz source archive

To install the built wheel locally:

pip install dist/Simpler_Kokoro-*.whl

You can now use the package as described in the usage section.


📖 API

SimplerKokoro

Methods

  • list_voices(): Returns a list of available voices with metadata.
  • generate(text, voice, output_path, speed=1.0, write_subtitles=False, subtitles_path='subtitles.srt', subtititles_word_level=False): Generates speech audio and optional subtitles.

📄 License

This project is licensed under the GPL-3.0 license.


⭐ Star History

Star History Chart

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

simpler_kokoro-1.2.1.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.

simpler_kokoro-1.2.1-py3-none-any.whl (20.8 kB view details)

Uploaded Python 3

File details

Details for the file simpler_kokoro-1.2.1.tar.gz.

File metadata

  • Download URL: simpler_kokoro-1.2.1.tar.gz
  • Upload date:
  • Size: 22.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.5

File hashes

Hashes for simpler_kokoro-1.2.1.tar.gz
Algorithm Hash digest
SHA256 a6772b6df1c75a4a8d039006a6e9fc6116c8a352eb16fe1c573860038fc98d39
MD5 51594db4b21342deddf3b67e65dc5d43
BLAKE2b-256 4fe4d2cd55f35b621cfff199b935245c0851e87a4a62d13490840448bf3adc73

See more details on using hashes here.

File details

Details for the file simpler_kokoro-1.2.1-py3-none-any.whl.

File metadata

  • Download URL: simpler_kokoro-1.2.1-py3-none-any.whl
  • Upload date:
  • Size: 20.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.5

File hashes

Hashes for simpler_kokoro-1.2.1-py3-none-any.whl
Algorithm Hash digest
SHA256 31ff12a6e67e970ad2b5ec0193a959df0f55b1adb4639ccf1ad29a6cf2ec4b3a
MD5 197e649073adf280a53a0583de70526b
BLAKE2b-256 c371a8e3e8b2c113d2ffff1d5ebca29e1a7911afa5d666d508efb5524e3a093e

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