noboxio / tj-python

Python library for use with Watson services on a Raspberry Pi.
http://nobox.io
5 stars 3 forks source link
conversation ibm ibm-bluemix ibm-bluemix-python ibm-tjbot python speech tjbot tone watson watson-conversation watson-services watson-speech watson-tone-analyzer

Differences in this library compared to others

alt text

THINGS THAT HAVE TO BE PERFORMED ON A NEW PI

  1. Download the newest Raspbian image from: https://www.raspberrypi.org/downloads/raspbian/

    • We currently use RASPBIAN JESSIE WITH DESKTOP 2017-07-05
  2. Load the downloaded .img file onto your SD card. Raspberry Pi recommends that you use Etcher. See their Installing Operating Systems Images page: https://www.raspberrypi.org/documentation/installation/installing-images/README.md

  3. Configure the Raspberry Pi

    • Raspberry Icon --> Preferences --> Raspberry Pi Configuration
      • System:
        • Underscan: Disabled
      • Interfaces:
        • Camera: Enabled
        • SSH: Enabled
        • Serial: Enabled
      • Performance:
        • GPU Memory: 256
      • Localisation:
        • Locale: click Set Locale...
          • Language: en (English)
          • Country: US (USA)
        • Timezone: click Set Timezone...
          • Area: US
          • Location: Central
        • Keyboard: click Set Keyboard...
          • Country: United States
          • Variant: English (US) scroll up to see it at the top
    • Then reboot the pi sudo reboot or use the menu
  4. Set the default audio to be analog audio. sudo raspi-config

    • Pick option 7 Advanced Options
    • Pick option A4 Audio
    • Pick option 1 Force 3.5mm ('headphone') jack
    • Press the Enter Key
    • Use the Left and Right arrow keys to select <Finish> and press the Enter Keyboard

Then you can run the script located in config/setup.sh or you can execute the commands manually below.

  1. Update the dist list: sudo apt-get update
  2. Upgrade the apps sudo apt-get upgrade
    • Tell is yes if it asks if you want to continue Y
  3. Upgrade the distro sudo apt-get dist-upgrade
  4. Install vim sudo apt-get install vim
    • Vim config TODO
    • Git config use vim TODO
  5. REMOVE Install screen sudo apt-get install screen
  6. Install Python 3 and set as default
    • Already default
  7. Install system dependencies they are found on the pyaudio page(Below)
    • sudo apt-get install portaudio19-dev
    • sudo apt-get install python-all-dev
    • sudo apt-get install python3-dev
    • sudo apt-get install python3-pyaudio python-pyaudio !!!THIS DOES NOT WORK ON THE RPi!!!
    • TODO: Need to add the special code from the non standard dist that makes PyAudio work. This may not be correct if the new library doesn't require it!
  8. Install system dependencies for the watson-developer-cloud
    • sudo apt-get install libssl-dev libffi-dev build-essential scons swig
    • sudo easy_install3 --upgrade watson-developer-cloud
  9. Install the adafruit stuff
    • sudo pip3 install RPi.GPIO
  10. Install this for the LED controls
    • git clone https://github.com/jgarff/rpi_ws281x.git
    • cd rpi_ws281x
    • scons
    • cd python
    • sudo python3 setup.py install
  11. You need to copy the asound.conf file to /etc/
    • sudo cp asound.conf /etc/asound.conf
  12. You need to copy the asound file to ~/.asound
    • cp .asoundrc ~/.asoundrc
  13. Install VLC to play the music
    • sudo apt-get install vlc
  14. Install the python libraries required.
    • sudo easy_install3 websocket-client
    • sudo pip3 install colour
    • sudo pip3 install python-vlc

Thinking about adding: sudo pip3 install SpeechRecognition

IBM's TJBot code rewritten in Python.

NEEDS TO BE UPDATED

This is initial infromation that somewhat applies to the code in this repository but it is not up to date at this time.

Servo

Function wave(duration) or wave(count)
Function setangle(angle) or setangle(angle, speed)
Function up(), down(), forward() ---> just sends an angle to the set angle function
Function stop()

LED

Function setcolor(r,g,b) or setcolor(hex) or setcolor(color)
Function playsequence(sequence)
Sequence is a list of actions
A sequence has a repeat infinite, repeat count options
An action for the LED has a color and a duration
Function rainbow(speed) → does stuff with colors
Function strobe(speed) → strobes white at the speed
Function stop()

Music

Function playmusic(sound file)
Function volup(), voldown(), volmute()
Function pause(), stop(), restart()

Camera

Take a picture and just show it on the screen
Show a live video stream