Skip to content

Swaps/Mutes active audio input device in OBS upon a specified channel point redemption in Twitch chat.

License

Notifications You must be signed in to change notification settings

Caisesiume/OBS-Mic-Swapper

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

20 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

OBS-Mic-Swapper

Shortcuts



Set up

  1. Create an account on Twitch for your bot
  2. Make sure your OBS version is >= 28.0.0.

If not, install OBS Websocket here

  1. Install the node modules for this program.
  2. Provide the OAuth data from your bot account in /twitch/client.json and /twitch/tokens.json
  3. Fill in the websocket authentication details in /twitch/auth.json
  4. Change the CHANNEL and REWARD to your channel and your reward ID in /twitch/listener.js.
  5. Make sure the values of MIC and CAM matches the names of the two OBS audio sources you want the script to activate / deactivate.

You can edit how long the toggle should last for by changing TIMEOUT

  1. Now run the program

Important: OBS needs to be open in order for the script to connect to the websocket

If you don't want to launch this manually each time you start your OBS, check this out.



Program Description

The system contains two main parts, one interacting with OBS and the other one interacting with Twitch Chat.

The OBS part

The system connects to your OBS locally using OBS Websocket.
The connection to OBS is only first established upon a call from the other part, the twitch chat listener.

The Twitch part

The listener connects to twitch chat as a read only bot that listens for specific custom channel point rewards redeemed by chatters.
This part is active at all times when the program is running and executes the OBS part when the channel point reward has been redeemed.



Example of Functionality (Use cases)

A user redeems the custom channel point reward "Mute Mic for 10s". This projects listener sees this reward in chat and tells the OBS part of the system to launch.
The OBS websocket client starts and tries to connect to your OBS Websocket. When connected, the audio state (muted/not muted) of the two defined audio input devices gets toggled. After 10 seconds, the input devices audio state gets once again toggled and returns to it's initial state.

A user redeems the custom channel point reward "Swap to webcam mic for 10s" This projects listener sees this reward in chat and tells the OBS part of the system to launch.
The OBS websocket client starts and tries to connect to your OBS Websocket. When connected, the audio state (muted/not muted) of the two defined audio input devices gets toggled. Meaning that your primary microphone gets muted and your secondary microphone (webcam) gets unmuted. After 10 seconds, the input devices audio state gets once again toggled and returns to it's initial state.



FAQ

How to find the reward ID?

You can check what the ID is by uncommenting line 37 before starting the program again. Keep in mind that the reward needs to have a text input field in twitch chat.


How do I install the correct node modules?

If you already have Node.js installed, simply navigate your command line to the root of this project where you can find package.json and run npm install


How do I run the program?

You will need to have Node.js installed to execute the program in a command line or via a .bat file or similar. The program can only be connected to OBS websockets on the same network as where the script is running.

Start by navigating your command line to the root folder of this system where you can find index.js. Now launch the program using one of the following

npm start

or

node ./index.js

Leave it open throughout your stream.


Can I run this automatically when starting OBS?

By default, no. Perhaps you can! I personally have not looked into this too much, but maybe this can be of some help?



Contact

Questions? Reach me on Twitter or Discord!

Twitter Logo            Discord Logo

About

Swaps/Mutes active audio input device in OBS upon a specified channel point redemption in Twitch chat.

Topics

Resources

License

Stars

Watchers

Forks