TWITTER BOTS Twitter Apps > apply for developer account https://projects.raspberrypi.org/en/projects/getting-started-with-the-twitter-api/ https://apps.twitter.com/
TTS API Thinking Sphinx or Google Web Speech API
install PIP to your computer using Terminal (MAC)
$ sudo pip install
also you might need to install below to install things
$ pip install twisted
Also, if you need upgrade below is the code
$ sudo pip --upgrade pip
after that you need to install speech recognition by the code below
$ sudo pip install SpeechRecognition
Also if your computer is preinstalled with python2, you might want to install Anaconda to use python3. Anaconda is allowing you to go back and forth between python2 and python3. Download from website link and install. After that, go steps below to launch environment to perform different ver of python
$ conda
$ conda search python
type the version of python you want to install in the area where “py36” is typed. you can have some instructions from there: Install Python with Anaconda
$ conda create -n py36 python=3.6 anaconda
$ source activate py36
If it worked well your terminal might display like this
(py36) youngin@youngsa-mbp ~ (master)
and check the version. If it matches with the version you installed it worked!
$ python -V
Python 3.6.6 :: Anaconda, Inc.
this is like speech-to-test plug-in. This will activate and allow to access your mic from python. do one of below
$ brew install portaudio
$ pip install pyaudio
$ sudo pip install pocketsphinx
google version works without anything but to use sphinx, you need this line. Google limits 50p/day and restart your computer!
one is for recognition > twitt and the other is for reading API
# as is to refer
import speech_recognition as sr
import time
from twython import Twython
from auth import (
consumer_key,
consumer_secret,
access_token,
access_token_secret
)
twitter = Twython(
consumer_key,
consumer_secret,
access_token,
access_token_secret
)
# Recognizer() command to let make it listen
r = sr.Recognizer()
while True:
with sr.Microphone() as source:
print("say something")
r.energy_threshold = 4000
audio = r.listen(source)
print("time over, thanks")
# recognize_sphinx part can be changed to recognize_google. but only 50/day
try:
message = (r.recognize_sphinx(audio))
twitter.update_status(status=message+" #DM_OpenStudio")
print("Tweeted: %s" % message)
time.sleep(100)
except:
pass;
this name can be changed, or directly typed in your tts file
consumer_key = 'your Key'
consumer_secret = 'your Key'
access_token = 'your Key'
access_token_secret = 'your Key'
$ source activate py36
$ cd /yourPathWhere tts.py is in
$ python tts.py