语谱图

语谱图:

所谓语谱图就是语音频谱图,一般是通过处理接收的时域信号得到频谱图,

因此只要有足够时间长度的时域信号就可以(时间长度为保证频率分辨率)。
专业点讲,语谱图就是频谱分析视图,如果针对语音数据的话,叫语谱图,语谱图的横坐标是时间,
纵坐标是频率,坐标点值为语音数据能量。
采用二维平面来表达三维信息。所以能量值的大小通过颜色来表示。颜色深表示该点的语音能量越强。

代码实现:

[x, Fs, nBits] = wavread('audio.wav');
specgram(x, 512, Fs, 100);
xlabel('Time(s)');
ylabel('Frequency(Hz)');
title('Spectrogram');

另一种不用specgram函数实现的语谱图画法matlab实现如下:

clear all;
clc
close all;

[x,Fs,nBits]=wavread('audio.wav');

if (size(x,1)>size(x,2))
	x=x';
end

s=length(x);	% calcualte  the length of the signal x.
w=256;
n=w;
ov=w/2;
h=w-ov;
win=hamming(n)';
c=1;
ncols=1+fix((s-n)/h);	
%fix:round towards zero. fix(x) rounds the elements of x to the nearest integers towards zero
%for example, if x=1.2345, after m = fix(x), the value of m is 1.
d=zeros((1+n/2),ncols);
for b=0:h:(s-n)
	u=win.*x((b+1):(b+n));	% add window to n samples.
	t=fft(u);	% do fft.
	d(:,c)=t(1:(1+n/2))';
	c=c+1;
end
tt=[0:h:(s-n)]/Fs;
ff=[0:(n/2)]*Fs/n;

imagesc(tt/1000,ff/1000,20*log10(abs(d)));
colormap(hot);
axis xy
xlabel('时间/s');
ylabel('频率/kHz');


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值