I get messages on this forum from time to time from users asking about this kind of Twitch Chat / VoiceAttack integration. I'm happy to try and help and reply to them, but I also thought it might be good to post some of the information here for posterity.
The way it works is a Streamlabs Chatbot python script takes commands from the Twitch Chat, does some logic to decide what to do. If appropriate, it uses the subprocess.call() method in python to run the voiceattack.exe as if from the command line to actually execute a command.
To start off, you can open the windows command prompt and see if you can get VoiceAttack to run commands for you manually. Have VoiceAttack running and then from the prompt, try commands like this:
VoiceAttack.exe -command test
That should fire off the corresponding "test" command in voice attack. Either make a simple command called "test" or use something that does exist in your profile. If voiceattack.exe is not in your path, you may have to change to the directory where its linstalled (C:\Program Files(x86)\VoiceAttack" by default).
If you can run the commands manually from the command line, then the next step is to get a python script to run them in response to interactions with chat.
The python script I have works inside the Streamlabs Chatbot framework. I recommend starting with this tutorial if this kind of thing is new to you:
https://betterprogramming.pub/creating-a-twitch-command-script-with-streamlabs-chatbot-step-by-step-a9f8cccd680dThat guide is what I started with when I had no experience with any of this stuff (python, chatbot, stream labs) and it was good in terms of a step by step setup for the supporting software and framework. If you can get the script they have you make working, then chances are good you can expand that to make it do what you want with Twitch chat to VoiceAttack integration.
If you can get their demo script setup and working, this is a sample of the first draft of my !PitGIrl script. Depending on what you are trying to do, it may be a good place to start in terms of parsing the Twitch chat and calling VoiceAttack.
ScriptName = "PitGirl"
Website = "http://robertsmania.com/"
Description = "PitGirl is love"
Creator = "Robertsmania"
Version = "1.0.0"
Command = "!pitgirl"
va_binary = r"C:\Program Files (x86)\VoiceAttack\VoiceAttack.exe"
camera_dict = OrderedDict()
camera_dict["chase"] = "set camera to chase"
camera_dict["cockpit"] = "set camera to cockpit"
camera_list = ', '.join(camera_dict.keys())
def Execute(data):
if data.GetParam(0) != Command:
return
elif data.GetParam(1) != "set" or data.GetParam(2) != "camera" or data.GetParam(3) != "to":
usage()
return
elif not camera_dict.get(data.GetParam(4)):
send_message(data.GetParam(4) + " is not a valid camera")
usage()
return
send_message(camera_dict.get(data.GetParam(4)))
va_cmd = [va_binary, "-command", camera_dict.get(data.GetParam(4))]
subprocess.call(va_cmd, shell=True)
return
def usage():
send_message("use: !pitgirl set camera to (camera)")
send_message("cameras are: " + camera_list)
return
def send_message(message):
Parent.SendStreamMessage(message)
return
Thats just a snip of the script, but it follows the format they present in their example. I have VoiceAttack commands for "set camera to chase" and "set camera to cockpit" that get called if the logic indicates that's what the user requested. This was a first draft and is strict in terms of what it will accept. In this example, if the user enters either of these commands into chat, it will fire off the corresponding command in VoiceAttack:
!pitgirl set camera to chase
!pitgirl set camera to cockpit
If you get something working so your Chatbot runs commands from VoiceAttack, you probably will want to go a little further and have it send additional parameters as well. That way the commands can be more powerful/general and you can have VoiceAttack say things specific to the request. In my case, I found having it say the viewer's name who made the request was really popular.
To do that, you can use the -passedText option when you call VoiceAttack.exe. Again, try it manually first and make sure your commands work properly from the command line like so:
VoiceAttack.exe -command test -passedText "\"text here\""
Inside your VoiceAttack command, you access those values as “~passedInteger1”, “~passedDecimal1”, “~passedBoolean1” and “~passedText1”.
See the documentation for handling these kind of passed values.
There is also this thread on the forum that might have helpful information:
https://forum.voiceattack.com/smf/index.php?topic=3357.30Here's a sample of how to make the corresponding call from within python:
va_binary = r"C:\Program Files (x86)\VoiceAttack\VoiceAttack.exe"
def test(data):
cmd_test = "test"
prm_test = "\"text here\""
run_command_test(cmd_test, prm_test)
return
def run_command_test(command_string, param_string):
va_cmd = [settings["va_binary"], "-command", command_string, "-passedText", param_string]
subprocess.call(va_cmd, shell=True)
log(2, str(va_cmd))
return