首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >webRTC:在python的WAV音频上获取VAD数据

webRTC:在python的WAV音频上获取VAD数据
EN

Stack Overflow用户
提问于 2022-01-18 06:34:40
回答 1查看 176关注 0票数 0

我正在尝试运行webRTC VAD found 这里的示例代码。

但是当我给它一个单16位的波形文件时,我只需要很长时间的停顿,它就会检测到整个文件是浊音,而浊音输出chunk-00.wav是整个音频文件。

任何帮助都是非常感谢的。下面我给出了我收到的控制台输出。

代码语言:javascript
复制
(base) gulag_dweller@Tumuls-MacBook-Pro python_transformers % python3 VAD-python.py /Users/gulag_dweller/Downloads/try_voice.wav 
sample rate is: 48000 Hz
00001111111111+(0.12)11111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111011111111111111111111111111111111111111111111111111111111111111111011111111111111111111111111111111111111111111100011111111111111111111111111111111111111110111111111111111111111111111111111111111110001111111111111111111111111111111111111111111111111-(16.22999999999986)
 Writing chunk-00.wav
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2022-01-31 11:45:47

我想我找到了一种替代的方法来获取VAD数据。我没有尝试从上面链接中显示的预定义方法中获取VAD,而是创建了自己的函数。

这个函数基本上测量的是波的振幅,任何在基音级(1.6x the base value)以上观测到的尖峰都被认为是浊音活动。这个函数假定只有一个人在说话,而且噪音水平保持相对恒定。

代码语言:javascript
复制
y_list=list(audio_data1) # create an immutable list of amplitude values
y_vad=[] # initialise an array
max_noise = -1.0 # put the lowest value that one can

for i in range(len(time_s)):
    t = time_s[i]

    # Variable to store the current absolute amplitude value for the given index i
    current_audio_amplitude = np.abs(audio_data1[i])
    # since at the start, some issues arise, first few seconds are padded out 
    # and for any sudden change in |amplitude| i.e. > 60% results in stopping the program 
    if t>0.2 and max_noise > 0 and current_audio_amplitude > 1.6*max_noise:
        print(t, current_audio_amplitude, max_noise)
        break
    # take the highest value of amplitude to be the max_noise
    if current_audio_amplitude > max_noise:
        max_noise = current_audio_amplitude
print('max-noise is: '+str(max_noise))

for i in range(len(time_s)):
    # for any value amplitude that exceeds the max_noise value is taken to be a voice activity
    if np.abs(audio_data1[i]) > max_noise:
        y_vad.append(1)
    # otherwise just take VAD value to be 0
    else:
        y_vad.append(0)
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/70751218

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档