📄 maindemo.m
字号:
function maindemo
% 基于小波和矢量量化的语音信号压缩算法
% Author: huihui
% Time: 2009-4
% Copyright: huihui and my university
% 给用户的提示信息
clear all; % 清除 matlab的环境变量内存
clc; % 清除 matlab的命令行的输入
% 提示用户需要耗费时间
disp('It will take approaximately 18 seconds for an INTEL PENTIUM 4 [2.4GHz], 256 RAM machine to finish a 2sec [16kHz] wavfile');
load parameter;
global para;
% 读入输入语音信号
%TAKING INPUT WAVEFILE,
inpfilenm = 's2ofwb'; % 语音文件需要放置在当前文件夹路径下
% Read Microsoft WAVE (.wav) sound file 信号读入函数
% 使用说明:
%y = wavread(filename) loads a WAVE
% file specified by filename, returning the sampled data
% in y. The filename input is a string
% enclosed in single quotes. The .wav extension is appended
% if no extension is given.
[x, fs] =wavread(inpfilenm);
% x=wavrecord(,);
% LENGTH (IN SEC) OF INPUT WAVEFILE, 给用户提示需要进行压缩的语音信号的文件的长度
t = length(x)./fs;
sprintf('Processing the wavefile "%s"', inpfilenm)
sprintf('The wavefile is %3.2f seconds long', t)
% 压缩算法开始运行
% Encode 算法 编码算法
[encode_speech,C, L] = encodeAudio(x);
decode_speech = decodeAudio(encode_speech, C, L);
psnrvalue = psnr(x,decode_speech, 255);
% 给用户的听觉体验,比较压缩前和压缩后的听觉效果
beep;
disp('Press a key to play the original sound!');
pause;
soundsc(x, fs);
disp('Press a key to play the compressed sound!');
pause;
soundsc(decode_speech, fs);
% 给出上述算法处理的波形图
figure;
subplot(2,1,1),
plot(x);
title(['Original signal = "', inpfilenm, '"']);
subplot(2,1,2),
plot(decode_speech);
title(['synthesized speech of "', inpfilenm, '" using our wavelet and vecotr quantizer']);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -