How to detect silence using G.729 Voice Activity Detection code
7 次查看(过去 30 天)
显示 更早的评论
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
0 个评论
回答(1 个)
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
Please refer to the following example for additional information - https://www.mathworks.com/help/dsp/ug/g-729-voice-activity-detection.html#:~:text=%27Scroll%27)%3B-,Stream%20Processing%20Loop,-Get
I hope this helps.
Best Regards,
Sachin
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Audio and Video Data 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!