User:Max Dovey/Talkingintothetwitterstream: Difference between revisions

From XPUB & Lens-Based wiki
No edit summary
 
(One intermediate revision by the same user not shown)
Line 65: Line 65:


</source>
</source>
{{youtube |vUIcuJOyGjE}}

Latest revision as of 20:24, 26 March 2014

Talking into the Twitter Stream

Attempting to talk into the twitter stream, to make my spoken words converge with tweets. Generative language, data, performance, poetry. using voice recognition program Dragon & a python sketch that takes the last word of each sentence, queries twitter and returns a tweet containing the word and the word that followed. Could i use this to make an ever lasting sentence?

import json
import simplejson
import os, sys
import time
import commands 
import subprocess
import twitter
CONSUMER_KEY = "****"
CONSUMER_SECRET = "****"
OAUTH_TOKEN = "****"
OAUTH_TOKEN_SECRET = "****"

auth = twitter.oauth.OAuth(OAUTH_TOKEN, OAUTH_TOKEN_SECRET,
                           CONSUMER_KEY, CONSUMER_SECRET)

twitter_api = twitter.Twitter(domain='api.twitter.com', 
                              api_version='1.1',
                              auth=auth

                                )
f = open("translate.txt", "r") #define file path

key=[]
q = [] 
for line in f:
    sentence = line.split()
    words = sentence[-1::]
    key.append(words)

p = open("translationfull.txt", "w",)
sawword= False 
q = key 
print q 
count = 2
search_results= twitter_api.search.tweets(q=q, count=count)
for status in search_results['statuses']:
    text = status['text']
    words = text.split()
    print words

    for i in words:
        if q in words:
            sawword=True
            print i
            p.write(word) 
            p.writelines("\n ")

            
        elif (sawword):
            print word 
            p.write(word)
            p.writelines("\n")
            sawword= False 
            time.sleep(2)
        p.close()