Merge branch 'master' of git.xpub.nl:/var/www/git.xpub.nl/repos/tgc3
commit
03943a36ab
@ -0,0 +1,46 @@
|
||||
#! /usr/bin/env python
|
||||
import re, subprocess, random, os
|
||||
from time import sleep
|
||||
|
||||
devnull = open(os.devnull, 'w')
|
||||
|
||||
# requires: espeak and aplay (alsa-utils) to be installed
|
||||
|
||||
dic={
|
||||
"narrator": "en-us",
|
||||
"Pilot": "m4",
|
||||
"Sensor": "m7",
|
||||
"MC": "m2",
|
||||
"Jag25": "m6",
|
||||
"Unknown": "f1",
|
||||
"Bam Bam 41": "m3",
|
||||
"Safety Observer":"f3"
|
||||
|
||||
}
|
||||
|
||||
f=open("transcripts-drone-attack.txt","r")
|
||||
txt=f.readlines()
|
||||
p= re.compile(r"^(\d\d\:\d\d) \((.*?)\)\: (.*)") # regex for capturing groups: time, character, sentence
|
||||
for line in txt:
|
||||
if p.findall(line):
|
||||
time,char,sentence = (p.findall(line))[0]
|
||||
voice=dic[char]
|
||||
# play time
|
||||
subprocess.call(["espeak", time +" "+char, "-v", dic['narrator'], "-p", "20"], stdout=devnull, stderr=devnull) # narrator speaks: time and character
|
||||
sleep(0.5) #short pause before sentence
|
||||
if "*expletive*" in sentence: #"*expletive*" in sentence is True:
|
||||
sentence_parts=re.split(r"(\*\w+\*)", sentence)
|
||||
for part in sentence_parts:
|
||||
if part == '*expletive*':
|
||||
subprocess.call(["aplay", 'swear.wav'], stdout=devnull, stderr=devnull)
|
||||
else:
|
||||
subprocess.call(["espeak", part, "-v", voice], stdout=devnull, stderr=devnull) # character speaks: his
|
||||
sleep(float(random.randint(1,10))/100)
|
||||
else:
|
||||
subprocess.call(["espeak", sentence, "-v", voice], stdout=devnull, stderr=devnull) # character speaks: his
|
||||
|
||||
#
|
||||
else: # line w/out time or character (narrator)
|
||||
subprocess.call(["espeak", line, "-v", dic['narrator'], "-p", "20"], stdout=devnull, stderr=devnull)
|
||||
sleep(1) # make pause after each text line
|
||||
|
@ -0,0 +1,35 @@
|
||||
#! /usr/bin/env python
|
||||
import re, subprocess, random
|
||||
from time import sleep
|
||||
|
||||
# requires: espeak to be installed
|
||||
|
||||
dic={
|
||||
"narrator": "en-us",
|
||||
}
|
||||
|
||||
f=open("detail_of_attack.txt","r")
|
||||
txt=f.readlines()
|
||||
for line in txt:
|
||||
print line
|
||||
# # play time
|
||||
subprocess.call(["espeak", "-v", dic['narrator'], "-p", "20", line]) # narrator speaks: time and character
|
||||
# sleep(0.5) #short pause before sentence
|
||||
# print sentence
|
||||
# if "*CLASSIFIED*" in sentence: #"*expletive*" in sentence is True:
|
||||
# sentence_parts=re.split(r"(\*\w+\*)", sentence)
|
||||
# print sentence_parts
|
||||
# for part in sentence_parts:
|
||||
# if part == '*CLASSIFIED*':
|
||||
# print 'EXPLETIVE', part
|
||||
# subprocess.call(["aplay", 'swear.wav'])
|
||||
# else:
|
||||
# print 'SPEECH', part
|
||||
# subprocess.call(["espeak", part, "-v", voice]) # character speaks: his
|
||||
# sleep(float(random.randint(1,10))/100)
|
||||
# else: # line w/out time or character (narrator)
|
||||
# print "NARRATOR"
|
||||
# subprocess.call(["espeak", line, "-v", dic['narrator'], "-p", "20"])
|
||||
|
||||
sleep(.5) # make pause after each text line
|
||||
|
@ -1,35 +0,0 @@
|
||||
#! /usr/bin/env python
|
||||
import re, subprocess, random
|
||||
from time import sleep
|
||||
|
||||
# requires: espeak to be installed
|
||||
|
||||
dic={
|
||||
"narrator": "en-us",
|
||||
}
|
||||
|
||||
f=open("detail_of_attack.txt","r")
|
||||
txt=f.readlines()
|
||||
for line in txt:
|
||||
print line
|
||||
# play time
|
||||
subprocess.call(["espeak", "-v", dic['narrator'], "-p", "20"]) # narrator speaks: time and character
|
||||
sleep(0.5) #short pause before sentence
|
||||
print sentence
|
||||
if "*CLASSIFIED*" in sentence: #"*expletive*" in sentence is True:
|
||||
sentence_parts=re.split(r"(\*\w+\*)", sentence)
|
||||
print sentence_parts
|
||||
for part in sentence_parts:
|
||||
if part == '*CLASSIFIED*':
|
||||
print 'EXPLETIVE', part
|
||||
subprocess.call(["aplay", 'swear.wav'])
|
||||
else:
|
||||
print 'SPEECH', part
|
||||
subprocess.call(["espeak", part, "-v", voice]) # character speaks: his
|
||||
sleep(float(random.randint(1,10))/100)
|
||||
else: # line w/out time or character (narrator)
|
||||
print "NARRATOR"
|
||||
subprocess.call(["espeak", line, "-v", dic['narrator'], "-p", "20"])
|
||||
|
||||
sleep(1) # make pause after each text line
|
||||
|
Loading…
Reference in New Issue