import sys
import os

class Festival:

    def __init__(self):
        if os.system("which festival"):
            print "\n*Festival not found"       
            sys.exit(1)
        else:
            self.pipe = os.popen("festival", "w")

    def __del__(self):
        self.pipe.close()
            
    def command(self, cmd):
        self.pipe.write("(%s)" % cmd)            
        self.pipe.flush()
        
    def set_voice(self, voice):
        self.command("voice_%s_diphone" % voice)        
            
    def say_text(self, tts):
        self.command('SayText "%s"' % tts)
