Reply To: Recording audio

PennController for IBEX Forums Support Recording audio Reply To: Recording audio

#4971
Jeremy
Keymaster

HI Alan,

You can record audio any time you want, just make sure that the trial that you create using InitiateRecorder comes before any trial in which you use the VoiceRecorder element in your sequence of trials. For example:

PennController.ResetPrefix(null)

Sequence( "intro" , "init-audio" , "first-half" , "record-audio" , "second-half" )

AddTable( "first-table" , "ButtonText\nClick on me\nAlmost there\nNext you'll be halfway through" )

AddTable( "second-table" , "ButtonText\nClick again\nAlmost done\nThis is the last trial" )

newTrial("intro" ,
  newText("Welcome!").print()
  ,
  newButton("Start").print().wait()
)

InitiateRecorder(
  "https://myserver/uploadVoices/saveRecordings.php"
  ,
  "You will first go over a few trials, then record a sample, and then go over some more trial. Please authorize this experiment to access you microphone."
)
.label( "init-audio" )

Template( "first-table" , row => 
  newTrial( "first-half" , newButton( row.ButtonText ).print().wait() )
)

newTrial( "record-audio" , 
  newVoiceRecorder().print().wait()
  ,
  newButton("Continue").print().wait()  
)

Template( "second-table" , row => 
  newTrial( "second-half" , newButton( row.ButtonText ).print().wait() )
)

Of course this example script won’t succeed in sending the audio sample since I provided a fake URL to InitiateRecorder

Jeremy