Squiso is a free, powerful automation tool that lets you customize your Twitch stream using simple scripts.
How to AI Generated Images When Someone Gifts Twitch Channel Subs
This script example displays an AI generated image briefly in OBS Studio and plays an audio when someone gifts subs. In order to show the image in OBS Studio, you are required to create an Image Source that points to the generated image on disk.
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 {
@Override
public void onTwitchGiftedSubs(OnTwitchGiftedSubsData data, API api) throws SquisoException {
// Compose an image prompt using the number of sub-gifts
SquisoString prompt = new SquisoString("A cake with the number " + data.getTotalGifted() + " on it. Explosions in the background. Epic cinematic movie poster. Dramatic colors. Full background. No text.");
// Generate an AI image using a given prompt
SquisoData image = api.generateAIImage(prompt);
// Save the image to generated.jpg
image.writeToFile("generated.jpg");
// Play the sound effect explosion.mp3
api.playAudio("explosion.mp3");
// Specify 10 seconds (10*1000=10000 milliseconds)
SquisoInteger waitTime = new SquisoInteger(10 * 1000);
// Do this 10 seconds later
api.doLater(waitTime, () -> {
// Delete the image generated.jpg
FileUtil.deleteFile("generated.jpg");
});
}
}