Mercurial > hg > env-test-daniele
changeset 22:8498a7b84ff1
• Audio files
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/cherryFxTest.py.orig Mon Mar 11 13:35:29 2013 +0000 @@ -0,0 +1,420 @@ + +import cherrypy, os, random, smtplib, string +from cherrypy.lib.static import serve_file +from templates import * + +from DirectorySession import DirectorySession +from ServerWrapper import ServerWrapper as CherryPyServer +from ServerWrapper import Config as ServerConfig + +from email.MIMEBase import MIMEBase +from email.MIMEText import MIMEText +from email.MIMEMultipart import MIMEMultipart +from email.Utils import COMMASPACE, formatdate +from email import Encoders + +from pprint import pprint + +PATH = os.path.abspath(os.path.dirname(__file__)) + +#audiodir = './audio' +#cherrypy.session['fxs'] = [cherrypy.session['f'] for cherrypy.session['f'] in os.listdir(audiodir) if os.path.isdir(os.path.join(audiodir, cherrypy.session['f']))] +#cherrypy.session['fxs'].remove('dry') +#print cherrypy.session['fxs'] + +class Root(object): pass + + +class HomePage: + def index(self): + + return "move along, nothing to see here!" + + index.exposed = True + + + +class TestPage: + + def getAASPFiles(self): + audioDir = './AASPAudio' + cherrypy.session['cats'] = [cherrypy.session['f'] for cherrypy.session['f'] in os.listdir(audioDir) if os.path.isdir(os.path.join(audioDir,cherrypy.session['f']))] + print cherrypy.session['cats'] + + def index(self): + TestPage.getAASPFiles(self) + cherrypy.session['sid'] = None + + cherrypy.session['sid_filename'] = None + + + if cherrypy.request.headers.has_key("X-Forwarded-For"): + cherrypy.session['ip'] = cherrypy.request.headers["X-Forwarded-For"] + elif cherrypy.request.headers.has_key("Remote-Addr"): + cherrypy.session['ip'] = cherrypy.request.headers["Remote-Addr"] + else : + cherrypy.session['ip'] = None + + cherrypy.session['test'] = None + cherrypy.session['results'] = None + cherrypy.session['tests'] = None + cherrypy.session['test_nr'] = None + cherrypy.session['audio'] = None + cherrypy.session['page'] = 0 + cherrypy.session['pages'] = 6 + cherrypy.session['userinfobox'] = None + cherrypy.session['ts'] = None + #return ''' + # <p> + # <a href="/test/">start test</a> + # </p>''' + + #take 2 examples for each effect + + cherrypy.session['audio'] = [] + + # get effected files: + cherrypy.session['audio'] = [] + for cherrypy.session['cat'] in cherrypy.session['cats']: + cherrypy.session['dirlist'] = os.listdir('./AASPAudio/%s/'%cherrypy.session['cat']) + for cherrypy.session['item'] in cherrypy.session['dirlist']: + if cherrypy.session['item'].split('.')[-1] == 'wav': + cherrypy.session['audio'].append(cherrypy.session['cat'] + '/' + cherrypy.session['item'].split('.')[0]) + + + #print TestPage.audio + random.shuffle(cherrypy.session['audio']) + + print "NUMBER OF TESTS:" + print len(cherrypy.session['audio']) + + cherrypy.session['sid'] = cherrypy.session.get_session_path().split('/')[1] + print cherrypy.session['sid'] + + #print cherrypy.session['audio'] + pprint(cherrypy.session['audio']) + + + TestPage.outfileid = '%s' %cherrypy.session['sid'] + ida = 0 + while os.path.exists('./sessions/%s/%s.txt' %(cherrypy.session['sid'], TestPage.outfileid)): + TestPage.outfileid += '_%s' %ida + ida += 1 + + + return welcome_templ %cherrypy.session['sid'] + + + def doStart(self, pageId, sessionId, startButton, uinfo00=None, uinfo01=None, info1=None): + + + + if cherrypy.session['page'] != int(pageId): + print "################################# BACK BUTTON PRESSED #################################" + + + if cherrypy.session['sid'] != str(sessionId): + return TestPage.sessionError(self) + #cherrypy.session['page'] = int(pageId) + + + + + cherrypy.session['userinfobox'] = str([str(uinfo00), str(uinfo01), int(info1)]) + '\n' + cherrypy.session['sessionId'] = sessionId + #print "sid:" + #print TestPage.sid + #print sessionId + if cherrypy.session['sid'] != str(cherrypy.session['sessionId']): + return TestPage.sessionError(self) + else: + return TestPage.index2(self) + + + + def index2(self): + #try: print testvar + #except: pass + + cherrypy.session['page'] = 1 + cherrypy.session['pages'] = 10 + cherrypy.session['tests'] = len(cherrypy.session['audio']) #should be 66 #10 * cherrypy.session['pages'] + cherrypy.session['results'] = [] + for cherrypy.session['n'] in xrange(cherrypy.session['tests']): cherrypy.session['results'].append([None]) + + # create tuple to fill template + cherrypy.session['ts'] = [] + for cherrypy.session['k'] in xrange(10): + cherrypy.session['ts'].append(0) + + return audiotempl%TestPage.makeTuple(self, 10) + + def doAttrib(self, pageId, sessionId, submitButton, attribute1=None, attribute2=None, attribute3=None, attribute4=None, attribute5=None, attribute6=None, attribute7=None, attribute8=None, attribute9=None, attribute10=None): + #print attribute1 + ' ' + attribute2 + # Error check + + print "################################# %s" %pageId + #_pageId = int(pageId) - 1 + + if cherrypy.session['page'] != int(pageId): + print "################################# BACK BUTTON PRESSED #################################" + + cherrypy.session['page'] = int(pageId) + + if cherrypy.session['sid'] != str(sessionId): + return TestPage.sessionError(self) + + #store results + + cherrypy.session['pos'] = 10 * (cherrypy.session['page'] - 1) + + cherrypy.session['results'][cherrypy.session['pos']] = [cherrypy.session['audio'][cherrypy.session['pos']][2].split('/')[-1], int(attribute1)] + cherrypy.session['results'][cherrypy.session['pos']+1] = [cherrypy.session['audio'][cherrypy.session['pos']+1][2].split('/')[-1], int(attribute2)] + cherrypy.session['results'][cherrypy.session['pos']+2] = [cherrypy.session['audio'][cherrypy.session['pos']+2][2].split('/')[-1], int(attribute3)] + cherrypy.session['results'][cherrypy.session['pos']+3] = [cherrypy.session['audio'][cherrypy.session['pos']+3][2].split('/')[-1], int(attribute4)] + cherrypy.session['results'][cherrypy.session['pos']+4] = [cherrypy.session['audio'][cherrypy.session['pos']+4][2].split('/')[-1], int(attribute5)] + cherrypy.session['results'][cherrypy.session['pos']+5] = [cherrypy.session['audio'][cherrypy.session['pos']+5][2].split('/')[-1], int(attribute6)] + cherrypy.session['results'][cherrypy.session['pos']+6] = [cherrypy.session['audio'][cherrypy.session['pos']+6][2].split('/')[-1], int(attribute7)] + cherrypy.session['results'][cherrypy.session['pos']+7] = [cherrypy.session['audio'][cherrypy.session['pos']+7][2].split('/')[-1], int(attribute8)] + cherrypy.session['results'][cherrypy.session['pos']+8] = [cherrypy.session['audio'][cherrypy.session['pos']+8][2].split('/')[-1], int(attribute9)] + cherrypy.session['results'][cherrypy.session['pos']+9] = [cherrypy.session['audio'][cherrypy.session['pos']+9][2].split('/')[-1], int(attribute10)] + + + resString = cherrypy.session['ip'] + '\n' + TestPage.outfileid + '\n' + cherrypy.session['userinfobox'] + '\n' + ',\n'.join(str(x) for x in cherrypy.session['results']) + + #f = open(TestPage.sid_filename, 'w') + #f.write(resString) + #f.close() + + cherrypy.session.write_data(resString,'%s.txt'%TestPage.outfileid) + + #if cherrypy.session['page'] < cherrypy.session['pages'] - 1: + cherrypy.session['page'] += 1 + # create tuple to fill template + cherrypy.session['ts'] = [] + cherrypy.session['npos'] = cherrypy.session['pos'] + 10 + + if cherrypy.session['page'] < cherrypy.session['pages']: + cherrypy.session['m'] = 10 + else: + cherrypy.session['m'] = 6 + + for cherrypy.session['k'] in xrange(cherrypy.session['m']): + for cherrypy.session['i'] in xrange(4): + #print cherrypy.session['k'] + #print cherrypy.session['i'] + cherrypy.session['ts'].append(cherrypy.session['results'][cherrypy.session['npos']+cherrypy.session['k']][cherrypy.session['i']+1]) + + return audiotempl%TestPage.makeTuple(self, cherrypy.session['m']) + + + index.exposed = True + doAttrib.exposed = True + index2.exposed = True + doStart.exposed = True + + + def doAttrib2(self, pageId, sessionId, submitButton, attribute1=None, attribute2=None, attribute3=None, attribute4=None, attribute5=None, attribute6=None): + #print attribute1 + ' ' + attribute2 + # Error check + + print "################################# %s" %pageId + #_pageId = int(pageId) - 1 + + if cherrypy.session['page'] != int(pageId): + print "################################# BACK BUTTON PRESSED #################################" + + cherrypy.session['page'] = int(pageId) + + if cherrypy.session['sid'] != str(sessionId): + return TestPage.sessionError(self) + + #store results + + cherrypy.session['pos'] = 10 * (cherrypy.session['page'] - 1) + + cherrypy.session['results'][cherrypy.session['pos']] = [cherrypy.session['audio'][cherrypy.session['pos']][2].split('/')[-1], int(attribute1)] + cherrypy.session['results'][cherrypy.session['pos']+1] = [cherrypy.session['audio'][cherrypy.session['pos']+1][2].split('/')[-1], int(attribute2)] + cherrypy.session['results'][cherrypy.session['pos']+2] = [cherrypy.session['audio'][cherrypy.session['pos']+2][2].split('/')[-1], int(attribute3)] + cherrypy.session['results'][cherrypy.session['pos']+3] = [cherrypy.session['audio'][cherrypy.session['pos']+3][2].split('/')[-1], int(attribute4)] + cherrypy.session['results'][cherrypy.session['pos']+4] = [cherrypy.session['audio'][cherrypy.session['pos']+4][2].split('/')[-1], int(attribute5)] + cherrypy.session['results'][cherrypy.session['pos']+5] = [cherrypy.session['audio'][cherrypy.session['pos']+5][2].split('/')[-1], int(attribute6)] + + + + resString = cherrypy.session['ip'] + '\n' + cherrypy.session['sid'] + '\n' + cherrypy.session['userinfobox'] + '\n' + ',\n'.join(str(x) for x in cherrypy.session['results']) + + #f = open(TestPage.sid_filename, 'w') + #f.write(resString) + #f.close() + #os.path.exists() + + cherrypy.session.write_data(resString,'%s.txt'%TestPage.outfileid) + + + print cherrypy.session['results'] + #_results = [] + + cherrypy.session['templ'] = '' + for cherrypy.session['n'] in xrange(cherrypy.session['tests']): + #print ">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>" + #print cherrypy.session['n'] + cherrypy.session['_templ'] = endtempl2 %(cherrypy.session['results'][cherrypy.session['n']][0], cherrypy.session['results'][cherrypy.session['n']][1], cherrypy.session['results'][cherrypy.session['n']][2], cherrypy.session['results'][cherrypy.session['n']][3], cherrypy.session['results'][cherrypy.session['n']][4]) + cherrypy.session['templ'] += cherrypy.session['_templ'] + + #TestPage.pageComplete += 1 + try: + #print 'skipping email' + TestPage.sendMail(self) + except: + print "WARNING: COULD NOT SEND RESULTS" + pass + cherrypy.session['sid'] = None + return endtempl%cherrypy.session['templ'] + #return lastpage + + + index.exposed = True + doAttrib.exposed = True + doAttrib2.exposed = True + index2.exposed = True + doStart.exposed = True + + + def makeTuple(TestPage, nr): + cherrypy.session['nr'] = nr + cherrypy.session['ts'].append(cherrypy.session['page']) + cherrypy.session['ts'].append(cherrypy.session['pages']) + for cherrypy.session['k'] in xrange(cherrypy.session['nr']): + pos = 10 * (cherrypy.session['page'] - 1) + cherrypy.session['k'] + #print pos + cherrypy.session['ts'].append(cherrypy.session['audio'][pos]) + cherrypy.session['ts'].append(cherrypy.session['page']) + cherrypy.session['ts'].append(cherrypy.session['sid']) + cherrypy.session['ts'] = tuple(cherrypy.session['ts']) + print cherrypy.session['ts'] + return cherrypy.session['ts'] + + def sessionError(TestPage): + print "################################# SESSION ERROR #################################" + cherrypy.session['resString'] = cherrypy.session['ip'] + '\n' + str(cherrypy.session['sid']) + '\n' + cherrypy.session['userinfobox'] + '\n' + ',\n'.join(str(x) for x in cherrypy.session['results']) + cherrypy.session['resString'] += '\n\nERROR: SESSION CONFUSION' + #f = open(TestPage.sid_filename, 'w') + #f.write(resString) + #f.close() + cherrypy.session.write_data(cherrypy.session['resString'],'%s.txt'%TestPage.outfileid) + + return ''' + <p> + <a href="/test/">oh noes! there is something wrong with your session, please start again or go for a coffee!</a> + </p>''' + + + def sendMail(TestPage): + cherrypy.session['file'] = './sessions/%s/%s.txt'%(cherrypy.session['sid'], TestPage.outfileid) + username = 'eecsqmul@gmail.com' + password = 'perceptual' + fro = 'FX-Test <eecsqmul@gmail.com>' + to = ['thomas.wilmering@eecs.qmul.ac.uk', 'gyorgy.fazekas@eecs.qmul.ac.uk'] + msg = MIMEMultipart() + msg['From'] = fro + msg['To'] = COMMASPACE.join(to) + msg['Date'] = formatdate(localtime=True) + msg['Subject'] = 'fx perceptual listening test' + msg.attach( MIMEText('Attached are new results from the listening test.')) + part = MIMEBase('application', "octet-stream") + part.set_payload( open(cherrypy.session['file'],"rb").read() ) + Encoders.encode_base64(part) + part.add_header('Content-Disposition', 'attachment; filename="%s"' % cherrypy.session['file']) + msg.attach(part) + server = smtplib.SMTP('smtp.gmail.com:587') + server.starttls() + server.login(username,password) + server.sendmail(fro, to, msg.as_string() ) + server.close() + + +class OutPage: + def index(self): + return ''' + <html> + <body> + <div id="video"> + <embed id="roll-video" src="http://www.dafk.net/what/ilovethe80s.swf" width="400" height="300"></embed> + </div> + </body> + </html> + + ''' + index.exposed = True + + +# # Of course we can also mount request handler objects right here! +# root = HomePage() +# root.test = TestPage() +# root.out = OutPage() +# #root = TestPage() +# +# tutconf = os.path.join(os.path.dirname(__file__), 'conf.conf') + + +def startFxTest(args): + + # check local switch + if args.count('-local') : + local = True; args.remove('-local'); + print 'Startup: Local mode.' + conf = os.path.join(os.path.dirname(__file__), 'local.conf') + else: + conf = os.path.join(os.path.dirname(__file__), 'server.conf') + local = False + + # check string encoding + print "Startup: String encoding = '%s'" %(str(sys.getdefaultencoding())) + + # check ip switch + ip = '' + if args.count('-ip') : + try : + # here we just see if it's numeric, parsing is done by the server wrapper + if args[args.index('-ip')+1].replace('.','').replace(':','').isdigit() : + ip = args[args.index('-ip')+1] + else : + print "Startup: Invalid service IP address. Use format: sawa.py -ip 127.0.0.1:8080" + os._exit(-1) + except : + print "Startup: Invalid service IP address. (Insufficient arguments.) Use format: cherryFxTest.py -ip 127.0.0.1:8080" + os._exit(-1) + args.remove(args[args.index('-ip')+1]); + args.remove('-ip') + + + # old command: + # cherrypy.quickstart(root, config=conf) + + # Of course we can also mount request handler objects right here! + root = HomePage() + root.test = TestPage() + root.daniele = TestPage() + root.out = OutPage() + #root = TestPage() + + server = CherryPyServer(ServerConfig(root=root,local=local,conf=conf)) + # if local : + # server = CherryPyServer(ServerConfig(root=root,local=local,conf=conf)) + # else : + # server = CherryPyServer(ServerConfig(root=False,local=local,conf=conf)) + server.mount(root,path_name='') + server.quickstart(ip) + + +if __name__ == '__main__': + # CherryPy always starts with app.root when trying to map request URIs + # to objects, so we need to mount a request handler root. A request + # to '/' will be mapped to HelloWorld().index(). + # cherrypy.quickstart(root, config=tutconf) + import sys + startFxTest(sys.argv[1:]) +else: + # This branch is for the test suite; you can ignore it. + cherrypy.tree.mount(root, config=tutconf) \ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/templates.py.orig Mon Mar 11 13:35:29 2013 +0000 @@ -0,0 +1,448 @@ + +audiotempl= ''' + +<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> +<html xmlns="http://www.w3.org/1999/xhtml"> + +<html lang="en" dir="ltr"> + +<head> + <meta http-equiv="Content-Type" content="text/html; charset=utf-8;charset=utf-8" > + <link rel="stylesheet" type="text/css" href="../htempl/barrensa.css" TITLE="combined" /> + <link rel="stylesheet" href="../build/mediaelementplayer.min.css" TITLE="combined"> + <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> + <title>Digital Audio FX Perceptual Attributes</title> + + <script src="../build/jquery.js"></script> + <script src="../build/mediaelement-and-player.min.js"></script> + + + <script language = "JavaScript"> + + window.onload = function () { + document.getElementById("a1")[%i].selected = true; + document.getElementById("a2")[%i].selected = true; + document.getElementById("a3")[%i].selected = true; + document.getElementById("a4")[%i].selected = true; + document.getElementById("a5")[%i].selected = true; + document.getElementById("a6")[%i].selected = true; + document.getElementById("a7")[%i].selected = true; + document.getElementById("a8")[%i].selected = true; + document.getElementById("a9")[%i].selected = true; + document.getElementById("a10")[%i].selected = true; + } + + </script> + + <script language="JavaScript" src="../js/gen_validatorv4.js" + type="text/javascript" xml:space="preserve"></script> + +</head> + +<body> + +<div id="mainPicture"> + <div class="picture"> + <div id="headerTitle">Digital Audio FX</div> + <div id="headerSubtext">Perceptual Attributes Listening Test</div> + </div> + </div> + <div class="contentBox"> + + + + + <h3 id="test 1">%i/%i</h3><br> + <h4>Please play the sounds and indicate where they have been recorded </h4> + +<form name="attributes" action="doAttrib" method="POST"> + +<audio id="audio player 1" controls> + <source src="/Users/daniele/Documents/AASPChallenge/survey/AASPAudio/%s.wav" type="audio/wav"> +</audio> + +<div class="selects"> +main:<img width=1px height=0px src='/images/spacer.gif'> +<select name="attribute1" id="a1"> + <option value="0"></option> + <option value="1">bus</option> + <option value="2">busy street</option> + <option value="3">office</option> + <option value="4">open air market</option> + <option value="5">park</option> + <option value="6">quiet street</option> + <option value="7">restaurant</option> + <option value="8">supermarket</option> + <option value="9">tube</option> + <option value="10">tube station</option> +</select> +</div> + +<br> + +<audio id="audio player 2" controls> + <source src="/Users/daniele/Documents/AASPChallenge/survey/AASPAudio/%s.wav" type="audio/wav"> +</audio> + +<div class="selects"> +<p>main:<img width=1px height=0px src='/images/spacer.gif'> +<select name="attribute2" id="a2"> + <option value="0"></option> + <option value="1">bus</option> + <option value="2">busy street</option> + <option value="3">office</option> + <option value="4">open air market</option> + <option value="5">park</option> + <option value="6">quiet street</option> + <option value="7">restaurant</option> + <option value="8">supermarket</option> + <option value="9">tube</option> + <option value="10">tube station</option> +</select> + +</div> +<br> + +<audio id="audio player 3" controls> + <source src="/Users/daniele/Documents/AASPChallenge/survey/AASPAudio/%s.wav" type="audio/wav"> +</audio> + +<div class="selects"> +<p>main:<img width=1px height=0px src='/images/spacer.gif'> +<select name="attribute3" id="a3"> + <option value="0"></option> + <option value="1">bus</option> + <option value="2">busy street</option> + <option value="3">office</option> + <option value="4">open air market</option> + <option value="5">park</option> + <option value="6">quiet street</option> + <option value="7">restaurant</option> + <option value="8">supermarket</option> + <option value="9">tube</option> + <option value="10">tube station</option> +</select> +</div> +<br> + +<audio id="audio player 4" controls> + <source src="/Users/daniele/Documents/AASPChallenge/survey/AASPAudio/%s.wav" type="audio/wav"> +</audio> + +<div class="selects"> +<p>main:<img width=1px height=0px src='/images/spacer.gif'> +<select name="attribute4" id="a4"> + <option value="0"></option> + <option value="1">bus</option> + <option value="2">busy street</option> + <option value="3">office</option> + <option value="4">open air market</option> + <option value="5">park</option> + <option value="6">quiet street</option> + <option value="7">restaurant</option> + <option value="8">supermarket</option> + <option value="9">tube</option> + <option value="10">tube station</option> +</select> +</div> +<br> + +<audio id="audio player 5" controls> + <source src="/Users/daniele/Documents/AASPChallenge/survey/AASPAudio/%s.wav" type="audio/wav"> +</audio> + +<div class="selects"> +<p>main:<img width=1px height=0px src='/images/spacer.gif'> +<select name="attribute5" id="a5"> + <option value="0"></option> + <option value="1">bus</option> + <option value="2">busy street</option> + <option value="3">office</option> + <option value="4">open air market</option> + <option value="5">park</option> + <option value="6">quiet street</option> + <option value="7">restaurant</option> + <option value="8">supermarket</option> + <option value="9">tube</option> + <option value="10">tube station</option> +</select> +</div> +<br> + +<audio id="audio player 6" controls> + <source src="/Users/daniele/Documents/AASPChallenge/survey/AASPAudio/%s.wav" type="audio/wav"> +</audio> + +<div class="selects"> +<p>main:<img width=1px height=0px src='/images/spacer.gif'> +<select name="attribute6" id="a6"> + <option value="0"></option> + <option value="1">bus</option> + <option value="2">busy street</option> + <option value="3">office</option> + <option value="4">open air market</option> + <option value="5">park</option> + <option value="6">quiet street</option> + <option value="7">restaurant</option> + <option value="8">supermarket</option> + <option value="9">tube</option> + <option value="10">tube station</option> +</select> +</div> +<br> + +<audio id="audio player 7" controls> + <source src="/Users/daniele/Documents/AASPChallenge/survey/AASPAudio/%s.wav" type="audio/wav"> +</audio> + +<div class="selects"> +<p>main:<img width=1px height=0px src='/images/spacer.gif'> +<select name="attribute7" id="a7"> + <option value="0"></option> + <option value="1">bus</option> + <option value="2">busy street</option> + <option value="3">office</option> + <option value="4">open air market</option> + <option value="5">park</option> + <option value="6">quiet street</option> + <option value="7">restaurant</option> + <option value="8">supermarket</option> + <option value="9">tube</option> + <option value="10">tube station</option> +</select> +</div> +<br> + +<audio id="audio player 8" controls> + <source src="/Users/daniele/Documents/AASPChallenge/survey/AASPAudio/%s.wav" type="audio/wav"> +</audio> + +<div class="selects"> +<p>main:<img width=1px height=0px src='/images/spacer.gif'> +<select name="attribute8" id="a8"> + <option value="0"></option> + <option value="1">bus</option> + <option value="2">busy street</option> + <option value="3">office</option> + <option value="4">open air market</option> + <option value="5">park</option> + <option value="6">quiet street</option> + <option value="7">restaurant</option> + <option value="8">supermarket</option> + <option value="9">tube</option> + <option value="10">tube station</option> +</select> +</div> +<br> + +<audio id="audio player 9" controls> + <source src="/Users/daniele/Documents/AASPChallenge/survey/AASPAudio/%s.wav" type="audio/wav"> +</audio> + +<div class="selects"> +<p>main:<img width=1px height=0px src='/images/spacer.gif'> +<select name="attribute9" id="a9"> + <option value="0"></option> + <option value="1">bus</option> + <option value="2">busy street</option> + <option value="3">office</option> + <option value="4">open air market</option> + <option value="5">park</option> + <option value="6">quiet street</option> + <option value="7">restaurant</option> + <option value="8">supermarket</option> + <option value="9">tube</option> + <option value="10">tube station</option> +</select> +</div> +<br> + +<audio id="audio player 10" controls> + <source src="/Users/daniele/Documents/AASPChallenge/survey/AASPAudio/%s.wav" type="audio/wav"> +</audio> + +<div class="selects"> +<p>main:<img width=1px height=0px src='/images/spacer.gif'> +<select name="attribute10" id="a10"> + <option value="0"></option> + <option value="1">bus</option> + <option value="2">busy street</option> + <option value="3">office</option> + <option value="4">open air market</option> + <option value="5">park</option> + <option value="6">quiet street</option> + <option value="7">restaurant</option> + <option value="8">supermarket</option> + <option value="9">tube</option> + <option value="10">tube station</option> +</select> +</div> +<br> + + <input type="hidden" name="pageId" value="%i"> + <input type="hidden" name="sessionId" value="%s"> + + <input type="submit" value="submit" name="submitButton"/> + + </form> + + <script language="JavaScript" type="text/javascript" + xml:space="preserve">//<![CDATA[ + var frmvalidator = new Validator("attributes"); + + frmvalidator.addValidation("attribute1","dontselect=0", "Please select at least one main attribute for each item"); + frmvalidator.addValidation("attribute2","dontselect=0", "Please select at least one main attribute for each item"); + frmvalidator.addValidation("attribute3","dontselect=0", "Please select at least one main attribute for each item"); + frmvalidator.addValidation("attribute4","dontselect=0", "Please select at least one main attribute for each item"); + frmvalidator.addValidation("attribute5","dontselect=0", "Please select at least one main attribute for each item"); + frmvalidator.addValidation("attribute6","dontselect=0", "Please select at least one main attribute for each item"); + frmvalidator.addValidation("attribute7","dontselect=0", "Please select at least one main attribute for each item"); + frmvalidator.addValidation("attribute8","dontselect=0", "Please select at least one main attribute for each item"); + frmvalidator.addValidation("attribute9","dontselect=0", "Please select at least one main attribute for each item"); + frmvalidator.addValidation("attribute10","dontselect=0", "Please select at least one main attribute for each item"); + + //]]></script> + + </div> + + </div> + +</body> + +<script> +$('audio,video').mediaelementplayer(); +</script> +</html> +''' + +welcome_templ= ''' + +<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> +<html xmlns="http://www.w3.org/1999/xhtml"> + +<html lang="en" dir="ltr"> + +<head> + <meta http-equiv="Content-Type" content="text/html; charset=utf-8;charset=utf-8" > + <link rel="stylesheet" type="text/css" href="../htempl/barrensa.css"> + <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> + <title>Digital Audio FX Perceptual Attributes</title> + + + + +<script language="JavaScript" src="../js/gen_validatorv4.js" + type="text/javascript" xml:space="preserve"></script> +</head> +<body> + +<div id="mainPicture"> + <div class="picture"> + <div id="headerTitle">Digital Audio FX</div> + <div id="headerSubtext">Perceptual Attributes Listening Test</div> + </div> + </div> + <div class="contentBox"> + + <h2>Welcome!</h2><br /> + + <br /> <br /> + + + +<form name="userinfos" action="doStart" method="POST"> +<div class="selects"> +</p> +Select Username<br /> +<input type="text" name="uinfo00" id="uinfo00" /> +<br /><br /> + +Age<br /> +<select name="uinfo01" id="uinfo01"> + <option value="0"></option> + <option value="1">< 18</option> + <option value="2">18-24</option> + <option value="3">25-34</option> + <option value="4">35-44</option> + <option value="5">45-54</option> + <option value="5">55-64</option> + <option value="6">65-74</option> + <option value="7">> 74</option> +</select> +<br /><br /> +It is encouraged to use high quality headphones for this test. However, if you use loudspeakers instead make sure you're in the correct position between the speakers in order to evaluate stereo effects. Please specify (the closest to) your listening conditions: +<br /> +<select name="info1" id="info1"> + <option value="0"></option> + <option value="1">high quality headphones</option> + <option value="2">low quality headphones</option> + <option value="3">loudspeakers / professional studio</option> + <option value="4">loudspeakers / semi-professional studio</option> + <option value="5">hifi speakers / home</option> +</select> + +<br /> +<br /> +<h4>Please note that HTML5 support is limited on this website and ADOBE FLASH is recommended</h4> +<input type="hidden" name="pageId" value="0"> +<input type="hidden" name="sessionId" value="%s"> +<input type="submit" value="submit" name="startButton"> +</p> +</form> + +<script language="JavaScript" type="text/javascript" + xml:space="preserve">//<![CDATA[ + var frmvalidator = new Validator("userinfos"); + + frmvalidator.addValidation("uinfo00","req","Please select a username"); + frmvalidator.addValidation("uinfo00","maxlen=20", "Max length for username is 20"); + frmvalidator.addValidation("uinfo00","minlen=3", "Min length for username is 3"); + frmvalidator.addValidation("uinfo01","dontselect=0", "Please specify all information"); + + frmvalidator.addValidation("info1","dontselect=0", "Please specify all information"); + +//]]></script> + + +</div> + <br /> +<h3>Thank you for participating in this project!</h3><br /> + + </div> +</body> + +</html> +''' + +endtempl = ''' +<!DOCTYPE html> +<html lang="en" dir="ltr"> +<head> +</head> +<body> +<p>results</p> +<table border="1"> +<tr> +<th>Audio File</th> +<th>Main 1</th> +<th>Main 2</th> +<th>Other 1</th> +<th>Other 2</th> +</tr> +%s +</table> +<p> <a href="http://www.elec.qmul.ac.uk/digitalmusic">thanks!</a> </p> +</body> +</html> +''' +#<p> <a href="/out/">thanks!</a> </p> + +endtempl2 = ''' +<tr> +<td>%s</td> +<td><center>%s</center></td> +<td><center>%s</center></td> +<td><center>%s</center></td> +<td><center>%s</center></td> +</tr> +'''
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/templates_old.py Mon Mar 11 13:35:29 2013 +0000 @@ -0,0 +1,398 @@ +audiotempl= ''' +<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> +<html xmlns="http://www.w3.org/1999/xhtml"> + +<html lang="en" dir="ltr"> + +<head> + <meta http-equiv="Content-Type" content="text/html; charset=utf-8;charset=utf-8" > + <! link rel="stylesheet" type="text/css" href="../htempl/barrensa.css" TITLE="combined" > + <link rel="stylesheet" href="../build/mediaelementplayer.min.css" TITLE="combined"> + <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> + <title>Audio Environment Classification</title> + + <script src="../build/jquery.js"></script> + <script src="../build/mediaelement-and-player.min.js"></script> + + + <script language = "JavaScript"> + + window.onload = function () { + document.getElementById("a1")[%i].selected = true; + document.getElementById("a2")[%i].selected = true; + document.getElementById("a3")[%i].selected = true; + document.getElementById("a4")[%i].selected = true; + document.getElementById("a5")[%i].selected = true; + document.getElementById("a6")[%i].selected = true; + document.getElementById("a7")[%i].selected = true; + document.getElementById("a8")[%i].selected = true; + document.getElementById("a9")[%i].selected = true; + document.getElementById("a10")[%i].selected = true; + } + + </script> + + <script language="JavaScript" src="../js/gen_validatorv4.js" + type="text/javascript" xml:space="preserve"></script> +</head> + +<body> + +<div id="mainPicture"> + <div class="picture"> + <div id="headerTitle">Audio Environment Classification - Listening Test</div> + </div> + </div> + <div class="contentBox"> + + <h3 id="test 1">%i/%i</h3><br> + <h4>Please play the sounds and indicate where they have been recorded </h4> + +<form name="attributes" action="doAttrib" method="POST"> + +<audio id="audio player 1" controls> + <source src="/Users/daniele/Documents/AASPChallenge/survey/AASPAudio/%s.wav" type="audio/wav"> +</audio> + +<form name = "attribute1" id="a1"> +<input type="radio" name="cat" value="bus">bus +<input type="radio" name="cat" value="busy street">busy street +<input type="radio" name="cat" value="office">office +<input type="radio" name="cat" value="open air market">open air market +<input type="radio" name="cat" value="park">park <br> +<input type="radio" name="cat" value="quiet street">quiet street +<input type="radio" name="cat" value="restaurant">restaurant +<input type="radio" name="cat" value="supermarket">supermarket +<input type="radio" name="cat" value="tube">tube +<input type="radio" name="cat" value="tube station">tube station +</form> +<br> + +<audio id="audio player 2" controls> + <source src="/Users/daniele/Documents/AASPChallenge/survey/AASPAudio/%s.wav" type="audio/wav"> +</audio> + +<form name = "attribute2" id="a2"> +<input type="radio" name="cat" value="bus">bus +<input type="radio" name="cat" value="busy street">busy street +<input type="radio" name="cat" value="office">office +<input type="radio" name="cat" value="open air market">open air market +<input type="radio" name="cat" value="park">park <br> +<input type="radio" name="cat" value="quiet street">quiet street +<input type="radio" name="cat" value="restaurant">restaurant +<input type="radio" name="cat" value="supermarket">supermarket +<input type="radio" name="cat" value="tube">tube +<input type="radio" name="cat" value="tube station">tube station +</form> +<br> + +<audio id="audio player 3" controls> + <source src="/Users/daniele/Documents/AASPChallenge/survey/AASPAudio/%s.wav" type="audio/wav"> +</audio> + +<form name = "attribute3" id="a3"> +<input type="radio" name="cat" value="bus">bus +<input type="radio" name="cat" value="busy street">busy street +<input type="radio" name="cat" value="office">office +<input type="radio" name="cat" value="open air market">open air market +<input type="radio" name="cat" value="park">park <br> +<input type="radio" name="cat" value="quiet street">quiet street +<input type="radio" name="cat" value="restaurant">restaurant +<input type="radio" name="cat" value="supermarket">supermarket +<input type="radio" name="cat" value="tube">tube +<input type="radio" name="cat" value="tube station">tube station +</form> +<br> + +<audio id="audio player 4" controls> + <source src="/Users/daniele/Documents/AASPChallenge/survey/AASPAudio/%s.wav" type="audio/wav"> +</audio> + +<form name = "attribute4" id="a4"> +<input type="radio" name="cat" value="bus">bus +<input type="radio" name="cat" value="busy street">busy street +<input type="radio" name="cat" value="office">office +<input type="radio" name="cat" value="open air market">open air market +<input type="radio" name="cat" value="park">park <br> +<input type="radio" name="cat" value="quiet street">quiet street +<input type="radio" name="cat" value="restaurant">restaurant +<input type="radio" name="cat" value="supermarket">supermarket +<input type="radio" name="cat" value="tube">tube +<input type="radio" name="cat" value="tube station">tube station +</form> +<br> + +<audio id="audio player 5" controls> + <source src="/Users/daniele/Documents/AASPChallenge/survey/AASPAudio/%s.wav" type="audio/wav"> +</audio> + +<form name = "attribute5" id="a5"> +<input type="radio" name="cat" value="bus">bus +<input type="radio" name="cat" value="busy street">busy street +<input type="radio" name="cat" value="office">office +<input type="radio" name="cat" value="open air market">open air market +<input type="radio" name="cat" value="park">park <br> +<input type="radio" name="cat" value="quiet street">quiet street +<input type="radio" name="cat" value="restaurant">restaurant +<input type="radio" name="cat" value="supermarket">supermarket +<input type="radio" name="cat" value="tube">tube +<input type="radio" name="cat" value="tube station">tube station +</form> +<br> + +<audio id="audio player 6" controls> + <source src="/Users/daniele/Documents/AASPChallenge/survey/AASPAudio/%s.wav" type="audio/wav"> +</audio> + +<form name = "attribute6" id="a6"> +<input type="radio" name="cat" value="bus">bus +<input type="radio" name="cat" value="busy street">busy street +<input type="radio" name="cat" value="office">office +<input type="radio" name="cat" value="open air market">open air market +<input type="radio" name="cat" value="park">park <br> +<input type="radio" name="cat" value="quiet street">quiet street +<input type="radio" name="cat" value="restaurant">restaurant +<input type="radio" name="cat" value="supermarket">supermarket +<input type="radio" name="cat" value="tube">tube +<input type="radio" name="cat" value="tube station">tube station +</form> +<br> + +<audio id="audio player 7" controls> + <source src="/Users/daniele/Documents/AASPChallenge/survey/AASPAudio/%s.wav" type="audio/wav"> +</audio> + +<form name = "attribute7" id="a7"> +<input type="radio" name="cat" value="bus">bus +<input type="radio" name="cat" value="busy street">busy street +<input type="radio" name="cat" value="office">office +<input type="radio" name="cat" value="open air market">open air market +<input type="radio" name="cat" value="park">park <br> +<input type="radio" name="cat" value="quiet street">quiet street +<input type="radio" name="cat" value="restaurant">restaurant +<input type="radio" name="cat" value="supermarket">supermarket +<input type="radio" name="cat" value="tube">tube +<input type="radio" name="cat" value="tube station">tube station +</form> +<br> + +<audio id="audio player 8" controls> + <source src="/Users/daniele/Documents/AASPChallenge/survey/AASPAudio/%s.wav" type="audio/wav"> +</audio> + +<form name = "attribute8" id="a8"> +<input type="radio" name="cat" value="bus">bus +<input type="radio" name="cat" value="busy street">busy street +<input type="radio" name="cat" value="office">office +<input type="radio" name="cat" value="open air market">open air market +<input type="radio" name="cat" value="park">park <br> +<input type="radio" name="cat" value="quiet street">quiet street +<input type="radio" name="cat" value="restaurant">restaurant +<input type="radio" name="cat" value="supermarket">supermarket +<input type="radio" name="cat" value="tube">tube +<input type="radio" name="cat" value="tube station">tube station +</form> +<br> + +<audio id="audio player 9" controls> + <source src="/Users/daniele/Documents/AASPChallenge/survey/AASPAudio/%s.wav" type="audio/wav"> +</audio> + +<form name = "attribute9" id="a9"> +<input type="radio" name="cat" value="bus">bus +<input type="radio" name="cat" value="busy street">busy street +<input type="radio" name="cat" value="office">office +<input type="radio" name="cat" value="open air market">open air market +<input type="radio" name="cat" value="park">park <br> +<input type="radio" name="cat" value="quiet street">quiet street +<input type="radio" name="cat" value="restaurant">restaurant +<input type="radio" name="cat" value="supermarket">supermarket +<input type="radio" name="cat" value="tube">tube +<input type="radio" name="cat" value="tube station">tube station +</form> +<br> + +<audio id="audio player 10" controls> + <source src="/Users/daniele/Documents/AASPChallenge/survey/AASPAudio/%s.wav" type="audio/wav"> +</audio> + +<form name = "attribute10" id="a10"> +<input type="radio" name="cat" value="bus">bus +<input type="radio" name="cat" value="busy street">busy street +<input type="radio" name="cat" value="office">office +<input type="radio" name="cat" value="open air market">open air market +<input type="radio" name="cat" value="park">park <br> +<input type="radio" name="cat" value="quiet street">quiet street +<input type="radio" name="cat" value="restaurant">restaurant +<input type="radio" name="cat" value="supermarket">supermarket +<input type="radio" name="cat" value="tube">tube +<input type="radio" name="cat" value="tube station">tube station +</form> +<br> + + <input type="hidden" name="pageId" value="%i"> + <input type="hidden" name="sessionId" value="%s"> + + <input type="submit" value="submit" name="submitButton"/> + + </form> + + <script language="JavaScript" type="text/javascript" + xml:space="preserve">//<![CDATA[ + var frmvalidator = new Validator("attributes"); + + frmvalidator.addValidation("attribute1","dontselect=0", "Please select at least one main attribute for each item"); + frmvalidator.addValidation("attribute2","dontselect=0", "Please select at least one main attribute for each item"); + frmvalidator.addValidation("attribute3","dontselect=0", "Please select at least one main attribute for each item"); + frmvalidator.addValidation("attribute4","dontselect=0", "Please select at least one main attribute for each item"); + frmvalidator.addValidation("attribute5","dontselect=0", "Please select at least one main attribute for each item"); + frmvalidator.addValidation("attribute6","dontselect=0", "Please select at least one main attribute for each item"); + frmvalidator.addValidation("attribute7","dontselect=0", "Please select at least one main attribute for each item"); + frmvalidator.addValidation("attribute8","dontselect=0", "Please select at least one main attribute for each item"); + frmvalidator.addValidation("attribute9","dontselect=0", "Please select at least one main attribute for each item"); + frmvalidator.addValidation("attribute10","dontselect=0", "Please select at least one main attribute for each item"); + + //]]></script> + + </div> + + </div> + +</body> + +<script> +$('audio,video').mediaelementplayer(); +</script> +</html> +''' + +welcome_templ= ''' +<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> +<html xmlns="http://www.w3.org/1999/xhtml"> + +<html lang="en" dir="ltr"> + +<head> + <meta http-equiv="Content-Type" content="text/html; charset=utf-8;charset=utf-8" > + <link rel="stylesheet" type="text/css" href="../htempl/barrensa.css"> + <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> + <title>Digital Audio FX Perceptual Attributes</title> + + + + +<script language="JavaScript" src="../js/gen_validatorv4.js" + type="text/javascript" xml:space="preserve"></script> +</head> +<body> + +<div id="mainPicture"> + <div class="picture"> + <div id="headerTitle">Digital Audio FX</div> + <div id="headerSubtext">Perceptual Attributes Listening Test</div> + </div> + </div> + <div class="contentBox"> + + <h2>Welcome!</h2><br /> + + <br /> <br /> + + + +<form name="userinfos" action="doStart" method="POST"> +<div class="selects"> +</p> +Select Username<br /> +<input type="text" name="uinfo00" id="uinfo00" /> +<br /><br /> + +Age<br /> +<select name="uinfo01" id="uinfo01"> + <option value="0"></option> + <option value="1">< 18</option> + <option value="2">18-24</option> + <option value="3">25-34</option> + <option value="4">35-44</option> + <option value="5">45-54</option> + <option value="5">55-64</option> + <option value="6">65-74</option> + <option value="7">> 74</option> +</select> +<br /><br /> +It is encouraged to use high quality headphones for this test. However, if you use loudspeakers instead make sure you're in the correct position between the speakers in order to evaluate stereo effects. Please specify (the closest to) your listening conditions: +<br /> +<select name="info1" id="info1"> + <option value="0"></option> + <option value="1">high quality headphones</option> + <option value="2">low quality headphones</option> + <option value="3">loudspeakers / professional studio</option> + <option value="4">loudspeakers / semi-professional studio</option> + <option value="5">hifi speakers / home</option> +</select> + +<br /> +<br /> +<h4>Please note that HTML5 support is limited on this website and ADOBE FLASH is recommended</h4> +<input type="hidden" name="pageId" value="0"> +<input type="hidden" name="sessionId" value="%s"> +<input type="submit" value="submit" name="startButton"> +</p> +</form> + +<script language="JavaScript" type="text/javascript" + xml:space="preserve">//<![CDATA[ + var frmvalidator = new Validator("userinfos"); + + frmvalidator.addValidation("uinfo00","req","Please select a username"); + frmvalidator.addValidation("uinfo00","maxlen=20", "Max length for username is 20"); + frmvalidator.addValidation("uinfo00","minlen=3", "Min length for username is 3"); + frmvalidator.addValidation("uinfo01","dontselect=0", "Please specify all information"); + + frmvalidator.addValidation("info1","dontselect=0", "Please specify all information"); + +//]]></script> + + +</div> + <br /> +<h3>Thank you for participating in this project!</h3><br /> + + </div> +</body> + +</html> +''' + +endtempl = ''' +<!DOCTYPE html> +<html lang="en" dir="ltr"> +<head> +</head> +<body> +<p>results</p> +<table border="1"> +<tr> +<th>Audio File</th> +<th>Main 1</th> +<th>Main 2</th> +<th>Other 1</th> +<th>Other 2</th> +</tr> +%s +</table> +<p> <a href="http://www.elec.qmul.ac.uk/digitalmusic">thanks!</a> </p> +</body> +</html> +''' +#<p> <a href="/out/">thanks!</a> </p> + +endtempl2 = ''' +<tr> +<td>%s</td> +<td><center>%s</center></td> +<td><center>%s</center></td> +<td><center>%s</center></td> +<td><center>%s</center></td> +</tr> +'''