示例#1
0
    def getHTML(self):

        audioLabel = self.textDict['play_button']
        mediaNameList = [name.strip() for name in self.mediaList]
        audioButtonList = [
            audio.generateAudioButton(name, i, audioLabel, 0, False)
            for i, name in enumerate(mediaNameList)
        ]

        tmpTxt = self.textDict[self.textName] % tuple(audioButtonList)
        htmlText = ('<p id="title">'
                    '%s'
                    '</p><br /><br />'
                    ''
                    '<div id="longText">'
                    ''
                    '%s'
                    ''
                    '</div><br />')
        htmlText %= (self.textDict['title'], tmpTxt)

        if self.audioOrVideo == "audio":
            extList = self.webSurvey.audioExtList
        else:
            extList = self.webSurvey.videoExtList

        embedTxt = ""
        embedTxt += self._getKeyPressEmbed()
        embedTxt += "\n\n" + audio.generateEmbed(self.wavDir, mediaNameList,
                                                 extList, self.audioOrVideo)

        pageTemplate = join(self.webSurvey.htmlDir, "basicTemplate.html")

        return htmlText, pageTemplate, {'embed': embedTxt}
示例#2
0
 def getHTML(self):
     
     audioLabel = self.textDict['play_button']
     mediaNameList = [name.strip() for name in self.mediaList]
     audioButtonList = [audio.generateAudioButton(name, i, audioLabel,
                                                  0, False)
                        for i, name in enumerate(mediaNameList)]
     
     tmpTxt = self.textDict[self.textName] % tuple(audioButtonList)
     htmlText = ('<p id="title">'
                 '%s'
                 '</p><br /><br />'
                 ''
                 '<div id="longText">'
                 ''
                 '%s'
                 ''
                 '</div><br />')
     htmlText %= (self.textDict['title'], tmpTxt)
     
     if self.audioOrVideo == "audio":
         extList = self.webSurvey.audioExtList
     else:
         extList = self.webSurvey.videoExtList
     
     embedTxt = ""
     embedTxt += self._getKeyPressEmbed()
     embedTxt += "\n\n" + audio.generateEmbed(self.wavDir, mediaNameList,
                                              extList, self.audioOrVideo)
     
     pageTemplate = join(self.webSurvey.htmlDir, "basicTemplate.html")
     
     return htmlText, pageTemplate, {'embed': embedTxt}
示例#3
0
 def getHTML(self):
     '''
     Returns html for a page where users mark either breaks or prominence
     
     
     '''
     pageTemplate = join(constants.htmlDir, "wavTemplate.html")
     
     txtFN = join(self.txtDir, self.transcriptName + ".txt")
     
     sentenceList = loader.loadTxtFile(txtFN)
     
     testType = self.pageName
     
     # Construct the HTML here
     
     htmlTxt = _doBreaksOrProminence(testType, 0, 0,
                                     self.name,
                                     self.textDict[self.instructText],
                                     self.textDict['play_button'],
                                     sentenceList, self.presentAudio,
                                     self.boundaryToken,
                                     self.syllableDemarcator)[0]
 
     if self.presentAudio is True:
         embedTxt = ""
         embed = audio.generateEmbed(self.wavDir,
                                     [self.name, ],
                                     self.webSurvey.audioExtList,
                                     "audio")
         embedTxt += "\n\n" + embed
         embedTxt += _getKeyPressEmbed(self.bindPlayKeyID,
                                       self.bindSubmitID)
     else:
         embedTxt = ""
     embedTxt += "\n\n"
     
     htmlTxt = html.makeNoWrap(htmlTxt)
     
     return htmlTxt, pageTemplate, {'embed': embedTxt}
