Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/wit-ai/pywit
Python library for Wit.ai
https://github.com/wit-ai/pywit
Last synced: about 1 month ago
JSON representation
Python library for Wit.ai
- Host: GitHub
- URL: https://github.com/wit-ai/pywit
- Owner: wit-ai
- License: other
- Created: 2014-09-29T22:55:24.000Z (about 10 years ago)
- Default Branch: main
- Last Pushed: 2023-12-10T12:01:28.000Z (11 months ago)
- Last Synced: 2024-10-01T12:22:32.146Z (about 1 month ago)
- Language: Python
- Homepage:
- Size: 117 KB
- Stars: 1,454
- Watchers: 92
- Forks: 359
- Open Issues: 21
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGES.md
- Contributing: CONTRIBUTING.md
- License: LICENSE
- Code of conduct: CODE_OF_CONDUCT.md
Awesome Lists containing this project
README
# pywit
`pywit` is the Python SDK for [Wit.ai](http://wit.ai).
## Install
Using `pip`:
```bash
pip install wit
```From source:
```bash
git clone https://github.com/wit-ai/pywit
pip install .
```## Usage
See the `examples` folder for examples.
## API
### Versioning
The default API version is `20200513`.
You can target a specific version by setting the env variable `WIT_API_VERSION`.### Overview
`pywit` provides a Wit class with the following methods:
* `message` - the Wit [message API](https://wit.ai/docs/http/20200513#get-intent-via-text-link)
* `speech` - the Wit [speech API](https://wit.ai/docs/http/20200513#post--speech-link)
* `interactive` - starts an interactive conversation with your bot### Wit class
The Wit constructor takes the following parameters:
* `access_token` - the access token of your Wit instanceA minimal example looks like this:
```python
from wit import Witclient = Wit(access_token)
client.message('set an alarm tomorrow at 7am')
```### .message()
The Wit [message API](https://wit.ai/docs/http/20200513#get-intent-via-text-link).
Takes the following parameters:
* `msg` - the text you want Wit.ai to extract the information fromExample:
```python
resp = client.message('what is the weather in London?')
print('Yay, got Wit.ai response: ' + str(resp))
```### .speech()
The Wit [speech API](https://wit.ai/docs/http/20200513#post--speech-link).
Takes the following parameters:
* `audio_file` - a file handler opened in binary mode
* `headers` - (optional) the dict of headers (e.g. "Content-Type")Example:
```python
resp = None
with open('test.wav', 'rb') as f:
resp = client.speech(f, {'Content-Type': 'audio/wav'})
print('Yay, got Wit.ai response: ' + str(resp))
```### .interactive()
Starts an interactive conversation with your bot.
Example:
```python
client.interactive()
```See the [docs](https://wit.ai/docs) for more information.
### Logging
Default logging is to `STDOUT` with `INFO` level.
You can set your logging level as follows:
``` python
from wit import Wit
import logging
client = Wit(token)
client.logger.setLevel(logging.WARNING)
```You can also specify a custom logger object in the Wit constructor:
``` python
from wit import Wit
client = Wit(access_token=access_token, logger=custom_logger)
```See the [logging module](https://docs.python.org/2/library/logging.html) and
[logging.config](https://docs.python.org/2/library/logging.config.html#module-logging.config) docs for more information.## License
The license for pywit can be found in LICENSE file in the root directory of this source tree.
## Terms of Use
Our terms of use can be found at https://opensource.facebook.com/legal/terms.
## Privacy Policy
Our privacy policy can be found at https://opensource.facebook.com/legal/privacy.