- iOS/Objective-C 元类和类别
- objective-c - -1001 错误,当 NSURLSession 通过 httpproxy 和/etc/hosts
- java - 使用网络类获取 url 地址
- ios - 推送通知中不播放声音
目前,我正在解析 wav 文件并在 std::vector<int16_t> sample
中存储样本 .现在,我想对这些数据应用 VAD(语音事件检测)以找出语音的“区域”,更具体地说是单词的开始和结束。
解析的 wav 文件是 16KHz,16 位 PCM,单声道。我的代码是用 C++ 编写的。
我已经搜索了很多,但找不到关于 webRTC 的 VAD 功能的适当文档。
根据我的发现,我需要使用的函数是 WebRtcVad_Process()
.它的原型(prototype)如下:
int WebRtcVad_Process(VadInst* handle, int fs, const int16_t* audio_frame,
size_t frame_length)
根据我在这里找到的内容:https://stackoverflow.com/a/36826564/6487831
Each frame of audio that you send to the VAD must be 10, 20 or 30 milliseconds long. Here's an outline of an example that assumes audio_frame is 10 ms (320 bytes) of audio at 16000 Hz:
int is_voiced = WebRtcVad_Process(vad, 16000, audio_frame, 160);
有道理:
1 sample = 2B = 16 bits
SampleRate = 16000 sample/sec = 16 samples/ms
For 10 ms, no of samples = 160
因此,基于此,我实现了这个:
const int16_t * temp = sample.data();
for(int i = 0, ms = 0; i < sample.size(); i += 160, ms++)
{
int isActive = WebRtcVad_Process(vad, 16000, temp, 160); //10 ms window
std::cout<<ms<<" ms : "<<isActive<<std::endl;
temp = temp + 160; // processed 160 samples
}
现在,我不确定这是否正确。另外,我也不确定这是否会给我正确的输出。
所以,
最佳答案
首先我要说的是,不,我认为您无法使用 VAD 将话语分割成单个单词。来自article on speech segmentation in Wikipedia :
One might expect that the inter-word spaces used by many written languages like English or Spanish would correspond to pauses in their spoken version, but that is true only in very slow speech, when the speaker deliberately inserts those pauses. In normal speech, one typically finds many consecutive words being said with no pauses between them, and often the final sounds of one word blend smoothly or fuse with the initial sounds of the next word.
也就是说,我会尽量回答您的其他问题。
在运行 VAD 之前,您需要将可以压缩的 WAV 文件解码为原始 PCM 音频数据。参见例如Reading and processing WAV file data in C/C++ .或者,您可以在运行代码之前使用 sox
之类的工具将 WAV 文件转换为原始音频。此命令会将任何格式的 WAV 文件转换为 WebRTCVAD 期望的格式的 16 KHz、16 位 PCM:
sox my_file.wav -r 16000 -b 16 -c 1 -e signed-integer -B my_file.raw
看起来您正在使用正确的功能。更具体地说,您应该这样做:
#include "webrtc/common_audio/vad/include/webrtc_vad.h"
// ...
VadInst *vad;
WebRtcVad_Create(&vad);
WebRtcVad_Init(vad);
const int16_t * temp = sample.data();
for(int i = 0, ms = 0; i < sample.size(); i += 160, ms += 10)
{
int isActive = WebRtcVad_Process(vad, 16000, temp, 160); //10 ms window
std::cout << ms << " ms : " << isActive << std::endl;
temp = temp + 160; // processed 160 samples (320 bytes)
}
要查看它是否正常工作,您可以运行已知文件并查看是否获得预期的结果。例如,您可以从处理静音开始,并确认您永远不会(或很少——此算法并不完美)看到从 WebRtcVad_Process
返回的有声结果。然后你可以尝试一个文件,除了中间的一个简短的话语等之外,所有的文件都是静音的。如果你想与现有的测试进行比较,py-webrtcvad 模块有一个单元测试可以做到这一点;查看test_process_file
function .
要进行词级分割,您可能需要找到一个语音识别库来执行此操作,或者让您可以访问执行此操作所需的信息。例如。 this thread on the Kaldi mailing list好像在讲怎么分词。
关于c++ - webRTC : How to apply webRTC's VAD on audio through samples obtained from WAV file,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44457162/
这是我的第一个主题here的继续,该主题是有关如何使用代码模拟屏幕触摸的。 我想将此功能整合到 float 的屏幕聊天头中(就像facebook所做的那样)。因此,基本上,当我点击聊天头时,此服务将模
安装应用程序时遇到以下问题: 使用Worklight控制台,我正在上载.wlapp文件,删除已部署的应用程序,然后尝试再次上载相同的.wlapp。 然后,Worklight Console被卡住,甚至
我进行了 LDAP 目录搜索并收到了一些结果。我需要迭代这些结果并显示每个条目的 Dn。 在我的测试环境中,我通过获取entryDN属性的值来返回Dn值。 在生产环境中,entryDN 属性始终返回
在调试器中,当执行这样一行代码时我“卡住”了:lock (myvar) 显然其他人持有myvar。但是我希望在这一行 myvar 应该是免费的。所以我想知道代码的哪一部分包含 myvar (来自另一个
我正在做一些序列化,其中还包含需要存储为字符串的 IFile 路径。 我在插件项目中使用这个 IFile。为调试或运行 Eclipse 启动一个新工作区。这个测试工作区的根目录相对于插件文件夹。我的问
我知道这个问题已经得到回答,但我不明白人们到底在做什么(关于证书,ssl),他们都使用本地主机而不是我。 我使用此示例作为示例 OpenIdConnect 我正在使用: 一个网络应用程序 一个 Web
我正在尝试获取当前星期以在SQLite中进行日期比较。 我上个月,去年,今天,昨天都没问题...但是找不到当前星期的解决方案。 我尝试了很多事情,例如: SELECT tastings.* FROM
我有兴趣将大部分使用Thrust GPU库编写的代码移植到多核CPU。值得庆幸的是,the website说推力代码可以与诸如OpenMP/Intel TBB之类的线程环境一起使用。 我在下面编写了一
我需要创建一个 PHP 应用程序,在给定主题标签的情况下,它会向我返回一个 XML,其中包含与该主题标签相关的帖子。 我在开发者部分登录 Instagram 并填写了应用程序设置表格。 已生成“客户端
当我从 Gradle 任务运行集成测试时,我的集成测试失败。 org.springframework.data.solr.UncategorizedSolrException: **SolrCore
这个问题已经有答案了: java.lang.IllegalStateException: Iterator already obtained (1 个回答) 已关闭 8 年前。 所以我写了一个小Jav
谁能告诉我为什么会出现以下异常? java.rmi.ServerException: RuntimeException; nested exception is: java.lang.Ille
当我尝试从 WCF 测试客户端运行我的应用程序时,我收到以下错误: Error: Cannot obtain Metadata from http://localhost:53867/MyAPI.sv
我有几个变量分配给同一个函数。属性“name”为“”,因为此函数是匿名的; 也没有涉及函数调用,因此没有被调用者。 JS有没有办法通过自己实现的反射算法获取变量名? 例如 var x = functi
只是想知道是否有人知道如何查询 Facebook Credits (FBC) API 以获取用户拥有的信用数?我的应用程序有此要求,并且 FBC API 中没有对此进行解释或提及。 谢谢 最佳答案 也
我正在使用 Spring Batch 3.0.5。关于 MySql 序列表的引擎类型的相同问题。与 spring-batch-storage-engine-as-myisam-than-innodb
我想我遗漏了一些明显的东西,但我就是想不通如何获取 CCMenuItemFont 的标签。 背景我正在为 iPad 构建一个简单的刽子手游戏。为了输入下一个猜测,我在 UI 中添加了 26 个按钮(每
我正在开发一个 Android 应用程序 (API 15) 并在尝试编写单元测试时遇到以下问题: 我使用 android.os.Parcel 来保存一个类(例如,如果屏幕翻转)并将它发送到另一个 Ac
我正在利用 C++ 全局变量的构造函数的行为在启动时以简单的方式运行代码。这是一个非常简单的概念,但有点难以解释,所以让我粘贴代码: struct _LuaVariableRegistration {
在 C# 中,如何获取对给定类的基类的引用? 例如,假设您有一个特定的类 MyClass,并且您想要获取对 MyClass 的父类(super class)的引用。 我的想法是这样的: Type s
我是一名优秀的程序员,十分优秀!