示例#4
0
    def getHTML(self):

        htmlText = self._getHTMLTxt()
        pageTemplate = join(self.webSurvey.htmlDir,
                            "blankPageWValidation.html")

        audioLabel = self.textDict['play_button']
        htmlText %= audio.generateAudioButton(self.mediaName, 0, audioLabel, 0,
                                              False)
        htmlText += "<br />"

        if self.audioOrVideo == "audio":
            extList = self.webSurvey.audioExtList
        else:
            extList = self.webSurvey.videoExtList

        embedTxt = ""
        embedTxt += "\n\n" + audio.generateEmbed(self.wavDir, [
            self.mediaName,
        ], extList, self.audioOrVideo)

        return htmlText, pageTemplate, {'embed': embedTxt}
    def getHTML(self):
        '''
        Listeners hear two files and decide if they are the same or different
        '''
        pageTemplate = join(self.webSurvey.htmlDir, "axbTemplate.html")
        availableFunctions = getToggleButtonsJS(1, "range%d")
        
        txtFN = join(self.txtDir, self.transcriptName + ".txt")
        sentenceList = loader.loadTxtFile(txtFN)
        transcriptTxt = "<br /><br />\n\n".join(sentenceList)

        audioLabel = self.textDict['play_button']
        playBtnSnippet = audio.generateAudioButton(self.mediaName, 0,
                                                   audioLabel,
                                                   0,
                                                   False)
        
        runOnMinThresholdJS = "enable_checkboxes();"
        embedTxt = ""
        
        mediaNames = [self.mediaName, ]
        
        if self.audioOrVideo == "audio":
            extList = self.webSurvey.audioExtList
        else:
            extList = self.webSurvey.videoExtList
        embedTxt += "\n\n" + audio.generateEmbed(self.wavDir,
                                                 list(set(mediaNames)),
                                                 extList,
                                                 self.audioOrVideo)
        embedTxt += "\n\n" + availableFunctions
        
        description = self.textDict[self.instructionText]

        htmlText = description + self._getHTMLTxt()
        htmlText %= (playBtnSnippet + "<br />" + transcriptTxt)
    
        return htmlText, pageTemplate, {'embed': embedTxt}
    def getHTML(self):
        '''
        Listeners hear two files and decide if they are the same or different
        '''
        pageTemplate = join(self.webSurvey.htmlDir, "axbTemplate.html")
        availableFunctions = getToggleButtonsJS(1, "range%d")
        
        txtFN = join(self.txtDir, self.transcriptName + ".txt")
        sentenceList = loader.loadTxtFile(txtFN)
        transcriptTxt = "<br /><br />\n\n".join(sentenceList)

        audioLabel = self.textDict['play_button']
        playBtnSnippet = audio.generateAudioButton(self.mediaName, 0,
                                                   audioLabel,
                                                   0,
                                                   False)
        
        runOnMinThresholdJS = "enable_checkboxes();"
        embedTxt = ""
        
        mediaNames = [self.mediaName, ]
        
        if self.audioOrVideo == "audio":
            extList = self.webSurvey.audioExtList
        else:
            extList = self.webSurvey.videoExtList
        embedTxt += "\n\n" + audio.generateEmbed(self.wavDir,
                                                 list(set(mediaNames)),
                                                 extList,
                                                 self.audioOrVideo)
        embedTxt += "\n\n" + availableFunctions
        
        description = self.textDict[self.instructionText]

        htmlText = description + self._getHTMLTxt()
        htmlText %= (playBtnSnippet + "<br />" + transcriptTxt)
    
        return htmlText, pageTemplate, {'embed': embedTxt}
示例#7
0
 def getHTML(self):
 
     htmlText = self._getHTMLTxt()
     pageTemplate = join(self.webSurvey.htmlDir,
                         "blankPageWValidation.html")
     
     audioLabel = self.textDict['play_button']
     htmlText %= audio.generateAudioButton(self.mediaName, 0, audioLabel,
                                           0, False)
     htmlText += "<br />"
     
     if self.audioOrVideo == "audio":
         extList = self.webSurvey.audioExtList
     else:
         extList = self.webSurvey.videoExtList
     
     embedTxt = ""
     embedTxt += "\n\n" + audio.generateEmbed(self.wavDir,
                                              [self.mediaName, ],
                                              extList,
                                              self.audioOrVideo)
     
     return htmlText, pageTemplate, {'embed': embedTxt}
 def getHTML(self):
 
     htmlText = self._getHTMLTxt()
     pageTemplate = join(self.webSurvey.htmlDir, "axbTemplate.html")
     
     audioLabel = self.textDict['play_button']
     htmlText %= audio.generateAudioButton(self.mediaList,
                                           0,
                                           audioLabel,
                                           self.pauseDuration,
                                           False, True) + "<br />"
     
     embedTxt = ""
     
     if self.audioOrVideo == "audio":
         extList = self.webSurvey.audioExtList
     else:
         extList = self.webSurvey.videoExtList
     embedTxt += "\n\n" + audio.generateEmbed(self.wavDir,
                                              list(set(self.mediaList)),
                                              extList,
                                              self.audioOrVideo)
     
     return htmlText, pageTemplate, {'embed': embedTxt}
 def getHTML(self):
 
     htmlText = self._getHTMLTxt()
     pageTemplate = join(self.webSurvey.htmlDir, "axbTemplate.html")
     
     audioLabel = self.textDict['play_button']
     htmlText %= audio.generateAudioButton(self.mediaList,
                                           0,
                                           audioLabel,
                                           self.pauseDuration,
                                           False, True) + "<br />"
     
     embedTxt = ""
     
     if self.audioOrVideo == "audio":
         extList = self.webSurvey.audioExtList
     else:
         extList = self.webSurvey.videoExtList
     embedTxt += "\n\n" + audio.generateEmbed(self.wavDir,
                                              list(set(self.mediaList)),
                                              extList,
                                              self.audioOrVideo)
     
     return htmlText, pageTemplate, {'embed': embedTxt}
