analitics

Pages

Showing posts with label wit. Show all posts
Showing posts with label wit. Show all posts

Friday, April 27, 2018

Python 3.6.4 : Testing the wit python module .

Today I tested the wit python module.
This python module is a Python library for Wit.ai
You can use for this issues:
  • Bots
  • Mobile apps
  • Home automation
  • Wearable devices
  • Robots
These support languages like:
Afrikaans, Albanian, Arabic, Azerbaijani, Bengali, Bosnian, Bulgarian, Burmese, Catalan, Central Khmer, Chinese, Croatian, Czech, Danish, Dutch, English, Estonian, Finnish, French, Georgian, German, Greek, Hausa, Hebrew, Hindi, Hungarian, Icelandic, Igbo, Indonesian, Inuktitut, Italian, Japanese, Kannada, Kinyarwanda, Korean, Latin, Latvian, Lithuanian, Macedonian, Malay, Maori, Mongolian, Norwegian, Persian, Polish, Portuguese, Romanian, Russian, Serbian, Slovak, Slovenian, Somali, Southern Ndebele, Southern Sotho, Spanish, Swahili, Swati, Swedish, Tagalog, Tamil, Thai, Tsonga, Tswana, Turkish, Ukrainian, Urdu, Uzbek, Venda, Vietnamese, Xhosa, Yoruba and Zulu.
About Wit is free, including for commercial use. So both private and public Wit apps are free and are governed our terms.
For this tutorial I use python 3.6.4, see :
C:\Python364>python.exe
Python 3.6.4 (v3.6.4:d48eceb, Dec 19 2017, 06:54:40) [MSC v.1900 64 bit (AMD64)]on win32
Type "help", "copyright", "credits" or "license" for more information.
The install of wit python module is simple:
C:\Python364>cd Scripts

C:\Python364\Scripts>pip install wit
Collecting wit
...
Successfully built wit
Installing collected packages: wit
Successfully installed wit-5.1.0

C:\Python364\Scripts>python
Python 3.6.4 (v3.6.4:d48eceb, Dec 19 2017, 06:54:40) [MSC v.1900 64 bit (AMD64)]
 on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> from wit import Wit
>>> w=Wit('3ODKKNB---------')
>>> w.message('Python este un limbaj de programare')
{'_text': 'Python este un limbaj de programare', 'entities': {}, 'msg_id': '0pNT
QXn87P3MYvqmR'}
>>> dir(w)
['__class__', '__delattr__', '__dict__', '__dir__', '__doc__', '__eq__', '__form
at__', '__ge__', '__getattribute__', '__gt__', '__hash__', '__init__', '__init_s
ubclass__', '__le__', '__lt__', '__module__', '__ne__', '__new__', '__reduce__',
 '__reduce_ex__', '__repr__', '__setattr__', '__sizeof__', '__str__', '__subclas
shook__', '__weakref__', '_sessions', 'access_token', 'interactive', 'logger', '
message', 'speech']
>>> file = open('C:\Python364\hello_world.wav', 'rb')
>>> w.speech(file)
Traceback (most recent call last):
  File "", line 1, in 
  File "C:\Python364\lib\site-packages\wit\wit.py", line 88, in speech
    data=audio_file, headers=headers)
  File "C:\Python364\lib\site-packages\wit\wit.py", line 41, in req
    ' (' + rsp.reason + ')')
wit.wit.WitError: Wit responded with status: 400 (Bad Request)
The error has an open issue.
It does not seem to work properly.
There are some open issues for this python module.
The examples on the internet are not very concise with how to use this python module.