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

조회 수: 6 (최근 30일)
홍근  김
홍근 김 2022년 1월 21일
답변: Sachin Lodhi 2023년 11월 7일
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

답변 (1개)

Sachin Lodhi
Sachin Lodhi 2023년 11월 7일
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

카테고리

Help CenterFile Exchange에서 Audio and Video Data에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by