示例#10
0
 def getHTML(self):
     '''
     Returns html for a page where users mark both breaks and prominence
     
     Subjects first mark up the boundaries.  They are then shown the same
     utterance with their original markings still present.  They are then
     asked to mark boundaries.
     
     'focus' - either 'meaning' or 'acoustics' -- used to print the correct
         instructions
     '''
     
     pageTemplate = join(constants.htmlDir, "wavTemplate.html")
     
     txtFN = join(self.txtDir, self.transcriptName + ".txt")
     
     sentenceList = loader.loadTxtFile(txtFN)
     
     # Construct the HTML here
     # There are two passes of the utterance.  The first is for boundaries.
     # After
     wordIDNum = 0
     htmlTxt = '<div id="ShownDiv" style="DISPLAY: block">'
 
     # HTML boundaries
     audioLabel = self.textDict['play_button']
     stepOneInstructText = self.textDict[self.stepOneInstructText]
     tmpHTMLTxt, numWords = _doBreaksOrProminence(self.pageName,
                                                  wordIDNum, 0,
                                                  self.name,
                                                  stepOneInstructText,
                                                  audioLabel,
                                                  sentenceList,
                                                  self.presentAudio,
                                                  self.boundaryToken,
                                                  None)
     htmlTxt += "<div>%s</div>" % tmpHTMLTxt
 
     # HTML from transitioning from the boundary portion of text
     # to the prominence portion
     continueButtonTxt = self.textDict['continue_button']
     htmlTxt += '''<br /><br /><input type="button" value="%s"
                 id="halfwaySubmitButton"
                 onclick="ShowHide(audioLoader.verifyFirstAudioPlayed(), %s)"></button>''' % (continueButtonTxt, _getTogglableWordEmbed(self))
     htmlTxt += '</div>\n\n<div id="HiddenDiv" style="DISPLAY: none">\n\n'
     
     # HTML prominence
     stepTwoInstructText = self.textDict[self.stepTwoInstructText]
     htmlTxt += _doBreaksOrProminence(self.pageName, numWords, 1,
                                      self.name,
                                      stepTwoInstructText,
                                      audioLabel,
                                      sentenceList,
                                      self.presentAudio,
                                      self.boundaryToken,
                                      None)[0]
     htmlTxt += "</div>"
                 
     # Add the javascript and style sheets here
     if self.presentAudio is True:
         embedTxt = ""
         embed = audio.generateEmbed(self.wavDir,
                                     [self.name, ],
                                     self.webSurvey.audioExtList,
                                     "audio")
         embedTxt += "\n\n" + embed
         embedTxt += "\n\n" + _getKeyPressEmbed(self.bindPlayKeyID,
                                                self.bindSubmitID,
                                                True)
             
     else:
         embedTxt = ""
     
     htmlTxt = html.makeNoWrap(htmlTxt)
     
     return htmlTxt, pageTemplate, {'embed': embedTxt}
    def getHTML(self):
        '''
        Listeners hear two files and decide if they are the same or different
        '''
        pageTemplate = join(self.webSurvey.htmlDir, "axbTemplate.html")
        availableFunctions = getToggleButtonsJS(len(self.responseButtonList))
        
        # Generate the media buttons
        playBtnLabelRow = ''
        playBtnSnippet = ''
        template = "<td class='buttons'>%s</td>"
        for i in range(len(self.mediaList)):
            
            # Don't generate an audio button if the list is empty
            if len(self.mediaList[i]) == 0:
                continue
            
            audioLabel = self.textDict['play_button']
            mediaButtonHTML = audio.generateAudioButton(self.mediaList[i], i,
                                                        audioLabel,
                                                        self.pauseDuration,
                                                        False)
            if self.buttonLabelList is not None:
                label = self.textDict[self.buttonLabelList[i]]
                playBtnLabelRow += template % label
            playBtnSnippet += template % mediaButtonHTML
        
        # Add optional button labels
        playBtnSnippet = '<tr>%s</tr>' % playBtnSnippet
        if self.buttonLabelList is not None:
            playBtnLabelRow = '<tr>%s</tr>' % playBtnLabelRow
        
        playBtnSnippet = playBtnLabelRow + playBtnSnippet
        
        # Add optional speech transcripts
        if self.transcriptList is not None:
            transcriptList = [loader.loadTxtFile(join(self.txtDir,
                                                      transcript + ".txt"))
                              for transcript in self.transcriptList]
            transcriptList = ["<td>%s</td>" % "<br />".join(transcript)
                              for transcript in transcriptList]
                              
            transcriptTxt = "<tr>%s</tr>" % "".join(transcriptList)
            playBtnSnippet = playBtnSnippet + transcriptTxt
        
        playBtnSnippet = ('<table class="center">%s</table>') % playBtnSnippet
        
        runOnMinThresholdJS = "enable_checkboxes();"
        embedTxt = ""
        
        mediaNames = [mediaName for mediaSubList in self.mediaList
                      for mediaName in mediaSubList]
        if self._doPlayMedia():
            if self.audioOrVideo == "video":
                extList = self.webSurvey.videoExtList
            else:
                extList = self.webSurvey.audioExtList
            embedTxt += "\n\n" + audio.generateEmbed(self.wavDir,
                                                     list(set(mediaNames)),
                                                     extList,
                                                     self.audioOrVideo)
        
        embedTxt += "\n\n" + availableFunctions
        embedTxt += self._getKeyPressEmbed()
        
        description = self.textDict[self.instructionText]

        htmlText = description + self._getHTMLTxt()
        htmlText %= (playBtnSnippet + "<br />")
    
        return htmlText, pageTemplate, {'embed': embedTxt}
