twitter

View the Project on GitHub digitalmonkey-risd/twitter

This is Github page for Documentation for OPENSTUDIO PROJECT RISD DM19

editor on GitHub

1.Basic Materials We Use for the Project ٩(๑•̀o•́๑)و

2. Install these to your Computer!

PIP

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

SpeedRecognition

after that you need to install speech recognition by the code below

$ sudo pip install SpeechRecognition

Anaconda

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.

pyaudio or portaudio.

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

Sphinx

$ 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!

3. Open Sublime Text and make two .py files as below

one is for recognition > twitt and the other is for reading API

tts.py

# 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;

auth.py

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'

4.Run Anaconda – In case you have different version of python installed. As far I tested it works well in python 3.6

$ source activate py36

5. Rud your code!

$ cd /yourPathWhere tts.py is in 
$ python tts.py