[open-allure-ds] push by jg07...@gmail.com - Create all.ogg from question / answer / response clips... on 2011-09-30 05:46 GMT

1 view
Skip to first unread message

open-al...@googlecode.com

unread,
Sep 30, 2011, 1:47:02 AM9/30/11
to open-al...@googlegroups.com
Revision: fc1cdd698d2c
Author: Jo...@John-PC.lan
Date: Thu Sep 29 22:45:26 2011
Log: Create all.ogg from question / answer / response clips
Use utf-8 codec in scriptParser
http://code.google.com/p/open-allure-ds/source/detail?r=fc1cdd698d2c

Added:
/odp2wts/silence.ogg
Modified:
/odp2wts/odp2wts.py
/odp2wts/scriptParser.py

=======================================
--- /dev/null
+++ /odp2wts/silence.ogg Thu Sep 29 22:45:26 2011
Binary file, no diff available.
=======================================
--- /odp2wts/odp2wts.py Mon Sep 26 00:58:04 2011
+++ /odp2wts/odp2wts.py Thu Sep 29 22:45:26 2011
@@ -22,16 +22,16 @@
20110917 Write out bits of Question/Answer/Response

img1.png > img1.htm > img1.mp3
-[questions=on]
+[questions=on]
How many slides have we seen? > q/img1q1.htm > q/img1q1.mp3
-One ;; > q/img1q1a1.mp3
+One ;; > q/img1q1a1.mp3
Two ;; > q/img1q1a1.mp3

What slide is next? > q/img1q2.htm > q/img1q2.mp3
Third ;; > q/img1q2a1.mp3
Fourth; No, just the third. > q/img1q2a2.mp3, > q/img1q2r2.mp3

-[questions=off]
+[questions=off]
"""
__version__ = "0.1.22"

@@ -164,7 +164,7 @@
easygui.msgbox("Need slide image files for this presentation\n"+
"with consistent stem: Slide* or img*\n\nCheck
in "+odpFileSubdirectory)
sys.exit()
-
+
## Step 1 - parse the .odp file, prepare script.txt and .zip file

def joinContents(textPList):
@@ -510,23 +510,39 @@
onImg = minNum
onImgStr = str(onImg)
onQ = 0
+ oggList = []
for position, question in enumerate(sequence):

# write convert.bat
if len(question.answers)==0:
convertItem(f," ".join(question.questionTexts),onImgStr)
+ oggList.append(onImgStr)
onImg += 1
onImgStr = str(onImg)
onQ = 0
else:
onQ += 1

convertItem(f," ".join(question.questionTexts),onImgStr+"q"+str(onQ))
+ oggList.append(onImgStr+"q"+str(onQ))
onAns = 0
for answer in question.answers:

convertItem(f,answer.answerText,onImgStr+"q"+str(onQ)+"a"+str(onAns))
+ oggList.append(onImgStr+"q"+str(onQ)+"a"+str(onAns))
if len(answer.responseText)>0:

convertItem(f,answer.responseText,onImgStr+"q"+str(onQ)+"r"+str(onAns))
+ oggList.append(onImgStr+"q"+str(onQ)+"r"+str(onAns))
onAns += 1
+
+ # Write concatenation of all .ogg files into all.ogg
+ f.write('cd "'+odpFileSubdirectory+'"\n')
+ if sys.platform.startswith("win"):
+ f.write('"'+savePath+os.sep+'sox.exe" ')
+ else:
+ f.write("~/bin/sox ")
+ for item in oggList:
+ f.write(imageFilePrefix+item+".ogg ")
+ f.write('"'+savePath+os.sep+'silence.ogg" ')
+ f.write("all.ogg\n")
f.close()

def fetchAudioFileTimes():
@@ -757,7 +773,7 @@
if retcode:
print "No time available"
times.append(float(output[0].strip()))
-
+
# Create makeVid.bat in odpFileDirectory for Windows
f = open(odpFileDirectory+os.sep+"makeVid.bat","w")
os.chmod(odpFileDirectory+os.sep+"makeVid.bat",stat.S_IRWXU)
=======================================
--- /odp2wts/scriptParser.py Mon Sep 26 00:58:04 2011
+++ /odp2wts/scriptParser.py Thu Sep 29 22:45:26 2011
@@ -5,11 +5,12 @@
# Author: John Graves
#
# Created: 17 April 2011
-# Modified: 13 September 2011
+# Modified: 29 September 2011
# Copyright: (c) John 2011
# Licence: MIT license

#-------------------------------------------------------------------------------
from BeautifulSoup import BeautifulSoup
+import codecs
import htmlentitydefs
import objects
import os
@@ -120,7 +121,7 @@
else:
return None

- f = open('debug.txt','w')
+ f = codecs.open('debug.txt', encoding='utf-8',mode='w')
f.write("test run at " + strftime("%d %b %Y %H:%M", gmtime()) + "\n")
f.write(str(type(urlText))+ "\n")
f.write(str(len(urlText))+ "\n")
@@ -134,12 +135,12 @@
def parseTxtFile(name):
# open txt file
try:
- f = open(name)
+ f = codecs.open(name, encoding='utf-8')
except:
# No parsing of .txt
return None
text = f.readlines()
-
+
# if not sys.platform.startswith("win"):
# # find slide images in .txt file and make symbolic links if
possible
# pngs = [item.strip() for item in text if item.endswith(".png\n")]
@@ -154,7 +155,7 @@
# subprocess.Popen(["rm",png])
# subprocess.Popen(["ln","-s",scriptDir+os.sep+png,png])
# os.chdir(savePath)
-
+
sequence = parseText(text)
return sequence

@@ -285,7 +286,7 @@

def dumpSequence(seq, questionMode):
if True:
- f = open('debug2.txt','w')
+ f = codecs.open('debug2.txt', encoding='utf-8', mode='w')
f.write("test run at " + strftime("%d %b %Y %H:%M", gmtime()))
f.write("\nquestionMode is "+ str(questionMode))
for i, q in enumerate(seq.sequence):

Reply all
Reply to author
Forward
0 new messages