示例#12
0
    def getHTML(self):
        '''
        Listeners hear two files and decide if they are the same or different
        '''
        pageTemplate = join(self.webSurvey.htmlDir, "axbTemplate.html")
        availableFunctions = getToggleButtonsJS(len(self.responseButtonList))
        
        # Generate the media buttons
        playBtnLabelRow = ''
        playBtnSnippet = ''
        template = "<td class='buttons'>%s</td>"
        for i in range(len(self.mediaList)):
            
            # Don't generate an audio button if the list is empty
            if len(self.mediaList[i]) == 0:
                continue
            
            audioLabel = self.textDict['play_button']
            mediaButtonHTML = audio.generateAudioButton(self.mediaList[i], i,
                                                        audioLabel,
                                                        self.pauseDuration,
                                                        False)
            if self.buttonLabelList is not None:
                label = self.textDict[self.buttonLabelList[i]]
                playBtnLabelRow += template % label
            playBtnSnippet += template % mediaButtonHTML
        
        # Add optional button labels
        playBtnSnippet = '<tr>%s</tr>' % playBtnSnippet
        if self.buttonLabelList is not None:
            playBtnLabelRow = '<tr>%s</tr>' % playBtnLabelRow
        
        playBtnSnippet = playBtnLabelRow + playBtnSnippet
        
        # Add optional speech transcripts
        if self.transcriptList is not None:
            transcriptList = [loader.loadTxtFile(join(self.txtDir,
                                                      transcript + ".txt"))
                              for transcript in self.transcriptList]
            transcriptList = ["<td>%s</td>" % "<br />".join(transcript)
                              for transcript in transcriptList]
                              
            transcriptTxt = "<tr>%s</tr>" % "".join(transcriptList)
            playBtnSnippet = playBtnSnippet + transcriptTxt
        
        playBtnSnippet = ('<table class="center">%s</table>') % playBtnSnippet
        
        runOnMinThresholdJS = "enable_checkboxes();"
        embedTxt = ""
        
        mediaNames = [mediaName for mediaSubList in self.mediaList
                      for mediaName in mediaSubList]
        if self._doPlayMedia():
            if self.audioOrVideo == "video":
                extList = self.webSurvey.videoExtList
            else:
                extList = self.webSurvey.audioExtList
            embedTxt += "\n\n" + audio.generateEmbed(self.wavDir,
                                                     list(set(mediaNames)),
                                                     extList,
                                                     self.audioOrVideo)
        
        embedTxt += "\n\n" + availableFunctions
        embedTxt += self._getKeyPressEmbed()
        
        description = self.textDict[self.instructionText]

        htmlText = description + self._getHTMLTxt()
        htmlText %= (playBtnSnippet + "<br />")
    
        return htmlText, pageTemplate, {'embed': embedTxt}