PennController for IBEX › Forums › Support › Saving Recordings with Appropriate Filename
- This topic has 4 replies, 3 voices, and was last updated 3 years, 1 month ago by
Jeremy.
-
AuthorPosts
-
February 14, 2021 at 6:28 pm #6604
danilchr1
ParticipantHello,
I am very new to PC-Ibex, but I am soon going to have my first PhD experiment in PC-Ibex in which I will be recording participants producing sentences.
I have set the php directory where the data will be stored using the following command InitiateRecorder("https://vecjezicnost.ung.si/BGexp1/mediarec.php", "Моля, регулирайте настройките на своя браузър, за да разрешите достъп до микрофона. След това натиснете връзката по-долу.")
The directory is a php university directory for the project which I do not have access to.
Now I want the audio recordings which are saved in this directory to have labels that provide relevant information, so that they are easier to process.
Below are two test examples in the result file involving trials of two participants doing either group A or B
1612992170,06ee3ecfa4185f3c15195ae69579d2a9,PennController,30,0,experiment,NULL,PennController,29,_Trial_,Start,1612991505058,target1,APAdvAN,седем,наръчник,Решение на проблема предлагаха седем препоръчани от много известната лекарка,наръчник,A,STE-072_mono.wav,NULL 1612992170,06ee3ecfa4185f3c15195ae69579d2a9,PennController,30,0,experiment,NULL,PennController,UploadRecordings,Filename,39cb2442-7585-8844-8bc3-cb6cd3fc3753.zip,1612991505176,target1,APAdvAN,седем,наръчник,Решение на проблема предлагаха седем препоръчани от много известната лекарка,наръчник,A,STE-072_mono.wav,async 1612992170,06ee3ecfa4185f3c15195ae69579d2a9,PennController,30,0,experiment,NULL,PennController,UploadRecordings,Status,Failed,1612991505176,target1,APAdvAN,седем,наръчник,Решение на проблема предлагаха седем препоръчани от много известната лекарка,наръчник,A,STE-072_mono.wav,Error Text: ; Status: 0 1612992170,06ee3ecfa4185f3c15195ae69579d2a9,PennController,30,0,experiment,NULL,Button,continue,Click,Click,1612991522028,target1,APAdvAN,седем,наръчник,Решение на проблема предлагаха седем препоръчани от много известната лекарка,наръчник,A,STE-072_mono.wav,NULL 1612992170,06ee3ecfa4185f3c15195ae69579d2a9,PennController,30,0,experiment,NULL,MediaRecorder,recorder,Filename,recorder-48.webm,1612991522030,target1,APAdvAN,седем,наръчник,Решение на проблема предлагаха седем препоръчани от много известната лекарка,наръчник,A,STE-072_mono.wav,NULL 1612992170,06ee3ecfa4185f3c15195ae69579d2a9,PennController,30,0,experiment,NULL,MediaRecorder,recorder,Recording,Start,1612991517926,target1,APAdvAN,седем,наръчник,Решение на проблема предлагаха седем препоръчани от много известната лекарка,наръчник,A,STE-072_mono.wav,NULL 1612992170,06ee3ecfa4185f3c15195ae69579d2a9,PennController,30,0,experiment,NULL,MediaRecorder,recorder,Recording,Stop,1612991520794,target1,APAdvAN,седем,наръчник,Решение на проблема предлагаха седем препоръчани от много известната лекарка,наръчник,A,STE-072_mono.wav,NULL 1612992170,06ee3ecfa4185f3c15195ae69579d2a9,PennController,30,0,experiment,NULL,PennController,29,_Trial_,End,1612991522030,target1,APAdvAN,седем,наръчник,Решение на проблема предлагаха седем препоръчани от много известната лекарка,наръчник,A,STE-072_mono.wav,NULL
1613150055,2fdca48def6c3939e8f3c64c13a94465,PennController,55,0,experiment,NULL,PennController,54,_Trial_,Start,1613149872960,filler2,APN,,терен,Зад хълма се намираха обработени от трактора,терен,B,STE-068_mono.wav,NULL 1613150055,2fdca48def6c3939e8f3c64c13a94465,PennController,55,0,experiment,NULL,PennController,UploadRecordings,Filename,c29e343f-d48b-f72b-53f5-b4f5d3f35d30.zip,1613149873220,filler2,APN,,терен,Зад хълма се намираха обработени от трактора,терен,B,STE-068_mono.wav,async 1613150055,2fdca48def6c3939e8f3c64c13a94465,PennController,55,0,experiment,NULL,PennController,UploadRecordings,Status,Failed,1613149873220,filler2,APN,,терен,Зад хълма се намираха обработени от трактора,терен,B,STE-068_mono.wav,Error Text: ; Status: 0 1613150055,2fdca48def6c3939e8f3c64c13a94465,PennController,55,0,experiment,NULL,MediaRecorder,recorder,Recording,Start,1613149882211,filler2,APN,,терен,Зад хълма се намираха обработени от трактора,терен,B,STE-068_mono.wav,NULL 1613150055,2fdca48def6c3939e8f3c64c13a94465,PennController,55,0,experiment,NULL,MediaRecorder,recorder,Recording,Stop,1613149883230,filler2,APN,,терен,Зад хълма се намираха обработени от трактора,терен,B,STE-068_mono.wav,NULL 1613150055,2fdca48def6c3939e8f3c64c13a94465,PennController,55,0,experiment,NULL,Button,continue,Click,Click,1613149884278,filler2,APN,,терен,Зад хълма се намираха обработени от трактора,терен,B,STE-068_mono.wav,NULL 1613150055,2fdca48def6c3939e8f3c64c13a94465,PennController,55,0,experiment,NULL,MediaRecorder,recorder,Filename,recorder-82.webm,1613149884284,filler2,APN,,терен,Зад хълма се намираха обработени от трактора,терен,B,STE-068_mono.wav,NULL 1613150055,2fdca48def6c3939e8f3c64c13a94465,PennController,55,0,experiment,NULL,PennController,54,_Trial_,End,1613149884284,filler2,APN,,терен,Зад хълма се намираха обработени от трактора,терен,B,STE-068_mono.wav,NULL
The information I am currently logging off apart from the general information is the following
.log("Type",variable.Type) (The type - target or filler: target1 and filler2) .log("ConditionLabel",variable.ConditionLabel) (the condition: APAdvAN or APN) .log("Numeral",variable.Numeral) (the numeral: седем (seven) or ,, (which in this case is None) .log("Target Noun",variable.BaseFormOfTargetNoun) (the block / target noun: наръчник or терен) .log("Final Sentence",variable.FinalSentence) (the final sentence Решение на проблема предлагаха седем препоръчани от много известната лекарка or Зад хълма се намираха обработени от трактора) .log("Target Noun",variable.BaseFormOfTargetNoun) (the block / target noun: наръчник or терен .log("Group",variable.Group) (the Group: A or B) .log("Audio File",variable.TargetAudioFile) (the audio file which the participants are listening to: STE-072_mono.wav or STE-068_mono.wav)
Also, I suspect that the numbers 06ee3ecfa4185f3c15195ae69579d2a9 and 2fdca48def6c3939e8f3c64c13a94465 indicate the participant.
I want the recorded audio files produced by the participants to have a similar organization in the filename, so I can process the results more easily:
For example, I want to include the following information (the variable name is put in quotes and they are all joined by the character “_”"type"_"condition"_"block"_"numeral"_"group"_"participant".wav
For examples the files I have will be labeled:
target1_APAdvAN_наръчник_седем_A_06ee3ecfa4185f3c15195ae69579d2a9.wav filler2_APN_терен__B_2fdca48def6c3939e8f3c64c13a94465.wav
It might even be preferable to have a simple id integer to show the participant rather than this long id:
target1_APAdvAN_наръчник_седем_A_1.wav filler2_APN_терен__B_2.wav
In the log results, in addition to the information I have, I also want to have the filenames of these audio files produced by the participants. Something like:
.log("Output Audio File","target1_APAdvAN_наръчник_седем_A_06ee3ecfa4185f3c15195ae69579d2a9.wav") .log("Output Audio File","filler2_APN_терен__B_2fdca48def6c3939e8f3c64c13a94465.wav")
or even better
.log("Output Audio File","target1_APAdvAN_наръчник_седем_A_1.wav") .log("Output Audio File", "filler2_APN_терен__B_2.wav")
In this way I can keep track of all the information just by looking at the filename.
How can I accomplish this in PC-Ibex using a Template? I already have a template with a design_final.csv file that stores all these variables (apart from the participant’s id which I need to get at runtime), as can be seen from the log commands.
Thank you.
Kind regards,
DanilFebruary 14, 2021 at 6:59 pm #6605Jeremy
KeymasterHello Danil,
The audio files are named after the MediaRecorder element you created to record them. So if you have newMediaRecorder("recorder","audio") then your files will be named something like recorder.webm. If you have more than one file recorded via a MediaRecorder element called recorder then PennController will automatically append a number to generate unique names, for example recorder-48.webm. Note that the extension in your case is webm and not wav, because no browser natively supports WAV as a format to save audio streams recorded via the MediaRecorder API.
In order to name the files as you describe, you need to do something like
newMediaRecorder([variable.Type,variable.ConditionLabel,variable.BaseFormOfTargetNoun,variable.Numeral,variable.Group].join('_'), "audio")
Of course this is a big long, so I’d suggest you add a column to your table in which you generate the filename you want to use for the recording file for each row. Say you name that column RecordingFile, then you can simply do:
newMediaRecorder(variable.RecordingFile, "audio")
which makes it easier to refer back to your element later, for example:
getMediarecorder(variable.RecordingFile).stop()
Note that I didn’t include a participant ID in those filenames, because the strings you mention are MD5 hashes generated at the end of the experiment. There is no easy way to add a unique participant ID to the filenames, unless if you pass it as part of your experiment’s URL, in which case you can use GetURLParameter to retrieve it, and you can do things like:
newMediaRecorder(variable.RecordingFile+'_'+GetURLParameter("id"), "audio")
and
getMediarecorder(variable.RecordingFile+'_'+GetURLParameter("id")).stop()
Let me know if you have any questions
Jeremy
February 15, 2021 at 3:22 pm #6608danilchr1
ParticipantThank you,
I will try this and see if it works.
DanilJuly 21, 2021 at 6:04 am #7123ginopino09
ParticipantHello Jeremy,
I tried this solution about a month ago and it was working, now I am back to work on my experiment and the debug shows this message: Unrecognized expression ‘variable’ (line inside PennController.Template) (PennController: 116).Here what I wrote:
Template("REAL_NDS", row => newTrial("ndsr", newText("+").css({'font-size':'1.5vw'}).print("center at 50%","middle at 50%"), newTimer(500).start().wait(), newText(row.WORD).css({'font-size':'1.5vw'}).print("center at 50%","middle at 50%"), newMediaRecorder(variable.REC, "audio").record(), newTimer(500).start().wait(), newKey("Enter").print().wait(), newTimer("pad", 500).start().wait(),clear(), getMediaRecorder(variable.REC) .stop() .log() ))
My table:
AddTable("REAL_NDS",`Audio1,WORD,REC sheep.wav,SHEEP,NDS_SHEEP_6_10 ...`)
Do you have any idea why this is not working anymore?
Thank you!July 21, 2021 at 10:46 am #7124Jeremy
KeymasterHello,
You are using
row
as your pointer (Template("REAL_NDS", row => newTrial("ndsr",
) notvariable
: replacevariable
withrow
and it should workJeremy
-
AuthorPosts
- You must be logged in to reply to this topic.