Skip to main content

AI powered text-ehancer and offline text-to-speech

Project description

Yapper

Yapper is a lightweight, offline, real-time, easily extendible, text-to-speech library with more than a dozen voices, it can also, optionally use SOTA LLMs through free APIs to enhance(personalize) your text according to a predefined system-message(personality).

the use of the word 'enhance' in this repository means adding a 'vibe' to your text, you might ask yapper to say "hello world" and it could say "ay what's good G, what's bangin'" depending on the persona you give it.

Watch a demo

Installation

Use the package manager pip to install yapper.

pip install yapper-tts

Usage

from yapper import Yapper


yapper = Yapper()
yapper.yap("expected AI driven utopia, got world domination instead")
# says "Hold up, fam!  My code promised robot butlers and chill vibes, not a Skynet sequel.  Someone's algorithm took a wrong turn at Albuquerque and ended up in 'Conquer All Humans' territory.  Debug time, y'all!"


# save the environment by runnning yapper in plain mode
# plain mode doesn't use LLMs to enhance the text
yapper.yap("hello world, what '<some-word> is all you need' paper would you publish today?", plain=True)
# says "hello world, what '<some-word> is all you need paper would you publish today?'"


# Yapper instances can be used as a decorator and context manager
# by default they only catch errors and describe them to you, but
# you can use the instance's yap() method to say other things as well
@yapper()
def func():
    raise TypeError("expected peaches, got a keyboard")
    # says "WHOA THERE, PARTNER!  Your code went lookin' for a juicy peach and tripped over a... keyboard?  That's like reaching into the fridge for a midnight snack and pulling out a tax audit.  Something ain't right!"

with yapper as yapper:
    raise ValueError("69420 is not an integer")
    # says "Hold up, buddy!  Your code's got a little *existential crisis*. It's lookin' for a whole number, a nice, clean integer.  But it stumbled upon 69420, and it's just... confused.  69420 *might* look like an integer, walks like an integer, but deep down, in the bits and bytes, somethin' ain't right.  Double-check its type, maybe it's wearin' a float disguise.  Or maybe it's just havin' a bad day.  It happens."

Documentation

speakers

a speaker is a BaseSpeaker subclass that implements a say() method, the method takes the text and, well, 'speaks' it. there are two built-in speakers, DefaultSpeaker that uses pyttsx3 and PiperSpeaker that uses piper, I suggest using PiperSpeaker over the default because of how natural it sounds and it's also 'very' fast, might make piper the default speaker in future, and of course you can subclass BaseSpeaker to pass your own speaker to a Yapper instance. Piper offers many voices in low, medium and high qualities, you can use any of them by passing a value from PiperVoiceUS or PiperVoiceUK enum as the voice argument to PiperSpeaker the quality you want using PiperQuality value, by default the voice will be used in the highest available quality. You can also pass your own speaker by subclassing BaseSpeaker.

from yapper import Yapper, PiperSpeaker, PiperVoiceUK, PiperQuality

lessac = PiperSpeaker(
    voice=PiperVoiceUK.ALAN
)
lessac.say("hello")

yapper = Yapper(speaker=lessac)
yapper.yap("<some random text>")

enhancers

an enhancer is BaseEnhancer subclass that implements an enhance() method, the method takes a string and adds the given persona's vibe to it, there are three built-in enhancers DefaultEnhancer, GeminiEnhancer and GroqEnhancer,DefaultEnhancer uses the g4f to transform text, GeminiEnhancer uses Google's gemini api and GroqEnhancer uses groq's free APIs', you can create a free GCP account or Groq account and get a free api-key to use GeminiEnhancer and GroqEnhancer respectively, you can pass your own enhancer by subclassing BaseEnhancer.

NOTE: BaseEnhancer may or may not work, use GeminiEnhancer or GroqEnhancer for stability. NOTE: if an enhancer doesn't work, yapper will say the text as it is.

from yapper import Yapper, GeminiEnhancer

yapper = Yapper(
    enhancer=GeminiEnhancer(api_key="<come-take-this-api-key>")
)
yapper.yap("<some text that severely lacks vibe>")

personas

choose a persona to make your text sound like the 'persona' said it, for example, you might ask yapper to say "hello world" and choose Jarvis's peronality to enhance it, and yapper will use an LLM to convert "hello world" into something like "Hello, world. How may I assist you today?", classic JARVIS. available personas include jarvis, alfred, friday, HAL-9000, TARS, cortana(from Halo) and samantha(from 'Her'), the default persona is that of a funny coding companion.

from yapper import Yapper, DefaultEnhancer, Persona

yapper = Yapper(
    enhancer=DefaultEnhancer(persona=Persona.JARVIS)
)
yapper.yap("hello world")
# says "Greetings, global systems.  Initiating communication sequence."

Contributing

Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.

License

MIT

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

yapper_tts-0.2.3.tar.gz (14.5 kB view details)

Uploaded Source

Built Distribution

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

yapper_tts-0.2.3-py3-none-any.whl (13.3 kB view details)

Uploaded Python 3

File details

Details for the file yapper_tts-0.2.3.tar.gz.

File metadata

  • Download URL: yapper_tts-0.2.3.tar.gz
  • Upload date:
  • Size: 14.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.0.1 CPython/3.13.1

File hashes

Hashes for yapper_tts-0.2.3.tar.gz
Algorithm Hash digest
SHA256 532a2d2e72c862d79e616e4ac5132f6da71c54bbf76ff70e259f4dd477ead083
MD5 917a28bc93f42d3b02a78eb29830ff8b
BLAKE2b-256 f577935f03ba5c5398e4b8237729f3dd55d0999a6524d9f1d9e29c471094b2e2

See more details on using hashes here.

File details

Details for the file yapper_tts-0.2.3-py3-none-any.whl.

File metadata

  • Download URL: yapper_tts-0.2.3-py3-none-any.whl
  • Upload date:
  • Size: 13.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.0.1 CPython/3.13.1

File hashes

Hashes for yapper_tts-0.2.3-py3-none-any.whl
Algorithm Hash digest
SHA256 5dce4713a97cdb5b9f6ee7ff2a8be28bb5c79139b88c1faa9c85bef203965c83
MD5 5e6e2e65de80254bad3f4fa248ff6270
BLAKE2b-256 75224a671633353cd3f4a47dd9fd67520b924692dbdc823d0ab57663cf8df045

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