def writeRoutineEndCode(self, buff): inits = getInitVals(self.params) # Alter inits if len(self.exp.flow._loopList): inits['loop'] = self.exp.flow._loopList[-1].params['name'] inits['filename'] = f"'recording_{inits['name']}_{inits['loop']}_%s.{inits['outputType']}' % {inits['loop']}.thisTrialN" else: inits['loop'] = "thisExp" inits['filename'] = f"'recording_{inits['name']}'" transcribe = inits['transcribe'].val if inits['transcribe'].val == False: inits['transcribeBackend'].val = None if inits['outputType'].val == 'default': inits['outputType'].val = 'wav' # Warn user if their transcriber won't work locally if inits['transcribe'].val: if inits['transcribeBackend'].val in localTranscribers: inits['transcribeBackend'].val = localTranscribers[self.params['transcribeBackend'].val] else: default = list(localTranscribers.values())[0] alert(4610, strFields={"transcriber": inits['transcribeBackend'].val, "default": default}) # Store recordings from this routine code = ( "# tell mic to keep hold of current recording in %(name)s.clips and transcript (if applicable) in %(name)s.scripts\n" "# this will also update %(name)s.lastClip and %(name)s.lastScript\n" "%(name)s.stop()\n" "%(name)sClip, %(name)sScript = %(name)s.bank(\n" ) buff.writeIndentedLines(code % inits) buff.setIndentLevel(1, relative=True) code = ( "tag='%(loop)s', transcribe='%(transcribeBackend)s',\n" ) buff.writeIndentedLines(code % inits) if transcribe: code = ( "language=%(transcribeLang)s, expectedWords=%(transcribeWords)s\n" ) else: code = ( "config=None\n" ) buff.writeIndentedLines(code % inits) buff.setIndentLevel(-1, relative=True) code = ( ")\n" "%(loop)s.addData('%(name)s.clip', os.path.join(%(name)sRecFolder, %(filename)s))\n" ) buff.writeIndentedLines(code % inits) if transcribe: code = ( "%(loop)s.addData('%(name)s.script', %(name)sScript)\n" ) buff.writeIndentedLines(code % inits) # Write base end routine code BaseComponent.writeRoutineEndCode(self, buff)
def writeRoutineEndCode(self, buff): inits = getInitVals(self.params) inits['routine'] = self.parentName # Store recordings from this routine code = ( "%(name)s.bank('%(routine)s')\n" ) buff.writeIndentedLines(code % inits) # Write base end routine code BaseComponent.writeRoutineEndCode(self, buff)