#!/usr/bin/python import sys, time, ConfigParser import psyche pathname = psyche.get_psychepath() # read psycherc for commands cfg = ConfigParser.ConfigParser() cfg.read(pathname+'/psycherc') commands = [] for section in cfg.sections(): if section != 'settings': for option in cfg.options(section): commands.append(option.upper()) commands.append('SHUTDOWN') commands.append('QUIT') # build a text file for sphinx training fp = open(pathname+'commands.txt','w') for command in commands: fp.write(command+'\n') fp.close() # display the list of commands sys.stderr.write('select a command:\n') for i in range(len(commands)): sys.stderr.write('%d: %s\n'%(i+1,commands[i])) # start testing backends P = psyche.Psyche() P.load_festival() while 1: command = raw_input('enter a command:') try: if 0 < int(command) and int(command) <= len(commands): x = P('%s: %s'%(command,commands[int(command)-1])) else: print '%s is not a valid command number'%command except ValueError: sys.stderr.write('invalid input\n') except psyche.PsycheOff: break del P print 'demo complete.\n'