数字信号处理课程设计报告(20211126002336)_第1页
数字信号处理课程设计报告(20211126002336)_第2页
数字信号处理课程设计报告(20211126002336)_第3页
数字信号处理课程设计报告(20211126002336)_第4页
数字信号处理课程设计报告(20211126002336)_第5页
已阅读5页,还剩17页未读 继续免费阅读

下载本文档

版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领

文档简介

1、数字信号处理课程设计报告课设题目:语音信号变声处理系统学院:信息科学与工程学院专业:电子与信息工程班级:姓名:学号:指导教师:哈尔滨工业大学(威海)2011 年7 月8 日目录一. 课程设计任务 . 1二. 课程设计原理及设计方案. 1三. 课程设计的步骤和结果. 3四. 课程设计总结 . 17五. 设计体会 . 18六. 参考文献 . 19哈尔滨工业大学(威海)课程设计报告- 1 - 一. 课程设计任务电视台经常针对某些事件的知情者进行采访,为了保护知情者,经常改变说话人的声音,请利用所学的知识,将其实现。1) 自己录制一段正常的声音文件,或者通过菜单选择的方式选择一段正常声音文件;2) 能

2、够播放该文件;3) 对语音信号进行处理,要求处理后的语音信号基本不影响正常收听与理解;5) 对处理参数能够通过 matlab 界面进行调节,以对比不同处理效果;6) 能够对处理后的声音文件与原始声音文件的频谱进行观察、分析。7) 编制 gui用户界面。哈尔滨工业大学(威海)课程设计报告- 2 - 二. 课程设计原理及设计方案()选取需要变声的原始语音信号;()得到原始语音信号的基音周期长度;()根据基音周期长度定位整个原始语音信号的每一个基音周期的位置;()在原始语音信号中的基音周期之间删除插入基音周期,得到缩短伸长的语音信号;()将缩短伸长的语音信号线性伸长压缩至与原始语音信号一致的长度,得

3、到变声后的语音信号。哈尔滨工业大学(威海)课程设计报告- 3 - 三. 课程设计的步骤和结果function varargout = fenxi(varargin) gui_singleton = 1; gui_state = struct(gui_name , mfilename, .gui_singleton, gui_singleton, .gui_openingfcn, fenxi_openingfcn, .gui_outputfcn, fenxi_outputfcn, .gui_layoutfcn, , .gui_callback, ); if nargin & ischar

4、(varargin1) gui_state.gui_callback = str2func(varargin1); endif nargout varargout1:nargout = gui_mainfcn(gui_state, varargin:); else gui_mainfcn(gui_state, varargin:); end% end initialization code - do not edit% - executes just before fenxi is made visible.function fenxi_openingfcn(hobject, eventdat

5、a, handles, varargin) % this function has no output args, see outputfcn.% hobject handle to figure% eventdata reserved - to be defined in a future version of matlab% handles structure with handles and user data (see guidata)% varargin command line arguments to fenxi (see varargin)% choose default co

6、mmand line output for fenxihandles.output = hobject; % update handles structureguidata(hobject, handles); % uiwait makes fenxi wait for user response (see uiresume)哈尔滨工业大学(威海)课程设计报告- 4 - % uiwait(handles.figure1);% - outputs from this function are returned to the command line.function varargout = fe

7、nxi_outputfcn(hobject, eventdata, handles) % varargout cell array for returning output args (see varargout);% hobject handle to figure% eventdata reserved - to be defined in a future version of matlab% handles structure with handles and user data (see guidata)% get default command line output from h

8、andles structurevarargout1 = handles.output; % - executes on button press in luyin.function luyin_callback(hobject, eventdata, handles) if get(hobject,value) % set(handles.luyinpinlv,enable,on); set(handles.dakai,value,0); set(handles.luyinshijian,enable, on ); set(handles.luyinqueding,enable, on );

9、 set(handles.dakaiqueding,enable, off); set(handles.bofang,value,0); set(handles.bofangpinlv,enable, off); set(handles.bofangqueding,enable, off); set(handles.luyinqueding,string, start); elseend; % hint: get(hobject,value) returns toggle state of luyin% - executes on button press in dakai.function

10、dakai_callback(hobject, eventdata, handles) if get(hobject,value) set(handles.luyin,value,0); set(handles.luyinshijian,enable, off); set(handles.luyinqueding,enable, off); set(handles.dakaiqueding,enable, on ); set(handles.bofang,value,0); %set(handles.bofangpinlv,enable,off); set(handles.bofangqued

11、ing,enable, off); 哈尔滨工业大学(威海)课程设计报告- 5 - %set(handles.luyinpinlv,enable,off);elseend; function radiobutton3_callback(hobject, eventdata, handles) % hobject handle to radiobutton3 (see gcbo)% eventdata reserved - to be defined in a future version of matlab% handles structure with handles and user dat

12、a (see guidata)% hint: get(hobject,value) returns toggle state of radiobutton3% - executes on button press in luyinqueding.function luyinqueding_callback(hobject, eventdata, handles) % hobject handle to luyinqueding (see gcbo)% eventdata reserved - to be defined in a future version of matlab% handle

13、s structure with handles and user data (see guidata)set(hobject,string, recording); pause(0.4); fs=44100; t=str2double(get(handles.luyinshijian,string); ai=analoginput(winsound,0); % 初始化录音麦克chanel=addchannel(ai,1);%1 表示单声道set(ai,samplerate ,fs); duration=t; % 录音时间set(ai,samplespertrigger,duration*fs

14、); start(ai); y=0;time=0; y,time=getdata(ai);% 读出相应的数据handles.y=y; handles.fs=fs; guidata(hobject,handles); plot(handles.huitu2,time,handles.y)% 画出声音波形title(handles.huitu2, 时域图 ); ysize=size(handles.y); set(hobject,string, finish); set(handles.yuchuli,enable, on ); set(handles.yuchuliqd,enable, on )

15、; 哈尔滨工业大学(威海)课程设计报告- 6 - set(handles.fuliyebianhuan,enable , on ); set(handles.baocun,enable, on ); %set(handles.biansheng,enable,on);% - executes on button press in dakaiqueding.function dakaiqueding_callback(hobject, eventdata, handles) % hobject handle to dakaiqueding (see gcbo)% eventdata reserv

16、ed - to be defined in a future version of matlab% handles structure with handles and user data (see guidata) filename pathname=uigetfile(*.wav, all files(*.*), select); if isequal(filename pathname,0,0) return ; endstr=pathname filename;% 选择的声音文件路径和文件名temp fs=wavread(str);%temp 表示声音数据 fs 表示频率handles

17、.y=temp;handles.fs=fs; guidata(hobject,handles); set(handles.yuchuli,enable, on ); set(handles.yuchuliqd,enable, on ); set(handles.fuliyebianhuan,enable , on ); set(handles.baocun,enable, on ); %set(handles.biansheng,enable,on); set(handles.bofang,enable, on ); % - executes on button press in pushbu

18、tton3.function pushbutton3_callback(hobject, eventdata, handles) % hobject handle to pushbutton3 (see gcbo)% eventdata reserved - to be defined in a future version of matlab% handles structure with handles and user data (see guidata)function luyinshijian_callback(hobject, eventdata, handles) % hobje

19、ct handle to luyinshijian (see gcbo)% eventdata reserved - to be defined in a future version of matlab% handles structure with handles and user data (see guidata)% hints: get(hobject,string) returns contents of luyinshijian as text%str2double(get(hobject,string) returns contents of luyinshijian 哈尔滨工

20、业大学(威海)课程设计报告- 7 - as a double% - executes during object creation, after setting all properties.function luyinshijian_createfcn(hobject, eventdata, handles) ifispc & isequal(get(hobject,backgroundcolor), get(0, defaultuicontrolbackgroundcolor) set(hobject,backgroundcolor, white); end% - executes

21、 on button press in bofang.function bofang_callback(hobject, eventdata, handles) if get(hobject,value) set(handles.luyin,value,0); set(handles.luyinshijian,enable, off); set(handles.luyinqueding,enable, off); set(handles.dakaiqueding,enable, off); set(handles.dakai,value,0); set(handles.bofangpinlv,

22、enable, on ); set(handles.bofangqueding,enable, on ); % set(handles.luyinpinlv,enable,off);elseend; % hint: get(hobject,value) returns toggle state of bofangfunction bofangpinlv_callback(hobject, eventdata, handles) function bofangpinlv_createfcn(hobject, eventdata, handles) ifispc & isequal(get

23、(hobject,backgroundcolor), get(0, defaultuicontrolbackgroundcolor) set(hobject,backgroundcolor, white); end% - executes on button press in bofangqueding.function bofangqueding_callback(hobject, eventdata, handles) % hobject handle to bofangqueding (see gcbo)% eventdata reserved - to be defined in a

24、future version of matlab% handles structure with handles and user data (see guidata)c=handles.fs; contents = cellstr(get(handles.bofangpinlv,string) ;% 获取listbox1哈尔滨工业大学(威海)课程设计报告- 8 - 中的细胞矩阵bj=contentsget(handles.bofangpinlv,value); % 获取listbox中的值if strcmp(bj,frequency) ds=c; elseif strcmp(bj,male

25、) ds=0.7*c; else ds=1.7*c; end; wavplay(handles.y,ds); y=fft(handles.y,length(handles.y); ysize=size(y); plot(handles.huitu2,abs(y); xlabel(handles.huitu2,f/hz); ylabel(handles.huitu2,range ); title(handles.huitu2,frequency ); grid on; function luyinpinlv_callback(hobject, eventdata, handles) % hobj

26、ect handle to luyinpinlv (see gcbo)% eventdata reserved - to be defined in a future version of matlab% handles structure with handles and user data (see guidata)% hints: get(hobject,string) returns contents of luyinpinlv as text% str2double(get(hobject,string) returns contents of luyinpinlv as a dou

27、ble% - executes during object creation, after setting all properties.function luyinpinlv_createfcn(hobject, eventdata, handles) % hobject handle to luyinpinlv (see gcbo)% eventdata reserved - to be defined in a future version of matlab% handles empty - handles not created until after all createfcns

28、called哈尔滨工业大学(威海)课程设计报告- 9 - % hint: edit controls usually have a white background on windows.% see ispc and computer.ifispc & isequal(get(hobject,backgroundcolor), get(0, defaultuicontrolbackgroundcolor) set(hobject,backgroundcolor, white); endfunction xianshi_callback(hobject, eventdata, handl

29、es) % hobject handle to xianshi (see gcbo)% eventdata reserved - to be defined in a future version of matlab% handles structure with handles and user data (see guidata)% hints: get(hobject,string) returns contents of xianshi as text% str2double(get(hobject,string) returns contents of xianshi as a do

30、uble% - executes during object creation, after setting all properties.function xianshi_createfcn(hobject, eventdata, handles) % hobject handle to xianshi (see gcbo)% eventdata reserved - to be defined in a future version of matlab% handles empty - handles not created until after all createfcns calle

31、d% hint: edit controls usually have a white background on windows.% see ispc and computer.ifispc & isequal(get(hobject,backgroundcolor), get(0, defaultuicontrolbackgroundcolor) set(hobject,backgroundcolor, white); end% - executes on button press in yuchuliqd.function yuchuliqd_callback(hobject,

32、eventdata, handles) % hobject handle to yuchuliqd (see gcbo)% eventdata reserved - to be defined in a future version of matlab% handles structure with handles and user data (see guidata)contents = cellstr(get(handles.yuchuli,string) ;% 获取listbox1中的哈尔滨工业大学(威海)课程设计报告- 10 - 细胞矩阵bj=contentsget(handles.y

33、uchuli,value); % 获取listbox中的值if strcmp(bj,removal of dc component) shuju=handles.y; handles.y=shuju-mean(shuju); elseif strcmp(bj,removal of long-term trend) y=handles.y; handles.y=detrend(y); elsey=handles.y;fs=handles.fs; % 低通滤波器性能指标,% fp=1000; fc=2000; as=100; ap=1;wp=2*1200/8000; % 归一化通带数字频率 wpw

34、s=2*2000/8000; % 归一化阻带数字截止频率wsrp=0.5; % 通带波纹系数 rprs=60; % 最小阻带衰减 rsn,wn=buttord(wp,ws,rp,rs); % 求阶数 n和滤波器截止频率 wnnum,den=butter(n,rp); % 传输分子和分母的系数h,w=freqz(num,den); % 求频率响应f=filter(num,den,y); % 滤波f1=fft(f,fs); handles.y=f; plot(handles.huitu,abs(f1); % 画出滤波后的时域图title(handles.huitu, 滤波后的幅度谱 ); set(

35、handles.huitu,xgrid, on ); set(handles.huitu,ygrid, on ); plot(handles.huitu2,angle(f1); % 画出滤波后的时域图title(handles.huitu2, 滤波后的相位谱 ); grid on; end; guidata(hobject,handles); % - executes on selection change in yuchuli.function yuchuli_callback(hobject, eventdata, handles) 哈尔滨工业大学(威海)课程设计报告- 11 - % ho

36、bject handle to yuchuli (see gcbo)% eventdata reserved - to be defined in a future version of matlab% handles structure with handles and user data (see guidata)% hints: contents = cellstr(get(hobject,string) returns yuchuli contents as cell array% contentsget(hobject,value) returns selected item fro

37、m yuchuli% - executes during object creation, after setting all properties.function yuchuli_createfcn(hobject, eventdata, handles) % hobject handle to yuchuli (see gcbo)% eventdata reserved - to be defined in a future version of matlab% handles empty - handles not created until after all createfcns

38、called% hint: popupmenu controls usually have a white background on windows.% see ispc and computer.ifispc & isequal(get(hobject,backgroundcolor), get(0, defaultuicontrolbackgroundcolor) set(hobject,backgroundcolor, white); end% - executes on button press in fuliyebianhuan.function fuliyebianhua

39、n_callback(hobject, eventdata, handles) % hobject handle to fuliyebianhuan (see gcbo)% eventdata reserved - to be defined in a future version of matlab% handles structure with handles and user data (see guidata) temp=handles.y; fs=handles.fs; len=max(size(temp);% 读出声音数据文件的长度sel,ok=listdlg(liststring

40、, length, 128 , 256 , 512 , 1024 , 2048 , 4096 , 8192 , 16384 , 32768 , 65536 , .name , choose fft , okstring, yes , .cancelstring, cancle, selectionmode, single, listsize,250 150); 哈尔滨工业大学(威海)课程设计报告- 12 - data_frequency=len,128,256,512,1024,2048,4096,8192,16384,32768,65536; if ok=1 m=data_frequency

41、(sel); y=temp(1:m);% 取前m个数据做变换 s=length(y); zh=fft(y,s); % 做fft 变换 f=0:fs/s:fs*(s-1)/s; % 计算频率 plot(handles.huitu2,f(1:m/2),zh(1:m/2) set(handles.huitu2,xgrid, on ); set(handles.huitu2,ygrid, on ); legend( 频谱图 ); xlabel(handles.huitu2, 频率 ); ylabel(handles.huitu2, 振幅 ); elseend% - executes on button

42、 press in baocun.function baocun_callback(hobject, eventdata, handles) % hobject handle to baocun (see gcbo)% eventdata reserved - to be defined in a future version of matlab% handles structure with handles and user data (see guidata)fs=handles.fs; sel,ok=listdlg(liststring, frequency, 6000 , 8000 ,

43、 11025 , 16000 , 22050 , 32000 , 44100 , 48000 , 96000 , .name , choose frequency, okstring, yes, .cancelstring, cancle, selectionmode, single, listsize,240 120); data_frequency=fs,6000,8000,11025,16000,22050,32000,44100,48000,96000; if ok=1 fs=data_frequency(sel); filename=uiputfile(*.wav, save as)

44、; wavwrite(handles.y,fs,filename);%data表示声音数据else哈尔滨工业大学(威海)课程设计报告- 13 - end; % - executes on button press in biansheng.function biansheng_callback(hobject, eventdata, handles) % hobject handle to biansheng (see gcbo)% eventdata reserved - to be defined in a future version of matlab% handles structu

45、re with handles and user data (see guidata)% ct1set(hobject,string, processing, please wait); % 定义常数 fl = 80; % 帧长 wl = 240; % 窗长 p = 10; % 预测系数个数 s=handles.y;fs=handles.fs; % 载入语音 s s = s/max(s); % 归一化 l = length(s); % 读入语音长度 fn = floor(l/fl)-2; % 计算帧数% 预测和重建滤波器 exc = zeros(l,1); % 激励信号(预测误差) zi_pr

46、e = zeros(p,1); % 预测滤波器的状态 s_rec = zeros(l,1); % 重建语音 zi_rec = zeros(p,1); % 合成滤波器 exc_syn = zeros(l,1); % 合成的激励信号(脉冲串) s_syn = zeros(l,1); % 合成语音 last_syn = 0; % 存储上一个(或多个)段的最后一个脉冲的下标 zi_syn = zeros(p,1); % 合成滤波器的状态% 变调不变速滤波器 exc_syn_t = zeros(l,1); % 合成的激励信号(脉冲串) s_syn_t = zeros(l,1); % 合成语音 last_

47、syn_t = 0; % 存储上一个(或多个)段的最后一个脉冲的下标 zi_syn_t = zeros(p,1); % 合成滤波器的状态% 变速不变调滤波器(假设速度减慢一倍) hw = hamming(wl); % 汉明窗% 依次处理每帧语音哈尔滨工业大学(威海)课程设计报告- 14 - for n = 3:fn % 计算预测系数(不需要掌握) s_w = s(n*fl-wl+1:n*fl).*hw; % 汉明窗加权后的语音 a e = lpc(s_w, p); % 用线性预测法计算 p个预测系数% a 是预测系数, e会被用来计算合成激励的能量 s_f = s(n-1)*fl+1:n*fl); % 本帧语音,

温馨提示

  • 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
  • 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
  • 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
  • 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
  • 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
  • 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
  • 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

评论

0/150

提交评论