Giter Site home page Giter Site logo

random_quote's Introduction

random_quote

Python script that plays a random audio file based on input received from a livestream chat.

How it works

This script relies on the following:

  • mpv to play audio files
  • An IRC client: the script currently supports log files generated by Chatty but it can easily be adapted to handle logs from other clients such as HexChat

While the IRC client is logging messages from a channel, the script will continuously check the corresponding log file to see when someone has said something and then trigger an audio file thanks to mpv (cmd/cli) based on how the script was configured.

Before use

First, you will need to install Python, mpv and Chatty.

Python

Python can be downloaded here. During the installation, if you're a Windows user, make sure you check the checkbox that says Add python.exe to PATH.

mpv

mpv can be downloaded here. For Windows users, I suggest clicking the first link that takes you to SourceForge and then clicking the green button that says Download Latest Version. You will get a .zip file which you can extract into an empty folder. Double click on the .bat file you just extracted and let it do its thing.

Chatty

Chatty can be downloaded here. It requires Java so make sure you also install that if not already the case. The installation itself is straightforward so I won't go into the details here but after launching it for the first time and logging into your Twitch account, you will need to go to Main > Settings > Log to file and have the following configured:

  • in the Message Types section, uncheck everything except for the Chat Messages checkbox,
  • in the Other Settings section, uncheck the Lock files checkbox,
  • hit the Save button to save and close the settings window.

How to use

  1. Download this repository and unzip it anywhere you want on your computer
  2. Add your audio files inside the audio folder
  3. Assuming you have already joined a Twitch chat in Chatty, you can then run the script by either running the python main.py command or, for Windows users, by right-clicking the main.py and select Open with > Python
  4. A window will show up where you can:
    • fill in the name of the channel you want to track (aka one that you joined in Chatty)
    • select the way you want quotes to be played;
      • percentage chance per message sent -> make sure the value specified is a number between 1 and 100
      • command -> put any string you want and an audio file will play whenever someone's message contains that string
    • Chaos mode is a mode that doesn't wait for the previous audio file to finish, so it leads to a chaotic mess where audio files overlap
  5. The script will automatically update the contents of the quote.txt file with the info on who triggered an audio file in case you want to capture that in OBS (Add > Text > Read from file). There is also a large rectangle inside the window that contains the same info if you prefer capturing that.

Troubleshooting

tk package missing on Linux

One error I came across so far was when I tested it on Linux and the tk module was missing. In my case I just had to install it with the following command (i use arch btw)

sudo pacman -S tk

For other distros it might be named differently, like python-tk or something like that.

random_quote's People

Contributors

shadax1 avatar

Stargazers

Dominik Zimaj avatar Alex Barney avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.