Squiso is a free, powerful automation tool that lets you customize your Twitch stream using simple scripts.
How to Create a (Free) Twitch TTS Automatic Chat Reader
This examples plays each chat Twitch message in your chat automatically using (free) TTS voices. This script example does not queue chat messages, but plays the latest TTS message as soon as the previous one ended.
Script Example
import com.squiso.*;
import com.squiso.exception.*;
import com.squiso.scripting.*;
import com.squiso.scripting.data.*;
import com.squiso.keyboard.*;
import com.squiso.twitch.*;
import com.squiso.datatypes.*;
import com.squiso.utils.*;
// Important - Please do not change the row below - otherwise you will get a compilation error!
public class Script_Example extends SquisoScript {
// Create a variable to keep track if a TTS is already playing or not
final SquisoBoolean playingTTS = new SquisoBoolean(false);
@Override
public void onTwitchChatMessage(OnTwitchChatMessageData data, API api) throws SquisoException {
// Create a list of strings
SquisoList<String> voices = new SquisoList<>();
// Add voice IDs into the list
// Voices can be found here: https://www.squiso.com/voices/
voices.add("rdb1mjjz");
voices.add("2ddbr1kk");
voices.add("uh04fp6i");
// Run the code inside independently (asynchronously)
api.async(() -> {
// If user is nightbot, end here
if (data.getUserName().equals("Nightbot")) {
return;
}
// If a TTS is already playing, end here
if (playingTTS.get()) {
api.log("Ignoring chat message - already playing a TTS.");
return;
}
// Set the TTS playing to true
playingTTS.set(true);
// Get a voice based on the username
String voiceID = voices.getBasedOnString(data.getUserName().toString());
// Compose the TTS message
SquisoString ttsMessage = new SquisoString(data.getUserName() + " says: " + data.getMessageText());
// Log that we are playing the TTS message
api.log(ttsMessage);
// Speak the TTS
api.speak(voiceID, ttsMessage);
// Set the TTS playing to false again
playingTTS.set(false);
});
}
}