chrisjp / tts

A simple tool to demo text-to-speech using various services' voices. HTML5 and Vanilla JS.
https://lazypy.ro/tts
MIT License
67 stars 16 forks source link
streamelements streamlabs text-to-speech texttospeech tts twitch twitchtv

Text-to-Speech (TTS) Demo App

A simple web app demonstrating how text sounds in different TTS voices.

Convert your text to speech using voices provided by a variety of TTS services, the full list including their limitations can be found further down this readme.

About

This project originally came about from a desire to emulate how messages will sound when donating to Twitch.tv streamers, many of whom use Streamlabs/StreamElements TTS features to have donations read aloud (often by 'Brian') during their streams. FeelsGoodMan

It was inspired by Peter Cunha's similar tool. I wanted to build it using only vanilla JS, as well as improve it with UI/UX enhancements and by providing a massive selection of voices, including all those offered by Amazon Polly and other services. The project has grown somewhat bigger than the single file demo it was initially, and is now effectively a full PHP library and demo website.

Features

Using

The basic requirements are some kind of web server with PHP >= 8.0 installed and a working copy of composer. A Docker compose file is included to handle all this for you.

docker compose up

If not using Docker I'll assume you've already got this repo on a server; you'll need to run

composer install

in the directory to generate the autoloader classes.

Please check the generated config.php file and adjust any values as you see fit. Take note of the step to acquire a valid TikTok session ID value if you intend to use those voices, as these will not generate any audio without one. Lastly, ensure the AUDIO_DIR exists and is writable, especially if you have changed it from the default value. Composer will have attempted to create the default directory for you, and the script itself will always try to create your configured directory if it does not exist. But depending on how your PHP is set up this may not be possible.

Usage notes

Many of the services used aren't intended for professional/commercial use or are utilising a live demo, and as such they have limitations. As a reminder: You should only be using this to test how your text sounds in various voices. If you need to use TTS for commercial purposes please check out the services' respective websites linked below for more information.

Regarding URL validity, it is recommended you enable local saving in config.php if you'll be requiring access to the audio again in the near future. The same advice goes for services that return the audio as a data URI, as this can be inconvenient for sharing when message length is a concern.

TTS Services/APIs included (and their limitations)

Amazon Polly (via StreamElements or Streamlabs APIs)

Demo website

Head over to LazyPy.ro/tts for a live demo of all the available voices.