def initialize_with(heap_size, load_init_files): tts.initialize(heap_size, load_init_files)
def initialize(): tts.initialize()
to the tts module to be converted to speech. As the URL and the regular expression are both hard-coded, this application is very sensitive to changes in the location and layout of the target web page. """ import urllib, re import nltk_contrib.misc.festival.tts as tts URL = "http://www.bom.gov.au/cgi-bin/wrap_fwo.pl?IDV10450.txt" REGEXP = "(Forecast for Melbourne .*)Suburban" try: page = urllib.urlopen(URL).read() except IOError, e: print "Unable to connect to web server." sys.exit(1) x = re.search(REGEXP, page, re.DOTALL) # DOTALL ensures newlines are included if x: text = x.group(1) print text tts.initialize() tts.say_text(text) else: print "Web page does not have the expected format."