Esempio n. 1
0
    def do_GET(self):
        # log.debug("connect from: %s", self.client_address)
        if not self.path.startswith("/say?"):
            self.send_response(404)
            self.end_headers()
            return
        try:
            junk, data = self.path.split("?")
            data = urllib.unquote_plus(data)
            log.debug(data)
            phonetic = aquestalk2.yahoo.to_phonetic(data)
            log.debug(phonetic)
        except:
            self.send_response(500)
            self.end_headers()
            self.wfile.write("<html><head><title>Bootalk</title></head>")
            self.wfile.write("<body>bad input. UTF8 please</body></html>")
            return

        try:
            wav = aquestalk2.synthe(phonetic)
            self.send_response(200)
            self.send_header("Content-type", "text/html")
            self.end_headers()
            self.wfile.write("<html><head><title>Bootalk</title></head>")
            self.wfile.write("<body>%s</body></html>" % phonetic)
            f = wave.open(StringIO.StringIO(wav))
            play(self.device, f)
        except Exception, e:
            dummy, v = str(e).split(" ")
            err = aquestalk2.error_code.get(int(v)) or "Unknown error %s" % v
            log.warn(err)
            self.send_response(500)
            self.send_header("Content-type", "text/html")
            self.end_headers()
            self.wfile.write("<html><head><title>Bootalk</title></head>")
            self.wfile.write("<body>%s</body></html>" % err)
Esempio n. 2
0
    def test_synthe(self):
        wav = aquestalk2.synthe('あくえすとーく')
	self.assert_(len(wav) > 1000)