User:Max Dovey/Talkingintothetwitterstream: Difference between revisions

From XPUB & Lens-Based wiki
No edit summary
No edit summary
Line 1: Line 1:
<iframe src='http://www.mapchannels.com/ac1/map.htm?id=where_21495' style='width:800px;height:600px;border:solid 1px black;overflow:hidden' frameborder='0' marginwidth='0' marginheight='0' scrolling='no'></iframe>
===Talking into the Twitter Stream===
<br/>Map Coding by <a target='_blank' href='http://www.mapchannels.com/'>Map Channels</a> and <a target='_blank' href='http://googlemapsmania.blogspot.co.uk/'>Google Maps Mania</a>
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?
 
<source lang = "Python" >
 
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()
 
 
</source>

Revision as of 19:56, 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()