Skip to content

Instantly share code, notes, and snippets.

@mvanorder
Created February 12, 2019 20:55
Show Gist options
  • Save mvanorder/cb3a4ebc4612d134e307b5fdb517781b to your computer and use it in GitHub Desktop.
Save mvanorder/cb3a4ebc4612d134e307b5fdb517781b to your computer and use it in GitHub Desktop.
Listen to Hexchat irc log with Google translate voice.
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