Created
February 12, 2019 20:55
-
-
Save mvanorder/cb3a4ebc4612d134e307b5fdb517781b to your computer and use it in GitHub Desktop.
Listen to Hexchat irc log with Google translate voice.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import os | |
import re | |
import time | |
from google_speech import Speech | |
sox_effects = ("speed", "1.5", "pitch", "-700") | |
filename = os.path.join(os.path.expanduser('~'), '.config', 'hexchat', 'logs', 'freenode', '#python.log') | |
f = open(filename, 'r') | |
f.read() | |
while True: | |
t = f.readline() | |
if not re.match(r'^\w+ [0-9 ][0-9] ([0-9]{2}:){2}[0-9]{2} \*', t): | |
speech = Speech(re.sub(r'^\w+ [0-9 ][0-9] ([0-9]{2}:){2}[0-9]{2} <(\w+)>\t', r'\2 said ', t), 'en') | |
speech.play(sox_effects) | |
if not t: | |
time.sleep(0.5) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment