Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
import renpy.audio.audio
class PSSChannel(object):
def __init__(self, renpy_config):
# allocate myself a PSS channel number
self.channel_number = renpy.audio.audio.next_channel_number
renpy.audio.audio.next_channel_number += 1
print "Espeak/assigned myself channel number: %d" % self.channel_number
if(renpy_config.periodic_callback != None):
print "Espeak/Augh, someone's already registered the periodic callback. Attempting to be a good citizen and curry it."
old_callback = renpy_config.periodic_callback
def curry_callback():
old_callback()
self.periodic()
renpy_config.periodic_callback = curry_callback()
else:
renpy_config.periodic_callback = self.periodic
# buffers of WAV-headered PCM data go here. It's a FIFO, of course.
self.queue = []
def periodic(self):
depth = renpy.audio.audio.pss.queue_depth(self.channel_number)
print "Espeak/Periodic voice callback, depth %d..." % depth
if((depth < 2) and (len(self.queue) > 0)):
print "... !!!!!!!!!! I have more buffers and current depth is %d, so, submitting." % depth
renpy.audio.audio.pss.queue(self.channel_number, self.queue.pop(0), "espeak sample")
def enqueue(self, buf):
self.queue.append(buf)
self.periodic()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment