https://github.com/ranman/babylex
python lex client
https://github.com/ranman/babylex
Last synced: 11 months ago
JSON representation
python lex client
- Host: GitHub
- URL: https://github.com/ranman/babylex
- Owner: ranman
- Created: 2017-01-26T07:51:59.000Z (over 9 years ago)
- Default Branch: master
- Last Pushed: 2017-02-01T17:50:27.000Z (over 9 years ago)
- Last Synced: 2025-05-20T04:47:47.408Z (about 1 year ago)
- Language: Python
- Size: 4.88 KB
- Stars: 3
- Watchers: 0
- Forks: 4
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# BabyLex is a quick python wrapper for lex
# The lex service is in preview and this library may not be maintained or change as lex changes
----------------------------
# Quick Start
```python
from babylex import LexSession
lex_session = LexSession("WhereIsRandall", "$LATEST", "ranman")
resp = lex_session.text("where is randall")
print resp
```
returns:
`{u'slotToElicit': None,
u'dialogState': u'Fulfilled',
u'intentName': u'WhereRandall',
u'responseCard': None,
u'message': u'Randall is in claremont, ca',
u'slots': {},
u'sessionAttributes': {}}`
You can work with audio as well:
```python
from babylex import LexSession
import pyaudio
p = pyaudio.PyAudio()
lex_session = LexSession("WhereIsRandall", "$LATEST", "ranman")
resp = lex_session.content("Where is Randall", "text/plain; charset=utf-8", "audio/pcm")
stream = p.open(format=p.get_format_from_width(width=2), channels=1, rate=16000, output=True)
stream.write(resp.content)
stream.stop_stream()
stream.close()
```