Friday, September 30, 2011

I love Python (espeak speech synthesizer demo)

#!/usr/bin/env python

''' -- demo each of the English espeak voices

import os, re, time
from itertools import ifilter, imap

# Pty Language Age/Gender VoiceName File Other Langs
# 5 en M default default

pat = re.compile('\s* \d+ \s+ (en\S*) \s+ \S \s+ (\S+)',re.VERBOSE)
for m in ifilter(None, imap(pat.match, os.popen('espeak --voices=en'))):
lang,voice = m.groups()
if '-' in lang:
print voice
os.system('espeak -v {0} "{0}... beer is good food" 2>/dev/null >/dev/null'.format(

No comments:

Post a Comment