User:Max Dovey/PT/TRIMESTER 2: Difference between revisions
< User:Max Dovey | PT
No edit summary |
|||
Line 63: | Line 63: | ||
</source > | </source > | ||
===pilimageseuqncefromtextfile=== | |||
<source lang = "python"> | <source lang = "python"> | ||
Line 96: | Line 96: | ||
</source > | </source > | ||
[[File:A test14.png]] | [[File:A test14.png]] | ||
A still from subtitle rip of "cleo from 5 - 7" by agnes Varda. | <br> | ||
''A still from subtitle rip of "cleo from 5 - 7" by agnes Varda.'' | |||
===speech=== | ===speech=== | ||
Revision as of 19:08, 26 March 2014
Network traffic sound http://www.ioplex.com/~miallen/tcpsound/ html.write()
speech language processing
- http://fritz-weber.de/raw-sonata/
- http://www.voxforge.org/home/read
- http://www.speech.cs.cmu.edu/sphinx/dictator/
- http://nuancedev.github.io/samples/http/python/
CGI
- http://pzwart3.wdka.hro.nl/wiki/Python_CGI_checklist
- http://pzwart3.wdka.hro.nl/wiki/Python_CGI
- www.tutorialspoint.com/python/python_cgi_programming.htm
search
Where? map dispaying google searchers containing the phrase 'where can i?" http://headroom.pzwart.wdka.hro.nl/~max/where.html
subtitles
Takes text from SRT (film subtitle files) into a formatted text file
import sys, zipfile, os, shutil, glob, textwrap, re
from os.path import join
f = open("filmsubs/Lost In Translation [Eng].srt", "r",)
h =open("lostintranslation.txt", "w")
i=0
for line in f:
# read file
if re.findall(r'\b --> \w+', line): #if you find '-->' do something
# print next(f)
# print i
x = 1 # x = line after this symbol
checkBlank = False
while checkBlank is False:
p = open("filmsubs/Lost In Translation [Eng].srt", "r",)
line = p.readlines()[i+x] #read line from point i(where we last where) plus x (read on from this point)
h.write(line)
p.close()
x=x+1 #iterate this digit so that it reads nextline in this while loop until....
if re.match(r'^\s*$',line):
checkBlank = True
i=i+1
pilimageseuqncefromtextfile
import PIL
from PIL import ImageFont
from PIL import Image
from PIL import ImageDraw
import struct, sys , time , os
import glob
from images2gif import writeGif
import sys, zipfile, os, shutil, glob, textwrap
from os.path import join
font = ImageFont.truetype("/Library/Fonts/arial.ttf", size= 12, index = 0 , encoding = 'armn' ) #set font to armn apple roman
img=Image.new("RGBA", (600,480),(0,0,0))
pages = 0
speed = 0.2
height = 7
f = open("thegrandbeauty.txt", "r",)
# text = f.readlines()
if not os.path.exists('images'):
os.makedirs('images')
for word in f:
pages = pages +1
height = height +10
draw = draw = ImageDraw.Draw(img)
draw.text((260, height),word,(255,255,255),font=font)
img.save("images/a_test%02d.png" % pages)
A still from subtitle rip of "cleo from 5 - 7" by agnes Varda.
speech
Talking into the Twitter Stream
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()