Detect and record the voice onset time from the beginning of an audio recorded file

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
8 messages Options
gio
Reply | Threaded
Open this post in threaded view
|

Detect and record the voice onset time from the beginning of an audio recorded file

gio
Dear uos Forum,

I would like to measure Voice Ressponse Times (RTs), such as the time in milliseconds from the beginning of an audio recorded file (.wav or ogg) from MIC to the onset of the voice (i.e., the moment in time when there is a significant increase of audio signal from background baseline noise).

Unfortunately, I have limited knowledge about recorded audio files. I've just downloaded today the amazing uos library and compiled SimpleRecorder. Would you of any of the expert programmers of uos's community interested to help me, please?

How to implement the idea

After a .wav or .ogg file has been recorded from the MIC using for example SimpleRecorder, it would be necessary to create a simple program in Lazarus free Pascal that loads the newly recorded audio file and automatically detects the voice onset time in milliseconds (e.g. 847) from the beginning of the audio file. I guess there should be a formula (algorithm) in place that if from the background noise of the audio recording there is a great increase of signal level, then that is the voice onset time.

Thus, the new Lazarus code should:
1) load a recorded audio file (.wav or .ogg),
2) detect the voice onset time from the very beginning of the audio file and
3) write the voice onset time on a simple text file (i.e. voice RTs) or diplays the value on screen if a GUI is used.  

I hope you would be able to help me.

Many thanks,
Giorgio
Reply | Threaded
Open this post in threaded view
|

Re: Detect and record the voice onset time from the beginning of an audio recorded file

fredvs
Administrator
This post was updated on .
Hello and welcome to uos forum.

You may use something like this (not tested):


The main method ( see in other demos for the directory of library and variables)
-----------------

uos_LoadLib(nil, PChar(SndFileFileName), nil, nil, nil, nil); // only SndFile is needed

uos_CreatePlayer(PlayerIndex1);

InputIndex1 := uos_AddFromFile(PlayerIndex1, path-of-recorded-file);
uos_InputSetLevelEnable(PlayerIndex1, InputIndex1, 2);
uos_InputSetPositionEnable(PlayerIndex1, InputIndex1, 1);

uos_LoopProcIn(PlayerIndex1, InputIndex1, @LoopProcPlayer1); // this to seek begin of sound


uos_Play(PlayerIndex1);      

-------------

The loop procedure:

procedure Tform1.LoopProcPlayer1; ///this to seek begin of sound
var
  volumeLR : cfloat;
  temptime: ttime;
  ho, mi, se, ms: word;
  thetime: string; // the value you will use for your text

begin
  volumeLR  := (uos_InputGetLevelLeft(PlayerIndex1, InputIndex1) +
                         uos_InputGetLevelRight(PlayerIndex1, InputIndex1)) / 2;

   if  volumeLR > 0.2 then // you need to test/adjust the value
   begin
    temptime           := uos_InputPositionTime(PlayerIndex1, InputIndex1);
    DecodeTime(temptime, ho, mi, se, ms);
    thetime  := format('%.2d:%.2d:%.2d.%.3d', [ho, mi, se, ms]); // here the time of begin of sound that you will use in text file
    uos_Stop(PlayerIndex1);  
   end;


gio
Reply | Threaded
Open this post in threaded view
|

Re: Detect and record the voice onset time from the beginning of an audio recorded file

gio
Thank you very much.

I will try your sample code and write a new message to the forum.

Cheers
Giorgio
gio
Reply | Threaded
Open this post in threaded view
|

Re: Detect and record the voice onset time from the beginning of an audio recorded file

gio
This post was updated on .
Hello uos Forum,

I am still working on a Lazarus code to measure the Voice Response Time (VRT) in milliseconds from the beginning of an audio file.  I thought to share an example of a .ogg file, so everyone can try their code on the same audio recording. I have opened the attached rec_test_file_red.ogg in Audacity and from a visual inspection the voice onset time should be around 1904 ms. The first moment when the signal is reaching a value above threshold.

rec_test_file_red.ogg

Example of Voice Respose time (VRT) in ogg file


Thank you
Giorgio
Reply | Threaded
Open this post in threaded view
|

Re: Detect and record the voice onset time from the beginning of an audio recorded file

fredvs
Administrator
Hello Giorgio.

Nice picture but I am not sure to understand.
Did you get what you wanted or is it a picture of what you want?

Fre;D
gio
Reply | Threaded
Open this post in threaded view
|

Re: Detect and record the voice onset time from the beginning of an audio recorded file

gio
Hello Fred,

Thank you for your prompt response.

That is a picture of what I want. The picture is suggesting what should be the expected result after the Lazarus code has been fully implemented.

Unfortunately I got a cold. My eyes are watery if I am starting at a computer screen for too long.  . So I'm unable to work on the code.

Best wishes
Giorgio

Reply | Threaded
Open this post in threaded view
|

Re: Detect and record the voice onset time from the beginning of an audio recorded file

fredvs
Administrator
Hello.

In attachment wave form with VRT calculation.

Just unzip all the files in /uos/examples/ and load project /uos/examples/wavevrtform.lpi

wavevrtform.zip

gio
Reply | Threaded
Open this post in threaded view
|

Re: Detect and record the voice onset time from the beginning of an audio recorded file

gio
Hello,

Wow! Thank you so much for your amazing implementation with GUI. I am very impressed.


Best wishes

Giorgio