文章目录
一.配置语音箱
跳转这一篇文章有教程
二.绘制语谱图
测试代码:
clear all; clc; close all; [x,Fs]=audioread(['./mat_file/yunque/XC2' ... '86466 - 云雀 - Alauda arvensis.mp3']); %读入数据文件 wlen=800; inc=80; win=hanning(wlen);% 设置帧长,帧移和窗函数 N=length(x); time=(0:N-1)/Fs; % 计算时间 y=enframe(x,win,inc)'; % 分帧 fn=size(y,2); % 帧数 frameTime=(((1:fn)-1)*inc+wlen/2)/Fs; % 计算每帧对应的时间 W2=wlen/2+1; n2=1:W2; freq=(n2-1)*Fs/wlen; % 计算FFT后的频率刻度 Y=fft(y); % 短时傅里叶变换 clf % 初始化图形 %=====================================================% % Plot the STFT result % 画出语谱图 %=====================================================% set(gcf,'Position',[20 100 600 500]); axes('Position',[0.1 0.1 0.85 0.5]); imagesc(frameTime,freq,abs(Y(n2,:))); % 画出Y的图像 axis xy; ylabel('频率/Hz');xlabel('时间/s'); title('语谱图'); %=====================================================% % Plot the Speech Waveform % 画出语音信号的波形 %=====================================================% axes('Position',[0.07 0.72 0.9 0.22]); plot(time,x,'k'); xlim([0 max(time)]); xlabel('时间/s'); ylabel('幅值'); title('语音信号波形');
返回: