LBG算法实现语音信号的矢量量化
基于LBG的矢量量化图像压缩编码实验

基于LBG 的矢量量化图像压缩编码实验一、实验原理矢量量化:要想得到好的性能编码,仅采用标量量化是不可能的。
当把多个信源符号联合起来形成多维矢量,再对矢量进行标量量化时自由度将更大,同样的失真下,量化基数可进一步减少,码率可进一步压缩。
这种量化叫矢量量化。
应用:在航天、军事、气象、医学、多媒体等领域中经常需要大量存储和传输各种静态图像和视频图像。
为了提高传输效率和减少存储空间,必须采取有效的压缩编码算法消除图像中所包含的各种冗余信息并在给定的失真条件下使用尽量少的比特数来描述图像。
矢量量化(VQ)作为一种有效的有损压缩技术,其突出优点是压缩比大以及解码算法简单,因此它已经成为图像压缩编码的重要技术之一。
矢量量化压缩技术的应用领域非常广阔,如军事部门和气象部门的卫星(或航天飞机)遥感照片的压缩编码和实时传输、雷达图像和军用地图的存储与传输、数字电视和DVD 的视频压缩、医学图像的压缩与存储、网络化测试数据的压缩和传输、语音编码、图像识别和语音识别等等。
LGB 算法:一种有效和直观的矢量量化码书设计算法——LBG 算法(也叫GLA 算法)是由Linde 、Buzo 和Gray 于1980年首先提出来的。
该算法基于最佳矢量量化器设计的最佳划分和最佳码书这两个必要条件,且是Lloyd 算法在矢量空间的推广,其特点为物理概念清晰、算法理论严密及算法实现容易。
设训练矢量集为{}110,,,-=M x x x X ,待产生的码书为{}110,,,-=N y y y C ,其中{})1(10,,,-=k i i i i x x x x ,{})1(10,,,-=k j j j j y y y y ,10,10-≤≤-≤≤N j M i ,则码书设计过程就是需求把训练矢量集X 分成N 个子集)1,,1,0(-=N j S j 的一种最佳聚类方案,而子集j S 的质心矢量j y 作为码字。
假设平方误差测度用来表征训练矢量i x 和码字j y 之间的失真,即:∑-=-=12)(),(k l jl il j i y x y x d则码书设计的准则可用下列数学形式表达: 最小化 ∑∑-=-==1010),(),,(N j M i j i ij y x d w C X W f约束条件∑-==11N j ijw,10-≤≤M i其中W 为N M ⨯矩阵,其元素满足:⎩⎨⎧=01ij w j i j i S x S x ∉∈矩阵W 可看作训练矢量的聚类结果。
语音信号矢量量化

16
二、LBG算法 算法 1980年由 年由Linde,Buzo和Gray提出, 提出, 年由 , 和 提出 在矢量量化中是一个基本算法。 在矢量量化中是一个基本算法。整个算法 实际就是上述两个寻找最佳码书的必要条 件的反复迭代过程, 件的反复迭代过程,即由初始码书使码书 逐步优化,寻找最佳码书的迭代过程。 逐步优化,寻找最佳码书的迭代过程。
13
最佳矢量量化器和码本的设计
一、矢量量化器最佳设计 最佳设计就是使失真最小的设计 最佳设计就是使失真最小的设计 最佳设计中,重要的问题是如何划分量 最佳设计中,重要的问题是如何划分量 化区间和确定量化矢量。 化区间和确定量化矢量。 两个条件回答了两个问题 回答了两个问题。 这两个条件回答了两个问题。 一、最佳划分 二、最佳码书
14
最佳矢量量化器满足的两个必要条件 最佳矢量量化器满足的两个必要条件 1)Voronoi分割条件(最近邻准则) ) 分割条件( 分割条件 最近邻准则) 对信号空间的分割应满足
Sl = { X ∈ R K : d ( X , Yl ) ≤ d ( X , Yi ); i ≠ l}
根据该条件可以对信号空间进行最佳划分, 根据该条件可以对信号空间进行最佳划分, 得到的 S l 称为一个胞腔
22
谢谢! 谢谢!
23
δ
18
第二步: 第二步:迭代 1)根据最近邻准则将S分成 个子集 S1 m ) , )根据最近邻准则 最近邻准则将 分成 分成N个子集 (
( S 2m ) ,┅, Nm ) , 即当 X ∈ S1( m )时,下式成 S(
立: d ( X , Yl( m −1) ≤ d ( X , Yi( m −1) ), ∀i , j = l 2)计算失真: )计算失真:
矢量量化与语音信号处理

x
码字c2
4 34 1
212 3 码字c3
码书
4
d ( X , C) (xi ci )2 i 1
d(x,c0)=5 d(x,c1)=11 d(x,c2)=8 d(x,c3)=8
✓ 图像编码例子: 原图象块(4灰度级,矢量维数 k=4×4=16)
x
0
1
2
3
码书C ={y0, y1 , y2, y3}
Xi
矢量
Yj
量化器
4.判断规则
当给矢量量化器输入一种任意矢量Xi进行矢 量量化时,矢量量化器首先判断它属于那个子空 间,怎样判断就是要根据一定旳规则,选择一种 合适旳失真测度,分别计算每个码字替代Xi所带 来旳失真,当拟定产生最小失真旳那个码字Yj时, 就将Xi量化成Yj, Yj就是Xi旳重构矢量(和恢复 矢量)。
码本
Y1 Y2
码本
Y1 Y2
语音
YJ
信号
帧
特征 矢量
Xi
VQ 编码
V
形成
器
传播 或
V
存储
YJ
VQ Yj 译码
器
矢量量化在语音通信中旳应用
✓矢量量化编码与解码构造图:
编码 器
解码 器
信 输入 源 矢量
索引 近来邻 搜索
信道
索引
查表
输出 信 矢量 宿
码书
码书
用LBG(GLA)算 法生成
N个特征矢量 wen {X1 , X2 , … , XN}
xL
xa1
xak
xak+1
xaL
xaL+1
1-dimensional VQ is shown below:
电气工程及其自动化(LBG算法的语音识别)外文翻译文献

文献信息:文献标题:Speech Recognition Using Vector Quantization through Modified K-meansLBG Algorithm(基于改进矢量量化K-均值LBG算法的语音识别)国外作者:Balwant A.Sonkamble,Dharmpal Doye文献出处:《Computer Engineering and Intelligent Systems》, 2012, 7(3) 字数统计:英文2389单词,13087字符;中文3968汉字外文文献:Speech Recognition Using Vector Quantization throughModified K-meansLBG AlgorithmAbstract In the Vector Quantization, the main task is to generate a good codebook. The distortion measure between the original pattern and the reconstructed pattern should be minimum. In this paper, a proposed algorithm called Modified K-meansLBG algorithm used to obtain a good codebook. The system has shown good performance on limited vocabulary tasks.Keywords: K-means algorithm, LBG algorithm, Vector Quantization, Speech Recognition1.IntroductionThe natural way of communication among human beings is through speech. Many human beings are exchanging the information through mobile phones as well as other communication tools in a real manner [L. R. Rabiner et al., 1993]. The Vector Quantization (VQ) is the fundamental and most successful technique used in speech coding, image coding, speech recognition, and speech synthesis and speaker recognition [S. Furui, 1986]. These techniques are applied firstly in the analysis of speech where the mapping of large vector space into a finite number of regions in thatspace. The VQ techniques are commonly applied to develop discrete or semi-continuous HMM based speech recognition system.In VQ, an ordered set of signal samples or parameters can be efficiently coded by matching the input vector to a similar pattern or codevector (codeword) in a predefined codebook [[Tzu-Chuen Lu et al., 2010].The VQ techniques are also known as data clustering methods in various disciplines. It is an unsupervised learning procedure widely used in many applications. The data clustering methods are classified as hard and soft clustering methods. These are centroid-based parametric clustering techniques based on a large class of distortion functions known as Bregman divergences [Arindam Banerjee et al., 2005].In the hard clustering, each data point belongs to exactly one of the partitions in obtaining the disjoint partitioning of the data whereas each data point has a certain probability of belonging to each of the partitions in soft clustering. The parametric clustering algorithms are very popular due to its simplicity and scalability. The hard clustering algorithms are based on the iterative relocation schemes. The classical K-means algorithm is based on Euclidean distance and the Linde-Buzo-Gray (LBG) algorithm is based on the Itakura-Saito distance. The performance of vector quantization techniques depends on the existence of a good codebook of representative vectors.In this paper, an efficient VQ codebook design algorithm is proposed known as Modified K-meansLBG algorithm. This algorithm provides superior performance as compared to classical K-means algorithm and the LBG algorithm. Section-2 describes the theoretical details of VQ. Section-3 elaborates LBG algorithm. Section-4 explains classical K-means algorithm. Section -5 emphasizes proposed modified K-meansLBG algorithm. The experimental work and results are discussed in Section-6 and the concluding remarks made at the end of the paper.2.Vector QuantizationThe main objective of data compression is to reduce the bit rate for transmission or data storage while maintaining the necessary fidelity of the data. The feature vectormay represent a number of different possible speech coding parameters including linear predictive coding (LPC) coefficients, cepstrum coefficients. The VQ can be considered as a generalization of scalar quantization to the quantization of a vector. The VQ encoder encodes a given set of k-dimensional data vectors with a much smaller subset. The subset C is called a codebook and its elements i C are called codewords, codevectors, reproducing vectors, prototypes or design samples. Only the index i is transmitted to the decoder. The decoder has the same codebook as the encoder, and decoding is operated by table look-up procedure.The commonly used vector quantizers are based on nearest neighbor called V oronoi or nearest neighbour vector quantizer. Both the classical K-means algorithm and the LBG algorithm belong to the class of nearest neighbor quantizers.A key component of pattern matching is the measurement of dissimilarity between two feature vectors. The measurement of dissimilarity satisfies three metric properties such as Positive definiteness property, Symmetry property and Triangular inequality property. Each metric has three main characteristics such as computational complexity, analytical tractability and feature evaluation reliability. The metrics used in speech processing are derived from the Minkowski metric [J. S. Pan et al. 1996]. The Minkowski metric can be expressed as∑=-=k i p i i p y xp Y X D 1),(Where },...,,{21k x x x X = and },...,,{21k y y y Y = are vectors and p is the order of the metric.The City block metric, Euclidean metric and Manhattan metric are the special cases of Minkowski metric. These metrics are very essential in the distortion measure computation functions.The distortion measure is one which satisfies only the positive definiteness property of the measurement of dissimilarity. There were many kinds of distortion measures including Euclidean distance, the Itakura distortion measure and the likelihood distortion measure, and so on.The Euclidean metric [Tzu-Chuen Lu et al., 2010] is commonly used because it fits the physical meaning of distance or distortion. In some applications division calculations are not required. To avoid calculating the divisions, the squared Euclidean metric is employed instead of the Euclidean metric in pattern matching.The quadratic metric [Marcel R. Ackermann et al., 2010] is an important generalization of the Euclidean metric. The weighted cepstral distortion measure is a kind of quadratec metric. The weighted cepstral distortion key feature is that it equalizes the importance in each dimension of cepstrum coefficients. In the speech recognition, the weighted cepstral distortion can be used to equalize the performance of the recognizer across different talkers. The Itakura-Saito distortion [Arindam Banerjee et al., 2005] measure computes a distortion between two input vectors by using their spectral densities.The performance of the vector quantizer can be evaluated by a distortion measureD which is a non-negative cost )ˆ,(j j X X Dassociated with quantizing any input vector j Xwith a reproduction vecto j X ˆ. Usually, the Euclidean distortion measure is used. The performance of a quantizer is always qualified by an average distortion)]ˆ,([j j v X X D E Detween the input vectors and the final reproduction vectors, where E represents the expectation operator. Normally, the performance of the quantizer will be good if the average distortion is small.Another important factor in VQ is the codeword search problem. As the vector dimension increases accordingly the search complexity increases exponentially, this is a major limitation of VQ codeword search. It limits the fidelity of coding for real time transmission.A full search algorithm is applied in VQ encoding and recognition. It is a time consuming process when the codebook size is large.In the codeword search problem, assigning one codeword to the test vector means the smallest distortion between the codeword and the test vector among all codewords. Given one codeword t C and the test vector X in the k-dimensional space,the distortion of the squared Euclidean metric can be expressed as follows:∑=-=ki i t i t c x C X D 12)(),(Where },......,,{21k t t t t c c c C = and },......,,{2,1k x x x X =There are three ways of generating and designing a good codebook namely the random method, the pair-wise nearestneighbor clustering and the splitting method. A wide variety of distortion functions, such as squared Euclidean distance, Mahalanobis distance, Itakura-Saito distance and relative entropy have been used for clustering. There are three major procedures in VQ, namely codebook generation, encoding procedure and decoding procedure. The LBG algorithm is an efficient VQ clustering algorithm. This algorithm is based either on a known probabilistic model or on a long training sequence of data.3.Linde –Buzo –Gray (LBG) algorithmThe LBG algorithm is also known as the Generalised Lloyd algorithm (GLA). It is an easy and rapid algorithm used as an iterative nonvariational technique for designing the scalar quantizer. It is a vector quantization algorithm to derive a good codebook by finding the centroids of partitioned sets and the minimum distortion partitions. In LBG , the initial centroids are generated from all of the training data by applying the splitting procedure. All the training vectors are incorporated to the training procedure at each iteration. The GLA algorithm is applied to generate the centroids and the centroids cannot change with time. The GLA algorithm starts from one cluster and then separates this cluster to two clusters, four clusters, and so on until N clusters are generated, where N is the desired number of clusters or codebook size. Therefore, the GLA algorithm is a divisive clustering approach. The classification at each stage uses the full-search algorithm to find the nearest centroid to each vector. The LBG is a local optimization procedure and solved through various approaches such as directed search binary-splitting, mean-distance-ordered partial codebook search [Linde et al., 1980, Modha et al., 2003], enhance LBG , GA-based algorithm[Tzu-Chuen Lu et al., 2010, Chin-Chen Chang et al. 2006], evolution-based tabu search approach [Shih-Ming Pan et al., 2007], and codebook generation algorithm[Buzo et al., 1980].In speech processing, vector quantization is used for instance of bit stream reduction in coding or in the tasks based on HMM. Initialization is an important step in the codebook estimation. Two approaches used for initialization are Random initialization, where L vectors are randomly chosen from the training vector set and Initialization from a smaller coding book by splitting the chosen vectors.The detailed LBG algorithm using unknown distribution is described as given below: Step 1: Design a 1-vector codebook. Set m=1. Calculate centroid∑==T j j X TC 111 Where T is the total number of data vectors.Step 2: Double the size of the codebook by splitting.Divide each centroid i C into two close vectors )1(12δ+⨯=-i i C C and m i C C i i ≤≤-⨯=1),1(2δ. Here δ is a small fixed perturbation scalar.Let m=2m . Set n=0 , here n is the iterative time.Step 3: Nearest-Neighbor Search.Find the nearest neighbor to each data vector. Put j Xin the partitioned set i P if i C is the nearest neighbor to j X .Step 4: Find Average Distortion.After obtaining the partitioned sets)1,(m i P P i ≤≤=, Set n=n+1 Calculate the overall average distortion∑∑--=m i T j i i j n i C D TD 11)(),(1 Where },......,,{)()(2)(1i T i i i iX X X P =Step 5: Centroid Update.Find centroids of all disjoint partitioned sets i P by∑-=i T j i j i i X T C 1)(1Step 6: Iteration 1.If ε>--n n n D D D /)(1 , go to step 3;otherwise go to step 7 and ε is a threshold.Step 7: Iteration 2.If m=N , then take the codebook i C as the final codebook; otherwise, go to step 2.Here N is the codebook size.The LBG algorithm has limitations like the quantized space is not optimized at each iteration and the algorithm is very sensitive to initial conditions.4.Classical K-means AlgorithmThe K-means algorithm is proposed by MacQueen in 1967. It is a well known iterative procedure for solving the clustering problems. It is also known as the C-means algorithm or basic ISODATA clustering algorithm. It is an unsupervised learning procedure which classifies the objects automatically based on the criteria that minimum distance to the centroid. In the K-means algorithm, the initial centroids are selected randomly from the training vectors and the training vectors are added to the training procedure one at a time. The training procedure terminates when the last vector is incorporated. The K-means algorithm is used to group data and the groups can change with time. The algorithm can be applied to VQ codebook design. The K-means algorithm can be described as follows:Step 1: Randomly select N training data vectors as the initial codevectors N i C i ,......,2,1,=from T training data vectors. Step 2: For each training data vector T j X j ,......,2,1,= assign j X to thepartitioned set i S if ),(min arg i j i C X D i =Step 3: Compute the centroid of the partitioned set that is codevector using ∑∈=i j S X j i i XS C 1Where i S denotes the number of training data vectors in the partitioned seti S . If there is no change in the clustering centroids, then terminate the program; otherwise, go to step 2.There are various limitations of K-means algorithm. Firstly, it requires large data to determine the cluster. Secondly, the number of cluster, K, must be determined beforehand. Thirdly, if the number of data is a small it difficult to find real cluster and lastly, as per assumption each attribute has the same weight and it quite difficult to knows which attribute contributes more to the grouping process.It is an algorithm to classify or to group objects based on attributes/features into K number of group. K is positive integer number. The grouping is done by minimizing the sum of squares of distances between data and the corresponding cluster centroid. The main aim of K-mean clustering is to classify the data. In practice, the number of iterations is generally much less than the number of points.5.Proposed Modified K-meansLBG AlgorithmThe proposed algorithms objective is to overcome the limitations of LBG algorithm and K-means algorithm. The proposed modified KmeansLBG algorithm is the combination of advantages of LBG algorithm and K-means algorithms. The KmeansLBG algorithm is described as given below:Step 1: Randomly select N training data vectors as the initial codevectors. Step 2: Calculate the no. of centroids.Step 3: Double the size of the codebook by splitting. Step 4: Nearest-Neighbor Search.Step 5: Find Average Distortion.Step 6: Update the centroid till there is no change in the clustering centroids,terminate the program otherwise go to step 1.6.Experimentation and ResultsThe TI46 database [NIST, 1991] is used for experimentation. There are 16 speakers from them 8 male speakers and 8 female speakers. The numbers of replications are 26 for utterance by each person. The total database size is 4160 utterances of which 1600 samples were used for training and remaining samples are used for testing of 10 words that are numbers in English 1 to 9 and 0 are sampled at a rate of 8000 Hz. A feature vector of 12-dimensional Linear Predicting Coding Cepstrum coefficients was obtained and provided as an input to vector quantization to find codewords for each class.There are five figures shows comparative graphs of the distortion measure obtained using LBG algorithm and K-means algorithm and proposed K-meansLBG algorithm. The distortion measure obtained by the proposed algorithm is smallest as compared to the K-means algorithm and the LBG algorithm.The proposed modified KmeanLBG algorithm gives minimum distortion measure as compared to K-means algorithm and LBG algorithm to increase the performance of the system. The smallest measure gives superior performance as compared to both the algorithms as is increased by about 1% to 4 % for every digit.7.ConclusionThe Vector Quantization techniques are efficiently applied in the development of speech recognition systems. In this paper, the proposed a novel vector quantization algorithm called K-meansLBG algorithm. It is used efficiently to increase the performance of the speech recognition system. The recognition accuracy obtained using K-meansLBG algorithm is better as compared to K-means and LBG algorithm. The average recognition accuracy of K-meansLBG algorithm is more than 2.55% using K-means algorithm while the average recognition accuracy of K-meansLBG algorithm is more than 1.41% using LBG algorithm.中文译文:基于改进矢量量化K-均值LBG算法的语音识别摘要矢量量化的主要任务是产生良好的码本。
自适应矢量量化在语音识别中的应用

自适应矢量量化在语音识别中的应用于倩;李春利【摘要】介绍了用离散隐马尔可夫模型(DHMM)构造孤立词语音识别系统中的特征向量矢量量化的码书构造过程.以往的矢量量化通常采用基本算法LBG,在此基础上,引入了一种时间复杂性和空间复杂性有所降低的改进算法.该算法的核心是自适应地生成初始码书以及对初始码书的二次构造过程.从降低时间复杂度和节省存储空间,提高识别率的角度,对该算法进行了讨论.【期刊名称】《现代电子技术》【年(卷),期】2007(030)006【总页数】3页(P128-130)【关键词】语音识别;矢量量化;LBG;自适应码书【作者】于倩;李春利【作者单位】中国民航大学计算机学院,天津,300300;哈尔滨工程大学自动化学院,黑龙江哈尔滨,150001【正文语种】中文【中图分类】TP3911 引言现代语音识别中最常用的识别方法是Baum等人提出的隐马尔可夫模型(HMM)。
HMM是数学上一类重要的双重随机模型,用概率统计的方法描述时变语音信号,很好地描述了语音信号的整体非平稳性和局部平稳性。
HMM的各状态对应语音信号的各平稳段,各状态之间以一定转移概率相联系,是一种较为理想的语音模型。
在孤立词语音识别过程中,通常采用离散隐马尔可夫模型(DHMM),取得了比较好的实用效果[1,2]。
在构造离散隐马尔可夫模型(DHMM)过程中,对提取的MFCC特征参数矢量量化的码书构造是其中的一个主要部分,码书的选择会影响时间和空间的复杂度以及整个系统的识别率。
目前为止,矢量量化的方法很多,其中最典型的是1980年,Linde,Buzo和Gray提出的LBG算法[3]。
他可根据给定的训练序列,经多次递归运算,求出满足要求的码书和输入矢量的划分。
LBG算法的突出优点是压缩比大且解码算法简单,已被广泛应用于语音识别或图像编码等领域。
2 LBG算法LBG算法是一种有效和直观的矢量量化码书设计算法,其具体算法描述如下[4]:设训练矢量集为X={x0,x1,…,xM-1},M为训练矢量的个数。
语音信号

最佳矢量量化器码本设计(学生姓名:郝宾学院:信息工程学院学号:201010203012班级:电子10-1授课教师:杨玉兰一矢量量化矢量量化(Vector Quantization,VQ)技术是20世纪70年代后期发展起来的一种数据压缩和编码技术,广泛应用于语音编码、语音合成、语音识别和说话人识别等领域。
矢量量化在语音信号处理中占有十分重要的地位,在许多重要的研究课题中,矢量量化都起着非常重要的作用。
1、矢量的定义若干个标量数据组成一个矢量,标量的个数就为矢量的维数。
如语音信号某一帧中提取的声道参数,共K个,Xi={ai1,ai2,…,aiK}。
则Xi是一个K维矢量。
设共有N个K维矢量X={X1,X2,…,XN},其中第i个矢量为Xi,i=1,2,…N。
类比过来,N个语音帧,每帧中共有K个声道参数,共组成N个K维矢量。
2、矢量空间的划分把K维欧几里德空间无遗漏的划分为J个互不相交的子空间R1,R2…RJ , 这些子空间Rj称为胞腔。
在每一个子空间Rj找一个代表矢量Yj ,则J个代表矢量可以组成矢量集为Y={Y1,Y2,…,YJ}这样就组成了一个矢量量化器,在矢量量化里Y叫做码书或码本;Yj 称为码矢或码字;Y内矢量的个数J则叫做码本长度或者码本尺寸。
3、矢量量化的过程当给矢量量化器输入一个任意矢量进行矢量量化时,矢量量化器首先判断它属于哪个子空间Rj ,然后输出该子空间Rj的代表矢量Yj。
矢量量化过程就是用Yj代替Xi的过程,或者说把Xi量化成了Yj ,即Yj=Q(Xi),1 j J,1 i N式中,Q(Xi)为量化器函数。
从而矢量量化的全过程完成一个从K维欧几里德空间中的矢量Xi到K维空间有限子集Y的映射二矢量量化器1 矢量量化器的定义维数为k,码本长度为J的矢量量化器Q定义为:从k维欧几里德空间R k到一包含J个输出(重构)点的有限集合C的映射,Q:R k→C,其中C={y1 ,y2 ,… ,y J}Y i 属于R k,i=1,…,J集合C称作码本或码书,码本长度为J 。
语音信号矢量量化设计及实现算法的matlab仿真毕业设计说明书

引言21世纪是信息的社会,各类科技领域的信息大爆炸。
数字信号的数据量通常很庞大,对存储器的存储容量,通信信道的带宽及运算机的处置速度带来压力,因此必需对其进行量化紧缩来紧缩数据存储容量,较快地传输各类信号 ,并使发信机功率降低。
矢量量化(VQ)是一种极为重要的信号紧缩方式,其在语音信号处置中占有十分重要的地位,广泛应用于语音编码,语音识别,语音合成等领域。
在许多重要的课题中,VQ都起着超级重要的作用。
采纳矢量量化技术对信号波形或参数进行紧缩处置,能够取得超级高的效益。
VQ不仅能够紧缩表示语音参数所需的数码率,而且在减少运算量方面也是超级高效的,它还能直接用于组成语音识别和说话人识别系统。
语音数字通信的两个关键部份是语音质量和传输数码率。
但这二者是矛盾的:要取得较高的语音质量,就必需利用较高的传输码率;相反,为了实现高效地紧缩传输数码率,就很难取得良好的语音质量。
可是矢量量化却是一种既能取得高效紧缩的数码率,又能保证语音质量的方式。
量化能够分为两大类:一类是标量量化,一类是矢量量化VQ。
标量量化是把抽样后的信号值逐个进行量化,而矢量量化是先将k个抽样值组成k 维空间中的一个矢量,然后将此矢量进行量化,它能够极大的降低数码率,优于标量量化。
各类数据都能够用矢量表示,直接对矢量进行量化,能够方便的对数据进行紧缩。
矢量量化属于不可逆紧缩方式,具有比特率低,解码简单,失真较小的优势。
矢量量化的进展大致能够分为两各时期:第一时期约为1956至1977年。
1956年steinhaus第一次系统的论述了最正确矢量量化的问题。
1957年,在loyd的“PCM中的最小平方化”一文中给出了如何划分量化区间和如何求量化值问题的结论。
约于此同时MAX也得出一样的结果。
尽管他们谈论的都是标量量化问题,但他们的算法对后面的矢量量化的进展有着深刻的阻碍。
1964年,NEWMAN研究了正六边形原理。
1977年,berger的‘率失真理论’一书出版。
语音信号矢量量化器的设计及实现算法

第一章 矢量量化器概述 1.1矢量量化概述
矢量量化的研究意义:
21世纪是信息的社会,各种科技领域的信息大爆炸。 数字信号的数据量通常很巨大,对存储器的存储容量,通 信信道的带宽及计算机的处理速度带来压力,因此必须对 其进行量化压缩来紧缩数据存储容量 ,较快地传Βιβλιοθήκη 各种 信号 ,并使发信机功率降低 。
若D 的y
(n)
D
(n)
1 m
r 1
m
m in d ( X r , Y )
Y yN
(n)
D
(n)
D
( n 1 )
D
(n)
(n)
D
N
yN
(n L)
,则停止计算,当前的码书 y ,否则进行第四步;
利用公式
Y 1 Si
(n) N
是设计好
第四步
x S i
X
计算这时划分的各个
2
摘要
本设计基于对矢量量化器的基本理论和结构 的学习,重点研究了矢量量化器设计中最重要的 步骤——码书设计。本设计运用MATLAB仿真实 现了三种算法:LBG算法,成对最邻近(PNN)算 法和覆盖算法,并在对实际语音信号进行仿真的 过程中,通过改变语音数据量大小,码书维数, 量化压缩比等参数,比对分析实验结果的数据, 本设计对各算法的实现过程和性能特点进行了深 入的分析。本设计对矢量量化的研究和应用,都 着实际的参考意义。
i
2
i
j
若j=n-1,则从码书中去掉码字 y j ;否则令 y j y n 1, R j R n 1 从码书中去掉码字 y ,令n=n-1 步骤4:若 n=N,则终止程序,其中N为所要求的码书大小; 否则,转步骤2继续合并最近的两个胞腔
《语音信号处理》课程笔记

《语音信号处理》课程笔记第一章语音信号处理的基础知识1.1 语音信号处理的发展历程语音信号处理的研究起始于20世纪50年代,最初的研究主要集中在语音合成和语音识别上。
在早期,由于计算机技术和数字信号处理技术的限制,语音信号处理的研究进展缓慢。
随着技术的不断发展,尤其是快速傅里叶变换(FFT)的出现,使得语音信号的频域分析成为可能,从而推动了语音信号处理的发展。
到了20世纪80年代,随着全球通信技术的发展,语音信号处理在语音编码和传输等领域也得到了广泛应用。
近年来,随着人工智能技术的快速发展,语音信号处理在语音识别、语音合成、语音增强等领域取得了显著的成果。
1.2 语音信号处理的总体结构语音信号处理的总体结构可以分为以下几个部分:(1)语音信号的采集和预处理:包括语音信号的采样、量化、预加重等操作,目的是提高语音信号的质量,便于后续处理。
(2)特征参数提取:从预处理后的语音信号中提取出能够反映语音特性的参数,如基频、共振峰、倒谱等。
(3)模型训练和识别:利用提取出的特征参数,通过机器学习算法训练出相应的模型,并进行语音识别、说话人识别等任务。
(4)后处理:对识别结果进行进一步的处理,如语法分析、语义理解等,以提高识别的准确性。
1.3 语音的发声机理和听觉机理语音的发声机理主要包括声带的振动、声道的共鸣和辐射等过程。
声带振动产生的声波通过声道时,会受到声道形状的影响,从而产生不同的音调和音质。
听觉机理是指人类听觉系统对声波的感知和处理过程,包括外耳、中耳、内耳和听觉中枢等部分。
1.4 语音的感知和信号模型语音的感知是指人类听觉系统对语音信号的识别和理解过程。
语音信号模型是用来描述语音信号特点和变化规律的数学模型,包括时域模型、频域模型和倒谱模型等。
这些模型为语音信号处理提供了理论基础和工具。
第二章语音信号的时域分析和短时傅里叶分析2.1 语音信号的预处理语音信号的预处理主要包括采样、量化、预加重等操作,目的是提高语音信号的质量,便于后续处理。
LBG算法实现语音信号的矢量量化

语音信号的矢量量化一.实验内容:采用LBG 算法实现语音信号的矢量量化二.实验原理:基本LBG 算法的基本框架为:1.已知码书尺寸M ,给定设计的失真阈值即停止门限)10(<<εε,给定一个出示码书)0(M Y 。
已知一个训练序列]1,...,1,0,[-=m j X j 。
先取n=0(n 为迭代次数),并设出示平均失真∞→-)1(D 。
2.用给定的码本M Y ,求出平均失真最小条件下的所以区域边界),...,2,1(M i S i =。
即根据最佳划分准则把训练序列划分为M 个胞腔。
应该用训练序列i j S X ∈,使))(,(),(M j i j Y Y Y X d Y X d ∈<,从而得出最佳区域边界)(n i S 。
然后,计算在该区域下训练序列的平均失真∑-=∈=10)(),(min 1m j Y r j n MY X d m D 。
在这一步中要累计最小失真并在最后计算平均失真。
3.计算相对平均失真(即与第n-1次迭代的失真相对而言),如果它小于阈值,即ε≤--)()()1(n n n DD D ,则认为满足设计要求,此时停止计算,并且M Y 就是所设计的码书,)(n i S 就是所设计的区域边界。
如果平均失真的条件不满足则进行第四步。
4.按前面给出的最佳码书设计方法,计算这时划分的各胞腔的形心,由这M 个新形心构成(n+1)次迭代的新形心)1(+n M Y 。
置n=n+1,返回到第2步再进行计算,直到满足失真测度公式,得到所要求的码书为止。
三.结果分析:在本实验中采用语音参数的矢量量化,即将语音信号经过分析,得到各种参数,然后再将这些按桢或按段分析所得的数组构成矢量,进行矢量量化。
其中输入的语音文件波形如图一所示。
图1 声音波形输入信号的语音参数为20个MPCC 参数,码本尺寸为16,最后得到的码字为r ,r 是一个1620⨯的矩阵,在MA TLAB7.0里用工作空间的画图功能可得到下面的图。
一种改进的LBG矢量量化算法

其 中! % &’1)* 表示 x 的 标 量误 差 ! P= (’ "0- )是 x 在 0- 的离 散 概 率% LBG 算 法的 基本 思想 是 ( 对 于任 意 训练 矢 量 量 与 之间 的失 真度 ! 常定 义如 下(
. % &’.1)-* " 3
34 .
! &’ 4) *
.6 -6 5
图 像的 压 缩过 程 相当 于训 练 码书 时 的一 个 迭代 过 程! 在 采用 了 我们的 方法 后! 取得了 满意 的压 缩速 度和压 缩效 果" 本试 验用 Le na(256 + 256 ,256)作为 试验 影像 (如 下图 )! 算法 采 用 VC+ +6.0 编 程实 现 ! 用 三 种 不 同的 方 法 对 其 处 理 结果 见 附 表 ! 比 较的 指标 包括 压缩 时间 ! 信 噪比 ! 压缩 率" ! 为 训练 矢
一种改进的
顾俊凯
[摘
要]
LBG 矢 量 量 化 算 法
1
詹世富
1
王建雄
2
& 1 长安 大学 地测 学院 ! 西 安 710054 ) 2 云 南农 业大学 水利 水电 与建 筑学 院! 昆 明 650201 ’
LBG 算法 是矢 量量 化码书 设 计的 基本 算法 " 文 章提 出了 一种 改 进的 LBG 算 法! 通过 引 入 和 两 个 胞腔 ! 使 得码 本采
码 本的 分布 状况 ! 通过引入 R max 和 Rmin 两个控制胞腔! 使得产生胞腔 的速度大大提高%
3 改进 的 LBG 算法
考虑 到传 统 LBG 算法 码本 的生 成是 由 初始 码本 ! 以 及一 个常 数 B 生 成 ! 所 以初 始码 本! 特别 是 B 的 选取 对码 书的 生成 具 有决 定 性因 素! 但是 不论 常数 B 怎 样选 择都 会 出现 所 谓码 本 移动 * 单 向 性+ 效 应! 即码 本 各像 素 值同 时 增大 或者 同 时缩 小 " 本 改 进算 法 考 虑到 影 像 的像 素 的 分布 状 况 ! 同时 在 两 个 方 向上 生 成 码 本 ! 从 而从 根 本上 解 决了 码 本生 成的 * 单向 性 + 效 应! 使 得所 生 成的 码 本很好 地体 现了 像素 的分布 状况 ! 因 此码本 更具 有代 表性 "
自适应模糊聚类LBG矢量量化算法

自适应模糊聚类LBG矢量量化算法孙燕【摘要】采用模糊聚类C均值聚类确定型心改进LBG算法,实现语音参数MFCC 码本的矢量量化,实验结果表明,该算法有着与单一LBG算法相近的量化误差,自适应确定码本大小码,码本尺寸显著降低,减小码本的存储量。
%In this paper, a self-adaptive fuzzy c-means clustering algorithm is proposed. It is designed to overcome the shortcomings of the traditional LBG vector-quantization algorithm. Experimental results on MFCC quantization show that the proposed algorithm has similar quantization error compared to the classic LBG algorithm while significantly reducing codebook size and memory footprint.【期刊名称】《计算机工程与应用》【年(卷),期】2014(000)023【总页数】3页(P203-205)【关键词】LBG算法;自适应;梅尔频率倒谱系数(MFCC);模糊聚类;矢量量化【作者】孙燕【作者单位】青海民族大学计算机学院,西宁 810007【正文语种】中文【中图分类】TP391LBG-VQ算法[1]能找出使矢量量化误差达到最小的矢量中心集,这个中心集就是最佳码本。
传统的LBG-VQ算法是硬聚类算法[2-3],一个样本仅仅属于某一个类,量化后码本尺寸大小固定,如果码本尺寸巨大,存储量显而易见。
模糊C-均值聚类算法(Fuzzy C-means,FCM)允许样本以不同的隶属程度分别属于不同的类[4],本文在传统LBG-VQ算法确定的矢量中心集时,采用模糊聚类FCM改进确定,自适应确定型心,使码本尺寸显著减小。
矢量量化LBG算法的研究

矢量量化LBG算法的研究作者:孔勇平来源:《硅谷》2008年第06期[摘要]论述经典的LBG算法的基本原理、量化器设计的关键之处和存在的问题。
以矢量量化技术在图像压缩领域的应用作为研究目标,总结分析现有典型的LBG算法,并针对LBG算法的不足,提出改进的算法,减少计算复杂度,缩短程序运行时间。
通过理论推导和具体实现,证明改进方法的可行性和有效性。
[关键词]矢量量化 LBG算法中图分类号:TP3 文献标识码:A 文章编号:1671-7597(2008)0320039-02一、引言矢量量化(VQ Vector Quantization)是70年代后期发展起来的一种数据压缩技术,是一种高效的有损数据压缩技术,它具有压缩比大、解码简单和失真较小等优点。
其基本思想是:将若干个标量数据组构成一个矢量,然后在矢量空间给以整体量化,从而压缩了数据而不损失多少信息。
矢量量化是仙农信息论在信源编码理论方面的发展,它的理论基础是仙农的率失真理论,率失真理论是一个存在性定理,并非是一个构造性定理,它未给出如何构造矢量量化器的方法,矢量量化总是优于标量量化,这是因为矢量量化能有效地应用矢量中各分量之间的4种相互关联性质来消除数据中的冗余度。
自从1980年提出矢量量化器(Vector Quantizater)码书设计的LBG算法以来,矢量量化(Vector Quantization)技术[Gray(1984)]已经成功地应用到图像压缩和语音编码中[1]。
二、LBG算法中最佳量化器的设计LBG算法中的最佳矢量量化器设计的关键是最佳划分和最佳码书的设计[2]。
一是给定码书条件下,寻找信源空间的最佳划分,使平均失真最小,由码书和NNR得最佳划分。
信源空间中的任一点矢量,,如果它和码字的失真小于它和其它码字的失真,二是在给定划分条件下,寻找最佳码书,使平均失真最小给定了划分后为了使码书的平均失真最小,码字必须为相应划分的形心(质心),即:式中表示选取的Y是使平均失真为最小的Y,对于一般的失真测度和信源分布,很难找到形心的计算方法。
语音信号的矢量量化

最简单的方法是从训练序列中随机地选取M个矢量作 为初始码字,从而构成初始码书这就是随机选取法。
2)分裂法
用分裂法形成的初始码书性能较好.当然,以此码书 设计的矢量量化器性能也较好。但是随着码书中码字的 增加,计算量也迅速增加。
第12页
2021年12月12日星期日
3)乘积码书法 这种码书初始化的方法是用若干个低维码书作为乘积
码,求得所需的高维数的码书。
第13页
2021年12月12日星期日
语音信号及单片机处理
D min X (m) 1
M
d( ,Y) j
Y Y M
第9页
2021年12月12日星期日
(3)在这一步中要累计最小失真,并在最后计算平均失真。如果它小于阈值, 即
( n 1)
D D D (n)
(n)
则认为满足设计要求。此时停止计算,并且YM 就是所 设计的码书,S就是所设计的区域边界。如果上式的条件不 满足则进行第(4)步。
第10页
2021年12月12日星期日
(4)按前面给出的最佳码书设计方法,计算这时划分的各
胞腔的形心,由这M个新形心构成(n+1)次迭代的新形
心
Y (n 1) M
。置n=n+1,返回到第(2)步再进行计算,直
到满足上式,得到所要求的码书为止。
第11页
2021年12月12日星期日
在设计矢量量化器和码书中,有一个问题需要解决, 即如何选取初始码书。一般要求初始码书对要编码的数 据来说要有相当的代表性。下面介绍几种初始码书的生 成方法。
(1)设码书大小为M,设计的失真阈值即停止门限
为 ε(0<ε<1)。初始码书为 Y。M(已0) 知一个训练序列X0,X1,
矢量量化和压缩编码技术在语音信号中的应用

张 克 功 .矢量 量 化 和 压 缩 编 码 技 术 在 语 音 信 号 中 的应 用
・ 9・ 2
使 最 终设 计 的码 本达 不 到最优 。
2 2 码 本优 化 设计 .
( ) 断 8 <8 7判 ’ 7
若是 , 入() 行; 则 , 转 9执 否 转入 ( ) 行 。 8执
成 、 音识 别 和说话人 识别 、 语 图像 压缩等 领 域 。矢 量
这里 d ( , ) l 的下 标 2表 示平方 误 差 。 ,
2 码本 生成 及 优 化
2 1 初始 码本 生成 . 初始 码本 的生 成有很 多 种方 法 , 随 即码 本 法 。 如
量化 的基本 原 理是 : 若 干个 标 量 数 据 组成 一个 矢 将
收 稿 日期 :0 8— 5— 3 20 0 0
有代 表性 , 导致 码本 训练 中, 敛速 度变慢 或不 能 收 收 敛 ; 练好 的码本 中的有 限个码 字得 不 到充分 利用 , 训
作者简介 : 张克功( 94一) 男, 18 , 什肃会宁人 , 助讲
维普资讯
摘
要: 矢量量 化技 术作为 一种 有损 压缩 编码技 术在 语音 信 号 的存 储 和低 码 率传 输过 程
中起 到 了巨大的推 动作 用 , 音 信 号 矢量 量 化 算 法设 计 的编 码 采 用 m t b编 程 实现 , 语 al a 并
利 用 L G 算法对初始 码本 进行优 化 , 过设 置 不 同的码 本 长度 和码 字长 度 , B 通 比较 得 出各
不 同的初始 码本 。
失 真测 度 ( 离 测 度 ) 将 输 入 矢 量用 码 本 重 距 是
语音LSF参数M-L搜索VQ算法研究

语音LSF参数M-L搜索VQ算法研究许晶晶【摘要】针对高效低速率语音编码,以LBG矢量量化码书设计算法为基础,研究了M-L搜索多级矢量量化(VQ)的码书设计算法和M-L搜索多级矢量量化编解码算法,同时对整个算法进行了全面的测试和性能分析.设计结果表明:该方法可有效提高LSF参数压缩的效率,改善谱失真指标.【期刊名称】《电声技术》【年(卷),期】2014(038)006【总页数】5页(P53-56,71)【关键词】语音编码;线性预测;矢量量化;码书设计【作者】许晶晶【作者单位】广州广晟数码技术有限公司,广东广州 510640【正文语种】中文【中图分类】TN9121 引言语音是人类生活中情感交流最直接的信息交互方式,随着信息技术的发展,语音通信信道传输的信息量越来越饱和,语音编码算法的研究对于节约信道开支具有重要的作用。
低速率语音编码算法在现代语音通信系统中有着非常广泛的应用,超低速率下的语音压缩编码算法是目前语音信号处理领域的重要研究课题之一。
线性预测(Linear Prediction,LP)是很多低速率语音编码方案的核心技术,为降低编码速率,选用高效的线性预测参数编码至关重要。
在语音编码中,线性预测LP 系数一般使用线谱对(Line Spectral Pair,LSP)系数来表示,这是因为LSP系数的量化特性更好,动态在可控的范围内,对于量化器的设计和实现更为有利。
考虑到线性预测模型是语音编码的核心,研究LSP矢量量化技术对于提高压缩效率、增强语音质量具有重要的意义。
本文针对高效低速率语音编码算法中基于线性预测编码的线谱频率(LSF)高质量量化编码问题,以LBG矢量量化码书设计算法为基础,设计了M-L搜索多级矢量量化(VQ)的码书设计算法和M-L搜索多级矢量量化编解码算法。
报告给出了设计原理设计思想,并对设计算法进行了详细的说明,最后对整个算法进行了全面的测试和性能分析。
2 VQ矢量量化码书设计算法VQ矢量量化器的实现中,最重要的是码书设计和训练方法,一个设计良好的码书对于量化效率的影响最为关键。
语音信号处理第4章-矢量量化

信息科学与工程学院
东南大学
4.5 语音参数的矢量量化
语音参数的矢量量化:将语音信号经过分 析,得到各种参数,然后再将这些按帧分 析所得的参数构成矢量,进行矢量量化。
f ( ) X (e
A(e )
j
定义Itakura-Saito距离为:
d IS ( f , f ) aT Ra
2 ln 1
p
aT Ra r (0)ra(0) 2 r ( i )ra( i )
i 1
信息科学与工程学院
Sl {X R : d ( X , Yl ) d ( X , Yi );i l}
K
根据该条件可以对信号空间进行最佳划分,得到 的Sl 称为一个胞腔
信息科学与工程学院 东南大学
4.4 最佳矢量量化器和码本设计
2)Centroid质心条件:子空间分割固定后, Voronoi胞元的质心就是量化器的码字。
失真度选择必须具备的特性
主观评价上有意义,即小的失真应该对应于好 的主观语音质量; 易于处理的,即在数学上易于实现; 平均失真存在并且可以计算; 易于硬件实现
信息科学与工程学院
东南大学
4.3 失真测度
一、欧氏距离-均方误差
K维矢量X和码矢量Y的欧式距离定位: 1. 均方误差
第四章 语音信号的矢量量化
4.1概述 4.2矢量量化的基本原理 4.3失真测度 4.4最佳矢量量化器和码本设计 4.5语音参数的矢量量化
信息科学与工程学院
东南大学
4.1 概述
矢量量化(VQ,Vector Quantization)分 为两类:
标量量化:将取样后的信号值逐个地进行量化 矢量量化:将若干取样信号分成一组,即构成 一个矢量,然后对此矢量一次进行量化。
基于LBG的矢量量化算法

2.图像传输与存储需要的信息量空间:
1)彩色视频信息 对于电视画面的分辨率640*480的彩色图像,每 秒30帧,则一秒钟的数据量为: 640*480*3*8*30=221.12M 所以播放时,需要221Mbps的通信回路。 存储时,1张CD可存640M,则仅可以存放2.89秒的 数据。
2.图像传输与存储需要的信息量空间:
LBG算法流程图
谢谢!
维的,所以称为标量量化。
3.1 概述 一.标量量化 xa(t) xa(nT)
采样
量化
x(n)
x(n)=Q[xa(nT)]。
x1 xa1
xk xak xak+1
xk+1 xaL
xL xaL+1
3.1概述 一.标量量化
-2 -
2 2
标量量化
3.1 概述 二. 矢量量化: 若干个标量数据组成一个矢量,矢量量化是对 矢量进行量化,和标量量化一样,它把矢量空间分 成若干个小区域,每个小区域寻找一个代表矢量, 量化时落入小区域的矢量就用这个代表矢量代替, 或者叫被量化为这个代表矢量。例如,所有可能的 二维矢量就构成了一个平面,将平面分成7个小区 域。
上图给出了一个信息传输系统的模型,它主要由三部分组成(图中的三 个虚线框),即编码器、解码器和信号传输。
图像压缩的目的
◘图像压缩
▓
▓
▓
空间上的冗余:相邻像素或者序列相邻帧间有较大的相关性; 人的视觉特性:人眼的分辨率非常有限; 去除数字图像中的冗余,来减少数据量。
描述语言 1)“这是一幅 2*2的 图像,图像的第一个像 素是红的,第二个像素 是红的,第三个像素是 红的,第四个像素是红 的”。
点是压缩比大以及解码算法简单,因此它
实验五 基于LBG算法的语音信号的最佳码本设计

实验五 基于LBG 算法的最佳码本所设计1 实验目的通过Matlab 编程掌握语音信号最佳码本设计方法。
2 实验原理LBG 算法是一种递推算法,从事先选定的初始码本开始进行迭代,知道系统性能满足要求或者不再有明显改进为止。
具体实现步骤如下:第一步 初始化。
给定全部参考矢量集合S ,设定失真控制门限δ , 算法最大迭代次数L,以及初始码本{}00201J Y Y Y ,设置总失真∞=)0(D ,初始迭代次数m=1,最大迭代次数为L 。
第二步:迭代。
(1)根据最邻近准则将S 分成J 个子集,{}m J m mS S S 21 ⎭⎬⎫⎩⎨⎧==≠≤∈=--J l J i l i Y X d Y X d R X S m i m l K m l ,1;,1,);,(),(:11 (2)计算总失真∑∑=∈-=J l S X m lm ml Y X d D 11),( (3)计算新码字:每一个码字为其对应子集的质心。
{}m J m mY Y Y 21∑∈=m l S X l m l X N Y 1(4)计算相对失真改进量,m m m mD D D ||1-=-δ与失真控制门限比较, 若δδ>m 转入(5);若δδ≤m 转入(6)(5)若m 大于L ,则转入(6),否则m+1,转入(1)(6)得到最终的码书3 实验过程function[x1,x2,x3,y1,y2,y3]=randcz_nn(mux1,varx1,mux2,varx2,mux3,varx 3,muy1,vary1,muy2,vary2,muy3,vary3,n1,n2,n3)x1=mux1+sqrt(varx1)*randn(1,n1);x2=mux2+sqrt(varx2)*randn(1,n2);x3=mux3+sqrt(varx3)*randn(1,n3);y1=muy1+sqrt(vary1)*randn(1,n1);y2=muy2+sqrt(vary2)*randn(1,n2);y3=muy3+sqrt(vary3)*randn(1,n3);[x1,x2,x3,y1,y2,y3]=randcz_nn(1,0.2,-1,0.2,-1,0.2,1,0.2,1,0.2,-1,0.2, 100,100,100);x=[x1 x2 x3; y1 y2 y3];[code,label]=vq_cz(x,3,0.3,10);function [code,label]=vq_cz(x,codelength,tolthr,m)%the program is to caculate the codebook by the LBG%code=vq_cz(x,codelength)%parameter:% x: input data(N*M)%codelength: the length of the code book%tolthr delta%m maximal iteration times[r,c]=size(x);Y=x(:,1:codelength);d=[];D=[inf];l=1;tol=1;while (tol>=tolthr && l<=m)d=[];l=l+1;for i=1:codelengthd=[d;sum(repmat(Y(:,i),[1,c]).^2+x.^2-2*repmat(Y(:,i),[1,c]).*x)];%¼ÆËãѵÁ·¼¯Ê¸Á¿ºÍ¸÷Âë×ÖÖ®¼ä¾àÀëend[a,b]=min(d);D(l)=sum(a);label=b;for i=1:codelengthY(:,i)=sum(x(:,find(b==i)),2)./length(x(find(b==i)));endtol=(D(l-1)-D(l))/D(l)endcode=Y;plot(x(1,:),x(2,:),'*')hold onplot(code(1,:),code(2,:),'rO')xlabel('x×ø±ê')ylabel('y×ø±ê')。
- 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
- 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
- 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。
语音信号的矢量量化
一.实验内容:采用LBG 算法实现语音信号的矢量量化
二.实验原理:基本LBG 算法的基本框架为:
1.已知码书尺寸M ,给定设计的失真阈值即停止门限)10(<<εε,给定一个出示码书)
0(M Y 。
已知一
个训练序列]1,...,1,0,[-=m j X j 。
先取n=0(n 为迭代次数),并设出示平均失真∞→-)1(D 。
2.用给定的码本M Y ,求出平均失真最小条件下的所以区域边界),...,2,1(M i S i =。
即根据最佳划分准则把训练序列划分为M 个胞腔。
应该用训练序列i j S X ∈,使))(,(),(M j i j Y Y Y X d Y X d ∈<,
从而得出最佳区域边界)(n i S 。
然后,计算在该区域下训练序列的平均失真∑-=∈=1
0)(),(min 1m j Y r j n M
Y X d m D 。
在这一步中要累计最小失真并在最后计算平均失真。
3.计算相对平均失真(即与第n-1次迭代的失真相对而言),如果它小于阈值,即
ε≤--)()
()1(n n n D
D D ,则认为满足设计要求,此时停止计算,并且M Y 就是所设计的码书,)(n i S 就是所设计的区域边界。
如果平均失真的条件不满足则进行第四步。
4.按前面给出的最佳码书设计方法,计算这时划分的各胞腔的形心,由这M 个新形心构成(n+1)次迭代的新形心)1(+n M Y 。
置n=n+1,返回到第2步再进行计算,直到满足失真测度公式,得到所要求的码书为止。
三.结果分析:
在本实验中采用语音参数的矢量量化,即将语音信号经过分析,得到各种参数,然后再将这些按桢或按段分析所得的数组构成矢量,进行矢量量化。
其中输入的语音文件波形如图一所示。
图1 声音波形
输入信号的语音参数为20个MPCC 参数,码本尺寸为16,最后得到的码字为r ,r 是一个1620⨯的矩阵,在MA TLAB7.0里用工作空间的画图功能可得到下面的图。
图2 实验数据
四.实验程序
[s,fs]=wavread('s1.wav');
%数据准备
m = 100;
n = 256;
l = length(s);
nbFrame = floor((l - n) / m) + 1;
for i = 1:n
for j = 1:nbFrame
M(i, j) = s(((j - 1) * m) + i);
end
end
h = hamming(n);
M2 = diag(h) * M;
for i = 1:nbFrame
frame(:,i) = fft(M2(:, i));
end
t = n / 2;
tmax = l / fs;
m = melfb(20, n, fs);
n2 = 1 + floor(n / 2);
z = m * abs(frame(1:n2, :)).^2;
v = dct(log(z));
%LBG算法
k=16;
e = .01;
r = mean(v, 2);
dpr = 10000;
for i = 1:log2(k)
r = [r*(1+e), r*(1-e)];
while (1 == 1)
z = disteu(v, r);
[m,ind] = min(z, [], 2);
t = 0;
for j = 1:2^i
r(:, j) = mean(v(:, find(ind == j)), 2);
x = disteu(v(:, find(ind == j)), r(:, j));
for q = 1:length(x)
t = t + x(q);
end
end
if (((dpr - t)/t) < e)
break;
else
dpr = t;
end
end
end
%失真测度
function d = disteu(x, y)
[M, N] = size(x);
[M2, P] = size(y);
if (M ~= M2)
error('Matrix dimensions do not match.') end
d = zeros(N, P);
if (N < P)
copies = zeros(1,P);
for n = 1:N
d(n,:) = sum((x(:, n+copies) - y) .^2, 1);
end
else
copies = zeros(1,N);
for p = 1:P
d(:,p) = sum((x - y(:, p+copies)) .^2, 1)';
end
end
d = d.^0.5;
%滤波器
function m = melfb(p, n, fs)
f0 = 700 / fs;
fn2 = floor(n/2);
lr = log(1 + 0.5/f0) / (p+1);
bl = n * (f0 * (exp([0 1 p p+1] * lr) - 1)); b1 = floor(bl(1)) + 1;
b2 = ceil(bl(2));
b3 = floor(bl(3));
b4 = min(fn2, ceil(bl(4))) - 1;
pf = log(1 + (b1:b4)/n/f0) / lr;
fp = floor(pf);
pm = pf - fp;
r = [fp(b2:b4) 1+fp(1:b3)];
c = [b2:b4 1:b3] + 1;
v = 2 * [1-pm(b2:b4) pm(1:b3)];
m = sparse(r, c, v, p, 1+fn2);。