一些修改

This commit is contained in:
zhujisheng 2019-02-27 21:58:11 +08:00
parent d2e6843f9b
commit 19dc5c61b8
5 changed files with 38 additions and 0 deletions

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

38
ais_cli.py Normal file
View File

@ -0,0 +1,38 @@
"""
This is the client to public AIs' API for voice_assistant.
"""
import requests
class tuling123(object):
def __init__(self, user_id, api_key, base_url='http://openapi.tuling123.com/openapi/api/v2'):
self._session = requests.Session()
self._base_url = base_url
self._base_data = { 'reqType': 0,
'userInfo': {
'apiKey': api_key,
'userId': user_id
},
'perception': {
'inputText': {
'text': ''
}
}
}
def command(self, input_sentence):
data = self._base_data
data['perception']['inputText']['text'] = input_sentence
r = self._session.post(url=self._base_url, json = data)
output = r.json()
ouput_sentence = None
for result in output['results']:
if result['resultType']=='text':
ouput_sentence = result['values']['text']
break
return(ouput_sentence)