Playing audio word-by-word

PennController for IBEX Forums Support Playing audio word-by-word

Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • #5972
    cdadurian
    Participant

    Hello,

    I just started learning pcIBEX to host a self-paced listening task. So the audio should play word-by-word and RT should be taken from the end of each word to initiating the next word. Is it possible to pause audio after some ms for the first word, resume from that point, and have there be another pause after the next word, etc.? Basically as opposed to having to chop up each sentence into a per-word mp3. From what I’ve been toying with from the tutorials (forgive the ugliness; I don’t want to set defaults yet):

    newTrial("test_audio",
        newKey("next", "")
            .callback(getAudio("test")
                .enable()
                .play()
                .log()
                .wait()),
        
        newAudio("test", "2fishRoundTank.mp3")
            .play()
            .log()
            .print(),
            
        newTimer("reg1", 800)
            .start()
            .callback(getAudio("test")
                .disable()
                .pause()
                .log())
            .callback(getKey("next")
                .wait()),
            
        newTimer("reg2", 1200)
            .start()
            .callback(getAudio("test")
                .disable()
                .pause()
                .log())
            .callback(getKey("next")
                .wait()),
            
        newTimer("reg3", 1600)
            .start()
            .callback(getAudio("test")
                .disable()
                .pause()
                .log())
            .callback(getKey("next")
                .wait())
    
        newButton("next", "Next")
            .print()
            .wait()
        )

    As of now, when I take more than 800ms for the first keypress, the sentence just resumes from the pause point without the other timers. When the other timers do work, the pauses are seemingly random. I tried SetVar() for an audio timestamp at each pause point, but couldn’t figure out where to incorporate their respective GetVar()’s.

    Thanks for your help, and apologies for the long message.

    #5975
    Jeremy
    Keymaster

    Hi,

    The callback command is a non-blocking command, meaning that everything after the closing parenthesis of callback will be executed immediately, with no further delay. You probably want to use the blocking command wait instead:

    newTrial("test_audio",    
      newAudio("test", "2fishRoundTank.mp3")
        .play()
        .log()
        // .print() // Do you really want to show the player?
      ,
      newTimer("reg1", 800).start().wait(),
      getAudio("test").pause(),
      newKey("next", " ").log().wait()
      ,
      getAudio("test").play(),
      newTimer("reg2", 400).start().wait(), // I assume you want to play the next 400ms
      getAudio("test").pause(),
      getKey("next").wait()
      ,
      getAudio("test").play(),
      newTimer("reg3", 400).start().wait(),
      getAudio("test").pause(),
      getKey("next").wait()
      ,
      newButton("Next")
        .print()
        .wait()
    )

    Jeremy

    #5978
    cdadurian
    Participant

    Ah, fantastic! This makes a lot of sense.

    I do want to show the audio player during playback because originally, I wanted to give the option of replaying any word (but not words). I will play around with it some more and see if it’s too complicating or lofty.

    Thank you so much! For the timely response as well.
    Christina

    • This reply was modified 3 years, 8 months ago by cdadurian.
    #6009
    CarlyAzuma
    Participant

    Is there any way for iOS to translate speech to text and mark the spot of time in the audio file when a certain word appears?
    For example, in an audio file of 1:00 minute length, the word “hello” might occur at the 30 second mark. I would like my code to be able to find the word “hello” and mark that spot of time in the audio s that my code could go to that place and play the audio at that mark.

    #6015
    Jeremy
    Keymaster

    Hello,

    I think there are Praat scripts that will do what you describe, and generate an annex file reporting the corresponding timecodes. However, I don’t know exactly how you would integrate that within PennController, or any other experiemental software for the matter.

    If your goal is simply to skip any silence at the beginning of your audio files, you’d be better off using a script that automatically truncate your audio streams at the beginning and at the end.

    Jeremy

Viewing 5 posts - 1 through 5 (of 5 total)
  • You must be logged in to reply to this topic.