以下是一个示例代码,生成两个音频的频谱图和语谱图,将两个频谱图放在一个窗口,将两个语谱图放在另一个窗口:

% 读取音频文件
[y1, Fs1] = audioread('audio1.wav');
[y2, Fs2] = audioread('audio2.wav');

% 计算频谱图和语谱图
[S1, F1, T1] = spectrogram(y1, hann(512), 256, 1024, Fs1);
[S2, F2, T2] = spectrogram(y2, hann(512), 256, 1024, Fs2);

% 绘制频谱图
figure;
subplot(1,2,1);
imagesc(T1, F1, 20*log10(abs(S1)));
axis xy; colormap(jet); xlabel('Time (s)'); ylabel('Frequency (Hz)');
title('Spectrogram of Audio 1');
subplot(1,2,2);
imagesc(T2, F2, 20*log10(abs(S2)));
axis xy; colormap(jet); xlabel('Time (s)'); ylabel('Frequency (Hz)');
title('Spectrogram of Audio 2');

% 绘制语谱图
figure;
subplot(1,2,1);
spectrogram(y1, hann(512), 256, 1024, Fs1, 'yaxis');
title('Spectrogram of Audio 1');
subplot(1,2,2);
spectrogram(y2, hann(512), 256, 1024, Fs2, 'yaxis');
title('Spectrogram of Audio 2');

这段代码会生成两个窗口,第一个窗口包含两个频谱图,第二个窗口包含两个语谱图

matlab生成两个音频的频谱图和语谱图两个频谱图放在一个窗口两个语谱图放在一个窗口

原文地址: http://www.cveoy.top/t/topic/ewHe 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录