当前位置:主页 > 查看内容

如何三步搭建一套声纹系统

发布时间:2021-04-25 00:00| 位朋友查看

简介:def get_vector(sound, model_id i-vector ): url http://47.111.21.183:18089/demo/vdb/v1/retrieve d { resource : sound, model_id : model_id} r requests.post(url, data d) js json.loads(r.text) return np.array(js[ emb ])# 读取用户文件。file xxx.……
def get_vector(sound, model_id i-vector ): url http://47.111.21.183:18089/demo/vdb/v1/retrieve d { resource : sound, model_id : model_id} r requests.post(url, data d) js json.loads(r.text) return np.array(js[ emb ]) # 读取用户文件。 file xxx.wav data f.read() print(get_vector(data)) f.close()

在初始化的过程中 用户创建相关的用户声纹表。同时 给表的向量列加入向量索引 来加速查询过程。当前声纹模型输出的都是400维的向量 所以索引参数dim设置为400。

--创建用户声纹表
CREATE TABLE person_voiceprint_detection_table(
 id serial primary key, 
 name varchar,
 voiceprint_feature float4[]
--创建向量索引
CREATE INDEX person_voiceprint_detection_table_idx 
ON person_voiceprint_detection_table 
USING ann(voiceprint_feature) 
WITH(distancemeasure L2,dim 400,pq_segments 40);

第二步 注册用户声音。

在注册的过程中 注册一个用户 插入一条记录到当前系统中。

--注册用户 张三 到当前的系统中。
--通过HTTP服务 将声纹转化成相关的向量。
INSERT INTO person_voiceprint_detection_table(name, voiceprint_feature)
SELECT 张三 , array[-0.017,-0.032,...]::float4[])

第三步 检索或验证用户声音。

声纹门锁验证 1:1 验证 在验证系统中 系统会得到用户的标识信息 user_id 在声纹库中计算输入的声音向量和库里该用户的声音向量的距离。一般系统会设置一个距离阈值 threshold 550 如果向量之间的距离大于这个阈值 说明验证失败。如果小于阈值 说明声纹验证成功。

-- 声纹门锁检测(1:1)验证
SELECT id, -- 用户id信息
 name, -- 用户姓名
 l2_distance(voiceprint_feature, ARRAY[-0.017,-0.032,...]::float4[]) AS distance -- 向量距离 
FROM person_voiceprint_detection_table -- 用户声音表
WHERE distance threshold -- 通常情况下 threshold为550 
 AND id user_id -- 用户要验证的id;

会议声纹检索 1:N 检测 系统通过识别当前讲话人的声音 会返回最相关的注册用户信息。如果没有返回结果 说明当前会议说话人不在声纹库里面。

-- 声纹会议人员识别(1:N)验证
SELECT id, -- 用户id信息
 name, -- 用户姓名
 l2_distance(voiceprint_feature, ARRAY[-0.017,-0.032,...]::float4[]) AS distance -- 向量距离 
FROM person_voiceprint_detection_table -- 用户声音表
WHERE distance threshold -- 通常情况下 threshold为550 
ORDER BY voiceprint_feature - ARRAY[-0.017,-0.032,...]::float4[] -- 利用向量进行排序
LIMIT 1; -- 返回最相似的结果
结尾

详细的声纹模型以及相关的AnalyticDB系统请加我们的钉钉群 欢迎大家讨论和使用。

image.png

参考文献

[1] Aishell Data set. https://www.openslr.org/33/

[2] TIMIT Data set.

http://academictorrents.com/details/34e2b78745138186976cbc27939b1b34d18bd5b3/

[3] Najim Dehak, Patrick Kenny, Réda Dehak, Pierre Dumouchel, and Pierre Ouellet, “Front-end factor analysis for speaker verification,” IEEE Transactions on Audio, Speech, and Language Processing, vol. 19, no. 4, pp. 788–798, 2011.

[4] David Snyder, Daniel Garcia-Romero, Daniel Povey and Sanjeev Khudanpur, “Deep Neural Network Embeddings for Text-Independent Speaker Verification”, Interspeech , 2017 :999-1003.

[5] Anton, Howard (1994), Elementary Linear Algebra (7th ed.), John Wiley Sons, pp. 170–171, ISBN 978-0-471-58742-2

往期文献

[1] 戴口罩也能刷门禁 疫情下AnalyticDB亮出社区管理的宝藏神器 https://developer.aliyun.com/article/745160

[2] 阿里云提供高效基因序列检索功能 助力冠状病毒序列快速分析

https://developer.aliyun.com/article/753097

[3] 阿里云提供高效病原体检测工具助力精准医疗

https://yq.aliyun.com/articles/761891


本文转自网络,原文链接:https://developer.aliyun.com/article/783763
本站部分内容转载于网络,版权归原作者所有,转载之目的在于传播更多优秀技术内容,如有侵权请联系QQ/微信:153890879删除,谢谢!

推荐图文

  • 周排行
  • 月排行
  • 总排行

随机推荐