Revision: ac532a1a8f40
Author: John Graves
Date: Thu Nov 3 20:13:18 2011
Log: Fixed bug with IE not playing question responses
http://code.google.com/p/open-allure-ds/source/detail?r=ac532a1a8f40
Modified:
/odp2wts/odp2wts.py
/wikitospeech/BeautifulSoup.pyc
/wikitospeech/objects.pyc
/wikitospeech/scriptParser.py
/wikitospeech/scriptParser.pyc
/wikitospeech/voice.pyc
=======================================
--- /odp2wts/odp2wts.py Sun Oct 2 02:19:15 2011
+++ /odp2wts/odp2wts.py Thu Nov 3 20:13:18 2011
@@ -33,11 +33,11 @@
[questions=off]
"""
-__version__ = "0.1.24"
+__version__ = "0.1.25"
import BeautifulSoup
from BeautifulSoup import BeautifulStoneSoup
-from configobj import ConfigObj
+from ConfigParser import ConfigParser
import codecs
import easygui
import math
@@ -88,15 +88,15 @@
# Check for last .odp file in config file
lastOdpFile = '~/*.odp'
+config = ConfigParser()
try:
- config = ConfigObj(iniDirectory+os.sep+'odp2wts.ini'),
- lastOdpFile = config['Files']['lastOdpFile']
+ config.read(iniDirectory+os.sep+'odp2wts.ini')
+ lastOdpFile = config.get("Files","lastOdpFile")
except:
- config = ConfigObj()
- config.filename = iniDirectory+os.sep+'odp2wts.ini'
- config['Files'] = {}
- config['Files']['lastOdpFile'] = lastOdpFile
- config.write()
+ config.add_section("Files")
+ config.set("Files","lastOdpFile","")
+ with open(iniDirectory+os.sep+'odp2wts.ini', 'wb') as configfile:
+ config.write(configfile)
if not os.path.isfile(lastOdpFile):
lastOdpFile = None
@@ -250,8 +250,9 @@
if ((0 != len(odpFile)) and (os.path.exists(odpFilePath))):
# Save file name to config file
- config['Files']['lastOdpFile'] = lastOdpFile
- config.write()
+ config.set("Files","lastOdpFile",odpFilePath)
+ with open(iniDirectory+os.sep+'odp2wts.ini', 'wb') as configfile:
+ config.write(configfile)
odpName = odpFile.replace(".odp","")
odp = ZipFile(odpFilePath,'r')
@@ -341,23 +342,7 @@
f.write('del '+imageFilePrefix+onImgStr+'.wav\n')
else:
# For Mac OSX
-# f.write("/usr/bin/say -o "+imageFilePrefix+onImgStr+'.aiff "')
-# lines = item.split("\n")
-# for linenum, line in enumerate(lines):
-# line.replace('"',' ').replace('`',' ').replace(';',' ')
-# if not line.startswith("["):
-# f.write(line+" ")
-# elif linenum>0:
-# break
-# # f.write(item)
-# f.write('"\n')
-# f.write("~/bin/sox "+imageFilePrefix+onImgStr+'.aiff "'+
-# odpFileSubdirectory+os.sep+imageFilePrefix+onImgStr+'.ogg"\n')
-# f.write("~/bin/sox "+imageFilePrefix+onImgStr+'.aiff "'+
-# odpFileSubdirectory+os.sep+imageFilePrefix+onImgStr+'.mp3"\n')
-# f.write("rm "+imageFilePrefix+onImgStr+'.aiff\n')
-
- f.write("swift -n Marta -e utf-8 -m text
-o "+imageFilePrefix+onImgStr+'.wav "')
+ f.write("/usr/bin/say -o "+imageFilePrefix+onImgStr+'.aiff "')
lines = item.split("\n")
for linenum, line in enumerate(lines):
line.replace('"',' ').replace('`',' ').replace(';',' ')
@@ -367,17 +352,17 @@
break
# f.write(item)
f.write('"\n')
- f.write("~/bin/sox "+imageFilePrefix+onImgStr+'.wav "'+
+ f.write("~/bin/sox "+imageFilePrefix+onImgStr+'.aiff "'+
odpFileSubdirectory+os.sep+imageFilePrefix+onImgStr+'.ogg"\n')
- f.write("~/bin/sox "+imageFilePrefix+onImgStr+'.wav "'+
+ f.write("~/bin/sox "+imageFilePrefix+onImgStr+'.aiff "'+
odpFileSubdirectory+os.sep+imageFilePrefix+onImgStr+'.mp3"\n')
- f.write("rm "+imageFilePrefix+onImgStr+'.wav\n')
+ f.write("rm "+imageFilePrefix+onImgStr+'.aiff\n')
def writeHtmlHeader(htmlFile):
htmlFile.write('<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01
Transitional//EN"' + "\n")
htmlFile.write('"
http://www.w3.org/TR/html4/transitional.dtd">' + "\n")
htmlFile.write("<html>\n<head>\n")
- htmlFile.write('<meta http-equiv="Content-Type" content="text/html;
charset=utf-8">' + "\n")
+ htmlFile.write('<meta HTTP-EQUIV=CONTENT-TYPE CONTENT="text/html;
charset=utf-8">' + "\n")
htmlFile.write('<title>Wiki-to-Speech</title>\n')
def writeHtmlHeader2(htmlFile):
@@ -431,38 +416,41 @@
audioFileTimes):
"""
<script language="javascript" type="text/javascript">
+ var t;
function respond0()
{
- document.getElementById('a0').innerHTML = 'Third'
- document.getElementById('a0').style.color = 'grey';
- location.href = "img3.htm"
+ clearTimeout(t)
+ document.getElementById("a0").innerHTML = "Separators of plus
and quotes";
+ document.getElementById("a0").style.color = "grey";
+ document.getElementById('playaudio').innerHTML='<audio
controls autoplay><source src="img8q1r0.mp3" /><source src="img8q1r0.ogg"
/>Your browser does not support the <code>audio</code>
element.</audio><!--[if lte IE 8]><embed src="img8q1r0.mp3"
autostart="true"><![endif]-->';
}
function respond1()
{
- document.getElementById('a1').innerHTML = 'Fourth'
- document.getElementById('a1').style.color = 'grey';
- document.getElementById('playaudio').innerHTML = '<audio
controls autoplay><source src="img2q2r1.mp3" /><source src="img2q2r1.ogg"
/>Your browser does not support the <code>audio</code> element.</audio>'
- var t=setTimeout("advance1()",2000);
- }
- function advance1() {
- location.href = "img3.htm"
+ clearTimeout(t)
+ document.getElementById('playaudio').innerHTML='<audio
controls autoplay><source src="img8q1r1.mp3" /><source src="img8q1r1.ogg"
/>Your browser does not support the <code>audio</code>
element.</audio><!--[if lte IE 8]><embed src="img8q1r1.mp3"
autostart="true"><![endif]-->';
+ t=setTimeout("advance1()",12762);
+ }
+ function advance1()
+ {
+ location.href="img8q2.htm";
}
</script>
"""
- htmlFile.write('<script language="javascript"
type="text/javascript">\n')
+ htmlFile.write('<script language="javascript"
type="text/javascript">\nvar t;\n')
for answerNum, answer in enumerate(question.answers):
if len(answer.answerText)>0:
htmlFile.write('function respond'+
str(answerNum)+
- '()\n{\n')
- htmlFile.write(' document.getElementById("a'+
- str(answerNum)+'").innerHTML = "'+
- answer.answerText+
- '";\n')
- htmlFile.write(' document.getElementById("a'+
- str(answerNum)+
- '").style.color = "grey";\n')
+ '()\n{\n clearTimeout(t);\n')
+ if not answer.action > 0:
+ htmlFile.write(' document.getElementById("a'+
+ str(answerNum)+'").innerHTML = "'+
+ answer.answerText+
+ '";\n')
+ htmlFile.write(' document.getElementById("a'+
+ str(answerNum)+
+ '").style.color = "grey";\n')
if len(answer.responseText)>0:
if position==0:
@@ -479,9 +467,12 @@
pathToAudio +
'.ogg" />')
htmlFile.write( \
- "Your browser does not support the <code>audio</code>
element.</audio>';\n")
+ "<embed src=" +
+ '"' + pathToAudio +
+ '.mp3' +
+ '" autostart="true"></audio>' + "';\n")
if answer.action > 0:
- htmlFile.write(' var t=setTimeout("advance'+
+ htmlFile.write(' t=setTimeout("advance'+
str(answerNum)+
'()",'+
str(audioFileTimes[pathToAudio]+1000)+
@@ -556,10 +547,7 @@
f.write("~/bin/sox ")
for item in oggList:
f.write(imageFilePrefix+item+".ogg ")
- if sys.platform.startswith("win"):
- f.write('"'+savePath+os.sep+'silence.ogg" ')
- else:
- f.write('"'+savePath+os.sep+'silence22kHz.ogg" ')
+ f.write('"'+savePath+os.sep+'silence.ogg" ')
f.write("all.ogg\n")
f.close()
=======================================
--- /wikitospeech/BeautifulSoup.pyc Wed Aug 24 19:13:11 2011
+++ /wikitospeech/BeautifulSoup.pyc Thu Nov 3 20:13:18 2011
Binary file, no diff available.
=======================================
--- /wikitospeech/objects.pyc Wed Aug 24 19:13:11 2011
+++ /wikitospeech/objects.pyc Thu Nov 3 20:13:18 2011
Binary file, no diff available.
=======================================
--- /wikitospeech/scriptParser.py Mon Sep 26 00:58:04 2011
+++ /wikitospeech/scriptParser.py Thu Nov 3 20:13:18 2011
@@ -139,7 +139,7 @@
# 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 +154,7 @@
subprocess.Popen(["rm",png])
subprocess.Popen(["ln","-s",scriptDir+os.sep+png,png])
os.chdir(savePath)
-
+
sequence = parseText(text)
return sequence
@@ -188,7 +188,7 @@
questionMode = False
continue
elif parameterName == "path":
- if(not parameterValue.endswith(os.sep)):
+ if((not parameterValue.endswith(os.sep) or (not
parameterValue.endswith("\\")))):
parameterValue += os.sep
pathToImageFiles = parameterValue
question.pathToImageFiles = pathToImageFiles
=======================================
--- /wikitospeech/scriptParser.pyc Wed Aug 24 19:13:11 2011
+++ /wikitospeech/scriptParser.pyc Thu Nov 3 20:13:18 2011
@@ -1,5 +1,6 @@
Ñò
-SžUNc @ s´ d d k l Z d d k Z d d k Z d d k Z d d k Z d d k l Z l Z d „ Z d „ Z
d „ Z
+A ®Nc @ sØ d d k l Z d d k Z d d k Z d d k Z d d k Z d d k Z d d k Z d d k Z d d k l
Z
l
+ Z
d „ Z d „ Z d „ Z
d
„ Z e d j o e d ƒ n d S(
@@ -64,8 +65,11 @@
t } qx qx q× | d j o | } | | _ qx q× qÞ | d | i d
ƒ !| _ qâ | i
ƒ } | t j o× t | ƒ d j oÀ | i d ƒ pP | i d ƒ p@ |
i d ƒ p0 | i d ƒ p | i d ƒ p | i d ƒ oL t |
i ƒ d j o) | i i
+t statict .s .pngt rmt lns -s( R8 R t
readlinest syst platformR R R; R" t pathR* t getcwdt chdirt listdirt
| ƒ t i ƒ } | | _ n | | _ qÇ | i i
| ƒ qÞ qâ t | ƒ d j oÁ | i d ƒ p0 | i d ƒ p |
i d ƒ p | i d ƒ oL t | i ƒ d j o) | i i
+ 5
+ ( c C s | d i ƒ i d ƒ p | d i d ƒ o
| ƒ t i ƒ } | | _ n | | _ qÞ | i d ƒ }
d |
j o | i i
@@ -75,6 +79,8 @@
d i
ƒ } t | ƒ d j o‹ x4 | i d ƒ o# | i d 7 _ | d i
ƒ } qÚ W| i d ƒ o7 | i d
+ | d j oL | i t i ƒ p | i d ƒ o | t i 7} n |
} | | _ qx q
+ q | d | i d
ƒ } | d | !| _ | | d i
ƒ } n | | _ n | i d j o
d | _ n | i i
@@ -83,7 +89,20 @@
| ƒ n g }
| i D] } |
| i i ƒ q
- ~
+ !i
+ ƒ | _ | |
+ d i
+ ƒ } t | ƒ d j o‹ x4 | i d ƒ o# | i d 7 _ | d i
+ ƒ } q W| i d ƒ o7 | i d
+ ƒ } | d | !| _ | | d i
+ ƒ } n | | _ n | i d j o
+ d | _ n | i i
+ | ƒ t i ƒ } q t | i ƒ d j o) | i i
+ | ƒ t i ƒ } | | _ q qx qx Wt | i ƒ d j o | i i
+ | ƒ n g }
+ | i D] } |
+ | i i ƒ qT ~
+ } x t | i ƒ D]p \ } } xa | i D]V } | i d j o@ |
i i ƒ | j o& | i | i ƒ | | _ d | _ qï q™ q™ Wqƒ Wt |
| ƒ | i S( Ni s .pngs [path=R
} x t | i ƒ D]p \ } } xa | i D]V } | i d j o@ |
i i ƒ | j o& | i | i ƒ | | _ d | _ q¹ qc qc WqM Wt |
| ƒ | i S( Ni s .pngs [path=R
t #t [t ;t =i t ]t
questionst ont offt pathR s .htmls .jpgs .JPGs .PNGiÿÿÿÿs [next]( t lowerR R t FalseR6 t objectst SequenceR t Questiont AnswerR; R) t
questionTextst appendt pathToImageFilesR t tagt
@@ -98,7 +117,7 @@
-
+ %
@@ -127,10 +146,10 @@
responseSideLinks
responseTexts
action( R6 R8 R9 R R R' R\ R RU RV RT RR R[ RW RY RZ RX R< ( R` R_ R@ t it qRA t jt a( ( s, D:\open-allure-ds\openallure\scriptParser.pyR^
s(
+ s(
" " " 0 t __main__s
20110819b.txt( R RN R" R
R$ t timeR R R R R R R R+ R^ t __name__( ( ( s, D:\open-allure-ds\openallure\scriptParser.pyt <module> s
-
- % {
+ % }
=======================================
--- /wikitospeech/voice.pyc Wed Aug 24 19:13:11 2011
+++ /wikitospeech/voice.pyc Thu Nov 3 20:13:18 2011
@@ -1,5 +1,5 @@
Ñò
-SžUNc @ s{ d Z d d k Z d d k Z d d k Z d d k l Z l Z d e f d „ ƒ YZ d „ Z
e
+ݾƒNc @ s{ d Z d d k Z d d k Z d d k Z d d k l Z l Z d e f d „ ƒ YZ d „ Z
e
d j o e ƒ n d S( sŒ
voice.py
a component of openallure.py