result = relext.sire( params = { 'sid': 'ie-en-news', 'txt': input_query, 'rt': 'json' } ); # Type of the returned document: XML document response.content_type = 'text/json'; return result; # Setting up a Watson service # - url and auth(username,password) found in the credentails of a service # - operations: found at http://www.ibm.com/smarterplanet/us/en/ibmwatson/developercloud/apis/ @post('/speech-to-text') def speech_to_text(): speech_to_text = WatsonService( url = 'https://stream.watsonplatform.net/speech-to-text/api', auth = ('7112a49-50bf-4645-a877-2c57ef208bf5','25FXpxclz2sA'), operations = { 'sire': { 'method': 'POST', 'path': '/v1/sire/0' } } ); WebServer.start();
response = { 'type': 'message', 'text': randomText } else: response = { 'type': 'error', 'error': 'Unknown request type' } # generate sound file if (request['sound'] == 'on' and response['text'] and response['text'] != hello): result = textToSpeech.synthesize( params={ 'voice': 'en-US_MichaelVoice', 'text': response['text'], 'accept': 'audio/wav' }) # Save File ogg = open('static/sound/answer.wav', 'wb') ogg.write(result) return WebServer.processResponse(response) WebServer.start() # cf push eTeaching -p eTeaching -m 512M -n eteaching