How to detect silence using G.729 Voice Activity Detection code

7 visualizaciones (últimos 30 días)
홍근  김
홍근 김 el 21 de En. de 2022
Respondida: Sachin Lodhi el 7 de Nov. de 2023
I would like to know if there is a code of how many seconds of silence is used in a video.
If there is a video of two people speaking using G.729 Voice Activity Detection would there be a code the could get the result of down below??
speaking time -30s silence 10s speaking time 80s silence 15s
total speaking time = 110s
total silence time = 25s??
Thank you

Respuestas (1)

Sachin Lodhi
Sachin Lodhi el 7 de Nov. de 2023
Hi 홍근 ,
Based on my understanding, it seems that you want to generate an output using G.729 Voice Activity Detection (VAD) code, that sequentially lists the duration of speech, followed by the duration of silence, and then repeats this pattern.
To achieve this, you have to check the value returned by vadG729 function. It returns ‘1’ for speech and ‘0’ for silence. Using this value, you can get the desired functionality. Here is a sample code to demonstrate the logic -
% Initialize VAD parameters
VAD_cst_param = vadInitCstParams;
clear vadG729
% Run for 10 seconds
numTSteps = 1000;
silenceT = 0;
speechT = 0;
while(numTSteps)
% Retrieve 10 ms of speech data from the audio recorder
speech = audioSource();
% Call the VAD algorithm
decision = vadG729(speech, VAD_cst_param);
% Plot speech frame and decision: 1 for speech, 0 for silence
if (decision == 1)
if (silenceT == 0)
speechT = speechT + 1;
else
disp(['Silence for ', num2str(silenceT)]);
silenceT = 0;
speechT = 1;
end
else
if (speechT == 0)
silenceT = silenceT + 1;
else
disp(['Speech for ', num2str(speechT)]);
speechT = 0;
silenceT = 1;
end
end
scope(decision, speech);
numTSteps = numTSteps - 1;
end
I hope this helps.
Best Regards,
Sachin

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by