Skip to content

A TTS reading out chat loud with multiple settings.

License

Notifications You must be signed in to change notification settings

takoz53/TwitchTTS

Repository files navigation

TwitchTTS with Channel Awards

A TTS client for Twitch chat, integrated with GCP Text-to-speech (500 voices from 40+ languages).

Updated on 13.10.2021

Download at Releases

How to set up as developer?

You'll (maybe?) need to add System.Speech available on your System as Reference

You'll also need TwitchLib and Google.Cloud.TextToSpeech.V1 available on NuGet and you're good to go.

How to set up as user? (Windows Only!)

  1. Download the latest release and extract
  2. Run the Program and you'll have to fill out multiple things
    1. Firstly, whether you want to bind it on a specific Channel Award. If yes, type Y, else N.
      1. If Y, type the Channel Award its Title, e.g. "TTS" without the "".
    2. If you want the TTS to read out usernames (e.g. X said ...), hit Y, else N.
    3. Enter your botname / username
    4. Create an OAuth Key and enter your Key (oauth:xxxxxx..)
    5. Set the channel, where it should connect to (all lowercase!)
    6. Create an Access Token with Custom Scope Token. Tick following:
      1. channel:read:redemptions
    7. Hit GENERATE TOKEN.
    8. Insert your Access Token.
    9. Get your Channel ID. This value is numbers only.
      1. The website went down, so you need to find a way to get your ChannelID. For me, this chrome add-on works just fine.
    10. Insert your Twitch/Channel ID.
  3. Everything should be working now.
  4. Don't forget to set up a bad words filter or you might get banned if somebody wants to be funny.
  5. I don't take responsibility for whatever happens in your stream.

How to set up with GCP Text-To-Speech

In order for the bot to be able to access the google API, a valid service account key with access to the text-to-speech API must be available in the gcp.json file in the config folder.

  1. Register for a free account at https://cloud.google.com/free (1 million wavenet characters per month are free, and 4 million free standard characters) Try out the TTS here: https://cloud.google.com/text-to-speech

I'd recommend setting up a budget of $0 just in case.

Create credentials

  1. Search for Text To Speech in your Console.
  2. Enable the API.
  3. Go to Manage and on the menu left, choose Credientials.
  4. Create new Credientials for a Service Account.
  5. Enter service account name (anything is just fine), select role project-> owner on step 2. Skip step 3
  6. Click on the newly created Account and navigate to Keys.
  7. Add a Key (Create New) and select JSON.
  8. Save the file as gcp.json and put it in your Config folder.
  9. Enable GCP in options.txt and start the program once to create voicelist.txt.
  10. Ur good to go.

Activate the text-to-speech API

  1. In the menu on the left: APIs & Services -> Select Dashboard
  2. Activate the Cloud Text-to-Speech API with the button '+ APIS and services'

What's next?

  1. Keep the program running while streaming and everyone will be able to hear the chat.
  2. Use badwords.txt to create your own wordfilter, tip: There are many out in the internet, so maybe you want to download some!
  3. Use blocklist.txt to block users (or bots) from TTS
    1. Example: Nightbot answers to uptime? Block him or time will be read out always
    2. Someone is being a bitch and abusing the Bot? Block him. This can be done while the Bot is running.
  4. Use usernames.json to give usernames other nicknames
    1. Example: Instead of takoz53, say "taco"
    2. This can be done while the Bot is running.
  5. The app should fall back on local Microsoft TTS if connectivity to GCP fails for whatever reason.

FAQ

The Bot doesn't say anything, but it says that it connected in Chat, what now?!

Could be a number of things. If chat is not appearing in the console, it could be an issue with creds.txt. If gcp voices aren't working, it could be an issue with gcp.json, or maybe your account is out of requests (haven't tested this).

I'm not getting a message that the Bot connected

Then I'd recommend you checking if your Twitch ID is lowercase, your channel is lowercase and the oauth key is right.

What can I customize?

  1. Maximum allowed characters
  2. Sentence, if maximum allowed characters are exceeded
  3. Message connector
    1. Example: "takoz5334 said hello" can be changed to "takoz5334 speaks hello" or into any other language etc.
  4. Swearword replacing word, default is "beep" when something bad is written.
  5. The TTS Voice -
    1. Set GCP to True or False to enable/disable GCP voices
    2. Default Voice Options (For options.txt 'Default' or usernames.json 'voice' attribute per user)
      • "Microsoft" - Uses local Microsoft TTS
      • "Random" - Uses Random GCP Voice for all messages for all users not defined by usernames.json
      • "Random-per-user" - Selects and stores a Random GCP Voice per user while the app is open
      • Anything from voicelist.txt

How do I block users?

Just write their name down in the blocklist, press enter and write another name in. Simple? Yes.

How do I give users nicknames

Just like in blocklist, go to usernames and assign each user a name, e.g. takoz53=taco xxswordmasterxx=swordmaster. Just note down, that the names have to be written in lowercase.

Can I block and unblock users from chat?

Yeah, definitely. You can by typing !block username and !unblock username. It'll do the checks whether the user is blocked and input is correct, so don't worry about typing something wrong.

How do I stop a message! It is malicious!

Either you or your moderators can use the !stoptts command to stop the text. It should stop immediately. Worst case you can stop the whole application!

Feel free to donate

If you liked the project and want to give me a bit of support, you can drop a few pennies here c: