Revision e21d7f2c

View differences:

tts_bridge/mary/mary_tts_bridge/MaryTTSBridge.py
34 34
import actionlib
35 35
from io import BytesIO
36 36
import wave
37
import os
38
import pkgutil
37 39
from MaryTTSClient import *
38 40
from cStringIO import StringIO
39 41

  
......
116 118
	for line in sio:
117 119
	    if (line[0] != '#'):
118 120
		phoneme_list = line.split(" ")
119
		symbol = phoneme_list[2]
120
		symbol = symbol.rstrip()
121

  
122
		now = float(phoneme_list[0])
123
		duration = (now - last)*1000
124
		last = now
125
		plist.append(phoneme(symbol, int(duration)))
121
                if (line == '\n'):
122
                    #ignore empty lines
123
                    continue
124
                elif (len(phoneme_list) != 3):
125
                    print("> could not split line '%s' during phoneme seperation\n" % (line))
126
                else:
127
		    symbol = phoneme_list[2]
128
    		    symbol = symbol.rstrip()
129

  
130
   		    now = float(phoneme_list[0])
131
		    duration = (now - last)*1000
132
		    last = now
133
		    plist.append(phoneme(symbol, int(duration)))
126 134

  
127 135
	self.logger.info("created phonemelist with " + str(len(plist)) + " elements")
128 136

  
......
137 145
	self.logger.info("created utterance for 'phonemelist with '" + u.text + "'")
138 146
	return u
139 147

  
148
    def get_error_message(self):
149
        data_wav = pkgutil.get_data('mary_tts_bridge', 'data/connection_failed.wav')
150
        data_phonemes = pkgutil.get_data('mary_tts_bridge', 'data/connection_failed.phonemes')
151
        return (data_wav, data_phonemes)
152

  
140 153
    def execute_cb(self, goal):
141 154
	self.logger.info("incoming utterance '" + goal.text + "'")
142 155

  
......
150 163

  
151 164
	except:
152 165
	    self.logger.error("failed to create utterance error = '" + str(sys.exc_info()[1]) + "'")
153
	    success = False
166
            #try to open error message from file:
167
            success = True
168
            (audio, phonelist) = self.get_error_message()
154 169

  
155 170
	if success:
156 171
	    #build soundchunk
tts_bridge/mary/mary_tts_bridge/MaryTTSClient.py
59 59
	self.tts_port = tts_port
60 60
	self.locale   = locale
61 61
	self.voice    = voice
62
	
62

  
63 63
    def __del__(self):
64 64
	"""destructor
65 65
	"""
......
105 105
	params = urllib.urlencode(raw_params)
106 106
	headers = {}
107 107

  
108
	#open connection to mary server
109
	conn = httplib.HTTPConnection(self.tts_host, self.tts_port)
110

  
111 108
	#conn.set_debuglevel(5)
109
	#open connection to mary server
110
        conn = httplib.HTTPConnection(self.tts_host, self.tts_port)
112 111

  
113 112
	conn.request("POST", "/process", params, headers)
114 113
	response = conn.getresponse()
114

  
115 115
	if response.status != 200:
116 116
	    print response.getheaders()
117
            conn.close()
117 118
	    raise RuntimeError("{0}: {1}".format(response.status,response.reason))
118 119
	return response.read()
119 120

  
tts_bridge/mary/setup.py
38 38
    # Choose your license
39 39
    license='GPLv3',
40 40

  
41
    #include package data?
42
    include_package_data = True,
43

  
41 44
    # See https://pypi.python.org/pypi?%3Aaction=list_classifiers
42 45
    classifiers=[
43 46
        # How mature is this project? Common values are
......
90 93
    # installed, specify them here.  If using Python 2.6 or less, then these
91 94
    # have to be included in MANIFEST.in as well.
92 95
    package_data={
96
        '': ['data/connection_failed.*'],
93 97
        #'sample': ['package_data.dat'],
94 98
    },
95 99

  

Also available in: Unified diff