def get(self, name=None): ''' Responds with a list of all engines if name is None in the following JSON format: { "success" : true, "result" : [<unicode>, <unicode>, ...] } Responds with the properties supported by a single engine in the following JSON format if name is a valid engine name. The exact fields available are dependent on the ISynthesizer.get_info implementation for the engine. { "success" : true, "result" { "range_property" { "minimum" : <number>, "maximum" : <number>, "default" : <number> }, "enumeration_property" : { "values" : [<unicode>, <unicode>, ...], "default" : <unicode> }, ... } } Responds with the following JSON error if information about the named engine is unavailable: { "success" : false, "description" : <unicode> } :param name: Name of the engine to query for details or None to get a list of all supported engines. Defaults to None. :param name: str ''' if name is None: names = synthesizer.AVAILABLE_SYNTHS.keys() ret = {'success': True, 'result': names} self.write(json_encode(ret)) else: cls = synthesizer.get_class(name) if cls is None: self.send_json_error({'description': 'invalid engine'}) else: info = cls.get_info() ret = {'success': True, 'result': info} self.write(ret)
def get(self, name=None): ''' Responds with a list of all engines if name is None in the following JSON format: { "success" : true, "result" : [<unicode>, <unicode>, ...] } Responds with the properties supported by a single engine in the following JSON format if name is a valid engine name. The exact fields available are dependent on the ISynthesizer.get_info implementation for the engine. { "success" : true, "result" { "range_property" { "minimum" : <number>, "maximum" : <number>, "default" : <number> }, "enumeration_property" : { "values" : [<unicode>, <unicode>, ...], "default" : <unicode> }, ... } } Responds with the following JSON error if information about the named engine is unavailable: { "success" : false, "description" : <unicode> } :param name: Name of the engine to query for details or None to get a list of all supported engines. Defaults to None. :param name: str ''' if name is None: names = synthesizer.SYNTHS.keys() ret = {'success' : True, 'result' : names} self.write(json_encode(ret)) else: cls = synthesizer.get_class(name) if cls is None: self.send_json_error({'description' : 'invalid engine'}) else: info = cls.get_info() ret = {'success' : True, 'result' : info} self.write(ret)
def post(self): ''' Performs speech synthesis of the utterances posted in the following JSON format: { "format" : <unicode>, "utterances" : { "id1" : <unicode>, "id2" : <unicode>, ... }, "properties" : { "property1" : <any>, "property2" : <any>, ... } } where the format dicates the encoding for the resulting speech files, the utterance values are the text to synthesize as speech, and the property names and values are those supported by the selected engine (also one of the properties). Responds with information about the synthesized utterances in the following JSON format on success: { "success" : true, "result" : { "id1" : <unicode>, "id2"" : <unicode>, ... } } where the utterance keys match those in the request and the values are the filenames of the synthesized files accessible using the FilesHandler. Responds with the following JSON error if synthesis fails: { "success" : false, "description" : <unicode> } ''' if self.application.settings['debug']: self.start_time = time.time() args = json_decode(self.request.body) pool = self.application.settings['pool'] engine = synthesizer.get_class(args['properties'].get( 'engine', 'espeak')) if engine is None: self.send_json_error({'description': 'unknown speech engine'}) return enc = encoder.get_class(args.get('format', '.ogg')) if enc is None: self.send_json_error({'description': 'unknown encoder format'}) return params = (engine, enc, args['utterances'], args['properties']) pool.apply_async(synthesize, params, callback=self._on_synth_complete)
def post(self): ''' Performs speech synthesis of the utterances posted in the following JSON format: { "format" : <unicode>, "utterances" : { "id1" : <unicode>, "id2" : <unicode>, ... }, "properties" : { "property1" : <any>, "property2" : <any>, ... } } where the format dicates the encoding for the resulting speech files, the utterance values are the text to synthesize as speech, and the property names and values are those supported by the selected engine (also one of the properties). Responds with information about the synthesized utterances in the following JSON format on success: { "success" : true, "result" : { "id1" : <unicode>, "id2"" : <unicode>, ... } } where the utterance keys match those in the request and the values are the filenames of the synthesized files accessible using the FilesHandler. Responds with the following JSON error if synthesis fails: { "success" : false, "description" : <unicode> } ''' if self.application.settings['debug']: self.start_time = time.time() args = json_decode(self.request.body) pool = self.application.settings['pool'] engine = synthesizer.get_class(args.get('engine', 'espeak')) if engine is None: self.send_json_error({'description' : 'unknown speech engine'}) return enc = encoder.get_class(args.get('format', '.ogg')) if enc is None: self.send_json_error({'description' : 'unknown encoder format'}) return params = (engine, enc, args['utterances'], args['properties']) pool.apply_async(synthesize, params, callback=self._on_synth_complete)