User:Angeliki/Grad-prototyping
Zine-machines
export GPS data, publish routes/video frames to raw data-publish
import pykml
from pykml import parser
import csv
import re
from reportlab.lib.pagesizes import letter
from reportlab.pdfgen import canvas
def translate(value, leftMin, leftMax, rightMin, rightMax):
# Figure out how 'wide' each range is
leftSpan = leftMax - leftMin
rightSpan = rightMax - rightMin
# Convert the left range into a 0-1 range (float)
valueScaled = float(value - leftMin) / float(leftSpan)
# Convert the 0-1 range into a value in the right range.
return rightMin + (valueScaled * rightSpan)
kml_file='prlll.kml'
all_routes = {}
with open(kml_file) as f:
doc = parser.parse(f).getroot().Document.Folder
for pm in doc.iterchildren():
if hasattr(pm, 'LineString'):
name = pm.name.text
coordinates = pm.LineString.coordinates.text
cordinatesinline = coordinates.split('\n')
cordinatesasarray = []
for line in cordinatesinline:
pattern = re.compile("^\s+|\s*,\s*|\s+$")
array = [x for x in pattern.split(line) if x]
if array:
cordinatesasarray.append(array)
all_routes[name]= cordinatesasarray
canvas=canvas.Canvas("route.pdf", pagesize=letter)
canvas.setLineWidth(.8)
canvas.setFont('Helvetica', 6)
for name in all_routes:
x=[]
y=[]
for points in all_routes[name]:
x.append(points[0])
y.append(points[1])
i=0
for a in x:
if i < len(x)-1:
x_new=translate(float(x[i]),float(min(x)), float(max(x)),50,500)
y_new=translate(float(y[i]),float(min(y)),float(max(y)),50,500)
x_new2=translate(float(x[i+1]),float(min(x)), float(max(x)),50,500)
y_new2=translate(float(y[i+1]),float(min(y)),float(max(y)),50,500)
print x_new,y_new,x_new2,y_new2
canvas.line(x_new,y_new,x_new2,y_new2)
i=i+1
canvas.drawString(10,45,name)
canvas.showPage()
canvas.save()
Walking/annotating/listening/transcribing/present voice
The secrets of pocketsphinx
Acoustic model/training
0 46797 She had your dark suit in greasy wash water all year.
File:
1 Η ο At AtDf Fe|Sg|Nm 2 Atr _ _
2 Σίφνος Σίφνος No NoPr Fe|Sg|Nm 3 Sb _ _
3 φημίζεται φημίζομαι Vb VbMn Id|Pr|03|Sg|Xx|Ip|Pv|Xx 0 Pred _ _
4 και και Cj CjCo _ 5 AuxY _ _
5 για για AsPp AsPpSp _ 3 AuxP _ _
6 τα ο At AtDf Ne|Pl|Ac 8 Atr _ _
7 καταγάλανα καταγάλανος Aj Aj Ba|Ne|Pl|Ac 8 Atr _ _
8 νερά νερό No NoCm Ne|Pl|Ac 5 Obj _ _
9 των ο At AtDf Fe|Pl|Ge 11 Atr _ _
10 πανέμορφων πανέμορφος Aj Aj Ba|Fe|Pl|Ge 11 Atr _ _
11 ακτών ακτή No NoCm Fe|Pl|Ge 8 Atr _ _
12 της μου Pn PnPo Fe|03|Sg|Ge|Xx 11 Atr _ _
13 . . PUNCT PUNCT _ 0 AuxK _ _
1 Πιστεύω πιστεύω Vb VbMn Id|Pr|01|Sg|Xx|Ip|Av|Xx 0 Pred _ _
2 ότι ότι Cj CjSb _ 1 AuxC _ _
3 είναι είμαι Vb VbMn Id|Pr|03|Sg|Xx|Ip|Pv|Xx 2 Obj _ _
4 δίκαιο δίκαιο No NoCm Ne|Sg|Nm 3 Pnom _ _
5 να να Pt PtSj _ 7 AuxV _ _
6 το εγώ Pn PnPe Ne|03|Sg|Ac|We 7 Obj _ _
7 αναγνωρίσουμε αναγνωρίζω Vb VbMn Id|Xx|01|Pl|Xx|Pe|Av|Xx 3 Sb _ _
8 αυτό αυτός Pn PnDm Ne|03|Sg|Ac|Xx 7 Obj _ _
9 . . PUNCT PUNCT _ 0 AuxK _ _
1 Η ο At AtDf Fe|Sg|Nm 2 Atr _ _