Skip to main content

A wrapper class to get started using Text To Speech quickly

Project description

Usage: noahs_tts

Getting Started

First, install the library:

pip install noahs_tts

Quick start

from noahs_tts import TTS  # if you saved the class in tts.py

tts = TTS()
tts.say("Hello world!")  # blocks until finished

Speak sentence-by-sentence (default) for snappier responsiveness:

tts.say("First sentence. Second sentence! Third sentence?")

Speak the whole string as one chunk:

tts.say("This will be spoken as a single utterance.", split_sentences=False)

Speak the contents of a stream generator:

def example_generator():
    for s in ["hello there", "this is a stream", "last chunk here"]:
        yield s

tts.say_stream(example_generator())

Voice management

List available voices (id, name, locale, gender when available):

voices = tts.voices()
for v in voices:
    print(v["id"], v["name"], v["locale"], v["gender"])

Pick a voice by name or id (partial match allowed):

tts = TTS(voice="Zira")          # Windows example
tts = TTS(voice="Samantha")      # macOS example
tts = TTS(voice="english-us")    # Linux/eSpeak example

Control rate

Rate is engine-specific “words per minute” style. This wrapper casts to int.

tts = TTS(rate=180)      # set default on init
tts.say("Speaking at 180 wpm (approx).")

tts.say("Speed this one up.", split_sentences=False)

You can also override per-call when saving/synthesizing:

data = tts.synth("Faster line.", rate=220)

Save audio

Get WAV bytes:

wav_bytes = tts.synth("Save me to a file later.")
with open("out.wav", "wb") as f:
    f.write(wav_bytes)

Or save directly:

tts.save("Write this straight to disk.", "speech.wav", voice="Samantha", rate=170)

Check out Source Code

https://github.com/jonesnoah45010/noahs_tts

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

noahs_tts-0.1.2.tar.gz (4.5 kB view details)

Uploaded Source

Built Distribution

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

noahs_tts-0.1.2-py3-none-any.whl (4.8 kB view details)

Uploaded Python 3

File details

Details for the file noahs_tts-0.1.2.tar.gz.

File metadata

  • Download URL: noahs_tts-0.1.2.tar.gz
  • Upload date:
  • Size: 4.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.4

File hashes

Hashes for noahs_tts-0.1.2.tar.gz
Algorithm Hash digest
SHA256 8f1cb7a4429799c868b9004fc143f733152b97909396383cf9b51f88f91a4643
MD5 1b6e5f941a18d4c03c8f3a453d064a72
BLAKE2b-256 987eb51aa21d0478a97676f1e03afe7bd644180309d41ea904d163311c3758c1

See more details on using hashes here.

File details

Details for the file noahs_tts-0.1.2-py3-none-any.whl.

File metadata

  • Download URL: noahs_tts-0.1.2-py3-none-any.whl
  • Upload date:
  • Size: 4.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.4

File hashes

Hashes for noahs_tts-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 ae372a0d0534dc791749963dd2078f43692640ce48e0784db004174f92630d49
MD5 30ad4e30548f76c1749a4c7dd796e556
BLAKE2b-256 b8eb3fef9f49ae5a6d213049275b32a5b1f3f079c8ada36c0c961393ae76322f

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