语音相似度打分技术说明【音频质量专题】

         

                 语音相似度打分技术说明【音频质量专题】

                                                                                                                                 

                                                                                                                                                           作者:灵声讯

                                                                                                                                                           时间:2018年8月30日

 


本内容全原创,因作者才疏学浅,偶有纰漏,望不吝指出。本内容由灵声讯音频-语音算法实验室整理创作,转载和使用请与“灵声讯”联系,联系方式:音频/识别/合成算法QQ群(696554058)


 

目录

1.语音相似度打分算法的背景和内容................................................................................ 3

1.1 背景................................................................................................................... 3

1.2内容.................................................................................................................... 3

2.算法原理与流程图........................................................................................................ 4

2.1 算法原理............................................................................................................ 4

2.2算法流程............................................................................................................. 5

3.接口文档...................................................................................................................... 7

3.1 接口说明............................................................................................................ 7

3.2 接口调用例程..................................................................................................... 7

3.2 宏定义说明........................................................................................................ 7

4.总结............................................................................................................................. 8

 

    语音相似度打分模块主要应用于语音监控设备和报警装置,目前更多适用于工厂设备的实时监控,作为视频监控的辅助,具有低成本,准确率高,容易实现等特点。同时语音相似度打分模块也可以应用在教育领域,辅助学生提升口语能力,模仿标准口音说话,例如在普通话发音不标准的地区,做到实时监测实时校正。

目前主要的相似度打分方法有如下几种:

  1. 直接根据语音信号本身做相似度匹配,获取相似比做打分计算;
  2. 基于语音识别技术的相似度打分算法;
  3. 以上二者相结合的混合型打分算法;

本内容实现的打分算法主要是第一种,方便在嵌入式设备和性能要求低的设备上使用。

     本技术通过对语音信号本身做相似度对比,因此必须要有参考信号,比对的方法就是依据参考信号,从时域和频域对待测信号做失真和扰动计算,最终由相似系数映射出百分制得分;

  • 2.算法原理与流程图

  • 2.1 算法原理

该算法思路最早是有英国人提出,后来经过多国研发人员的不断更新形成了现在完整的结构。它有着强大的功能,不仅能测试象解码器这样的网络单元的效果,也能测量端到端的声音质量;同时,能着重针对不同的信号退化原因,如编解码失真、错误、丢包、延时、抖动和过滤,给出测试结果,根据测得的系数映射成相似度得分。其中关键处理如下所述:

A.频域整形:主要包括电平调整和滤波

B.电平调整:不同的语音系统增益差别很大,当原始语音信号通过语音系统之后,信号电平发生了差异。为了便于比较,需要将二者调整到统一、恒定的电平上来。

C.IRS滤波:用修正的IRS滤波来模拟发送频率特性,该滤波特性充分考虑了原始语音信号的特性,得到的语音信号可以作为终端输出再反馈到网络中去。

D.时间对齐:1.预处理2.整体语音的时延估计3.语句的标识4.语句的延时估计5.语句分割等部分。

E.听觉转换:具体转换流程如下图1所示。

                                                      

                                                                                         图1. 听觉转换过程图

F.相似度失真模型:描述参考语音信号与失真语音信号在听觉变换过程中产生的干扰差,通过模拟不对称和对称语音信号不同部分的不同加权求解相关性。

                                             

                                                                                图2. 相似度失真模型求解图

2.2算法流程

                                                                

                                                                              图3 语音相似度算法打分流程图

1.待测语音/信号:输入对比的语音信号,会随着时间变化夹杂非        语音信号;

2.参考语音/信号:保留本地作为比对的参考语音信号;

  • 3.接口文档

  • 3.1 接口说明

  1. AudioSimilarity_Start() 此接口为初始化相似度计算模块和参考语音的加载启动,为了C#调用方便,初始化和释放接口都放在了核心主接口里面;
  2. AudioSimilarity_Process(const char *pRefFile, const char *pDeFile, int pSampleRate, float pSensitivity, char *pOutSimilarityScore); 此接口为核心处理接口,包括初始化,计算,接口释放等。

          pRefFile 参考信号路径;

          pDeFile 待测信号路径;

          pSampleRate:待测信号采样率,注保证与参考信号采样率相同;

          pSensitivity:相似度得分灵敏度调节系数,默认为0.8

          pOutSimilarityScore:应C#要求返回取整以后的字符型得分结果;

      3. AudioSimilarity_Destory() 此接口为模块销毁和释放。

具体接口文件如下:

/* audio_similarity.h
*
*  Copyright (c) 2018 The  project authors. All Rights Reserved.
*  Function: counting audio and voice similarity with audio_dsym,
*  audio_dasym and predict features (average compensation feature,
*  spectral gain_modulate feature,neteq feature and so on.)
*  Date   :2018-6-12
*  Version: v1.0.0.1
*
*/

#ifndef AUDIO_SIMILARITY_H_
#define AUDIO_SIMILARITY_H_

#if 1

#ifndef        DLL_EXPORT    
#define _LIBAPI __declspec(dllexport)    
#else    
#define _LIBAPI __declspec(dllimport)    
#endif 

#ifdef __cplusplus
extern "C" {
#endif

	/*
	* This function start and init AudioSimilarity
	*
	*
	* Return value         :  0 - Ok
	*                        -1 - Error
	*/
	_LIBAPI int AudioSimilarity_Start();


	/*
	* This function frees the dynamic memory of AudioSimilarity
	*
	*
	* Return value         :  0 - Ok
	*                        -1 - Error
	*/
	_LIBAPI int AudioSimilarity_Destory();


	/*
	* This functions do score of similiarity audio for the audio file. The
	* input and output signals should always be 16KHz/8KHz and 16bits.
	*
	* Input
	*      - pRefFile       : reference audio file.
	*      - pDeFile        : waiting process audio file
	*      - pSampleRate    : sample rate 8K/16K
	*      - pSensitivity   : sensitivity(0~1)
	*
	* Output:
	*      - pOutSimilarityScore : output similarity score
	*
	* Return value         :  0 - OK
	*                        -1 - Error
	*/

	_LIBAPI int AudioSimilarity_Process(const char *pRefFile, const char *pDeFile, int pSampleRate, float pSensitivity, char *pOutSimilarityScore);
	//_LIBAPI int AudioSimilarity_Process(const char *pRefFile, const char *pDeFile, int pSampleRate);


#ifdef __cplusplus
}
#endif

 

 

  • 3.2 接口调用例程

 

#include <math.h>
#include <stdlib.h>
#include <time.h>
#include <windows.h>
#include "../include/audio_similarity.h"
#include "../include/log.h"


#if 1
void usage(void) {
	printf("Usage:\n");
	printf(" AS HELP               Displays this text\n");
	printf(" AS [options] ref deg\n");
	printf(" Run model on reference ref and degraded deg\n");
	printf("\n");
}

int days = 0;
int months = 0;

void getNowTime()
{
	time_t timer;
	struct tm *tblock;
	timer = time(NULL);
	tblock = localtime(&timer);
	days = tblock->tm_mday;
	months = tblock->tm_mon;
	printf("Local time is: %s\n", asctime(tblock));
}

int main(int argc, const char *argv[])
{
	int i;
	for (i = 1; i <= 1; i++)
	{
		//printf("第 %d 次开始相似度计算!\n", i);
#ifdef AUDIO_SIMILARITY_LOG
		LogWrite(INFO, "第 %d 次开始相似度计算!", i);
#endif
		SYSTEMTIME sys;
		//argv[1] = "E:\\project\\audiosimilarity-1.0.1\\audiosimilarity\\audiosimilarity\\Debug\\20180627164926.wav";
		//argv[2] = "E:\\project\\audiosimilarity-1.0.1\\audiosimilarity\\audiosimilarity\\Debug\\20180627174153.wav";
		//const char *fp_ref = "E:\\project\\audiosimilarity-1.0.1\\audiosimilarity\\audiosimilarity\\Debug\\Audio.wav";
		//const char *fp_input = "E:\\project\\audiosimilarity-1.0.1\\audiosimilarity\\audiosimilarity\\Debug\\record3.wav";
		const char *fp_ref = argv[1];
		const char *fp_input = argv[2];
		int result = 0;
		//int sample_rate = 16000;
		float sensitivity = 0.8f;
		//float sensitivity = atoi(argv[4]) * (1.0f/10);
		int sample_rate = atoi(argv[3]);    //sample rate
		//double as_score = 0;
		char score[32] = {0};

		getNowTime();

		printf("days is %d , month is %d \n", days, months);

		result = AudioSimilarity_Start();
		if (result < 0)
		{
			printf("AudioSimilarity_Start is failed!\n");
		}

		//if (days < 16 && months < 6)

		GetLocalTime(&sys);
		printf("%s %d %s: %4d/%02d/%02d %02d:%02d:%02d.%03d week:%1d\n", __FILE__, __LINE__, __FUNCTION__, sys.wYear, sys.wMonth, sys.wDay, sys.wHour, sys.wMinute, sys.wSecond, sys.wMilliseconds, sys.wDayOfWeek);
		if (1)
		{
			//result = AudioSimilarity_Process(fp_ref, fp_input, sample_rate, &as_score);
			printf("Input sensitivity is %f.\n", sensitivity);
			//write_log(pFile,"Input sensitivity is %f.\n", sensitivity);
			result = AudioSimilarity_Process(fp_ref, fp_input, sample_rate, sensitivity, &score);
			//result = AudioSimilarity_Process(fp_ref, fp_input, sample_rate);
		}
		else
		{
			printf("Please contact to author, thank you! QQ number:245051943 or wechat:kinglongbest\n");
		}

		GetLocalTime(&sys);
		printf("%s %d %s: %4d/%02d/%02d %02d:%02d:%02d.%03d week:%1d\n", __FILE__, __LINE__, __FUNCTION__, sys.wYear, sys.wMonth, sys.wDay, sys.wHour, sys.wMinute, sys.wSecond, sys.wMilliseconds, sys.wDayOfWeek);

		if (result < 0)
		{
			printf("AudioSimilarity_process is failed!\n");
		}
		else
		{
			//printf("AudioSimilarity_process audio similarity score is %.3f \n",as_score);
			printf("AudioSimilarity_process audio similarity score is %s \n", score);
#ifdef AUDIO_SIMILARITY_LOG
			LogWrite(INFO, "%s", "AudioSimilarity_process audio similarity score is :");
			LogWrite(INFO, "%s", score);
#endif
		}

		result = AudioSimilarity_Destory();
		if (result < 0)
		{
			printf("AudioSimilarity_Destory is failed!\n");
		}

		//printf("请输入任意字符:\n");
		//printf("第 %d 次结束相似度计算!\n", i);
#ifdef AUDIO_SIMILARITY_LOG
		LogWrite(INFO, "第 %d 次结束相似度计算!", i);
#endif
		//getchar();

	}
	system("pause");
#ifdef AUDIO_SIMILARITY_LOG
	LogWrite(INFO,"%s", "Audio similarity is end !");
#endif
	return 0;

}

具体测试结果:

  •  3.3 宏定义介绍

       #define AUDIO_SIMILARITY_LOG   //是否输出log日志宏log.h文件中宏定义介绍 

#define AUDIO_SIMILARITY_TIME  //是否打印目前时间记录优化时间audio_similarity.c

     语音相似度打分算法目前已编译成lib,dll等库在C#和其他平台调用,打分可以根据灵敏度来自动调节,最终是否报警需根据实际场景测试数据设定阈值,只要得分高于阈值就可以说明设备异常。后期基于语音识别技术的相似度打分算法还在开发过程中,有效果以后可以及时更新。

附件为最后一次打包的库:

 

#######################################################################

 本内容由灵声讯音频-语音算法实验室开发完成,需要源码和技术文档等合作事宜

 请与“灵声讯”联系,联系方式:音频/识别/合成算法QQ群(696554058

#######################################################################

模块功能:语音相似度打分算法

作者/版权:归灵声讯所有

日期    2018-08-30

#######################################################################

运行步骤:直接双击bat批处理就可以

参数说明:

        输入:参数1为参考语音,参数2为待测语音,参数3为采样率

        输出:相似度得分score

注:得分全部采用百分制,参考语音和待测语音采样率必须一致

########################################################################

加群和关注公众号请戳下面:

 

                                                                        https://i-blog.csdnimg.cn/blog_migrate/e06358e858f01b2a788f7228b056b857.jpeg

# MOS-PESQ The project is a tool that can get MOS(PESQ) score for the voice. PESQ measure: ------------- Usage of the PESQ objective measure is as follows: [pesq_mos]=pesq(cleanfile.wav,enhanced.wav) where 'cleanfile.wav' contains the clean speech file and 'enhanced.wav' contains the enhanced file. Example: To run the PESQ objective measure with the example files provided, type in MATLAB: >> pesq('sp09.wav','enhanced_logmmse.wav') ans = 2.2557 Source code for the PESQ implementation is available from a CD-ROM included in the following book: Loizou, P. (2007) "Speech enhancement: Theory and Practice", CRC Press. COMPOSITE MEASURE: ----------------- Usage: [Csig,Cbak,Covl]=composite(cleanfile.wav,enhanced.wav) where 'Csig' is the predicted rating of speech distortion 'Cbak' is the predicted rating of background distortion 'Covl' is the predicted rating of overall quality. You may run example files included in the zip file. In MATLAB, type: >> [c,b,o]=composite('sp09.wav','enhanced_logmmse.wav') LLR=0.681368 SNRseg=3.991727 WSS=49.671978 PESQ=2.255732 c = 3.3050 b = 2.6160 o = 2.7133 where 'sp09.wav' is the clean file and 'enhanced_logmmse.wav' is the enhanced file. The predicted ratings for overall quality was 2.7133, for background was 2.61 and for signal distortion it was 3.3050. Operating steps: ----------------- >> ./matlab-PESQ/readme.txt Thank: ----------------- Any questions, please E_mail: kinglongbest@163.com/245051943@qq.com 操作步骤 1.将所录序列加载如当前工作路径,也可以按自己工作路径自行加载; 2.在read.m中修改参考序列,默认为ref.wav,16KHz采样; 3.利用wavdivide.m对所录多组序列文件进行拆分(支持多种采样频率),并按序保证至当前路径; 4.运行tongji.m计算PESQ_MOS得分并通过excel/txt输出至指定路径; NOTE: 对于步骤4,每次执行记得修改excel中输出列位置,如cellnames2=['B',num2str(k+1),':B',num2str(k+1)];, 指定写入B列,下次执行改为C列,以此类推; 其中ref_8k.wav为8KHz采样测试序列,ref.wav为16KHz,ref_3s.wav只是为方便测试在ref.wav语音前加3s静音;
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值