Nhận xét và kết luận

Một phần của tài liệu Tìm hiểu một số phương pháp tăng cường chất lượng tiếng nói (Trang 58 - 76)

Nhận xét:

Qua kết quả đánh giá bằng OE và SE đƣa ra đƣợc kết luận là :

- Đối với từng loại nhiễu khác nhau thì tác động của các thuật toán tăng cƣờng là khác nhau.

- Đối với từng mức nhiễu khác nhau thì thuật toán cũng tác động cũng khác nhau.

- Ở môi trƣờng có SNR thấp thì phần tiếng bị mất nhiều, nhiều lúc bị ngắt quãng do nén quá lớn.

- Ở môi trƣờng SNR lớn, nhiễu đƣợc nén triệt để hơn nhƣng vẫn giữ đƣợc chất lƣợng tiếng nói.

- Ở phƣơng pháp lọc Wiener phần tiếng đƣợc khuếch đại lớn hơn so với phƣơng pháp trừ phổ nên có cảm giác nhiễu ít hơn.

KẾT LUẬN LUẬN VĂN VÀ HƢỚNG PHÁT TRIỂN TRIỂN TIẾP THEO

Chất lƣợng của tiếng nói bị suy giảm do sự tác động của nhiễu trong môi trƣờng xung quanh là một vấn đề quan trọng cần phải đƣợc giải quyết. Việc tìm ra các phƣơng pháp để triệt nhiễu và giảm nhiễu trong tiếng nói luôn luôn đề tài đƣợc quan tâm rất nhiều. Trong các dịch vụ truyền thông với phƣơng tiện ngôn ngữ là tiếng nói thì việc tăng cƣờng, cải thiện chất lƣợng tiếng nói đã bị nhiễu là rất cần thiết, giúp cho ngƣời nghe có thể nghe rõ và đúng những gì ngƣời nói đã nói.

Luận văn đã thực hiện đƣợc các vấn đề:

- Tìm hiểu và nghiên cứu các phƣơng pháp cải thiện chất lƣợng tiếng nói, nhƣng tập trung vào 2 thuật toán tăng cƣờng chất lƣợng tiếng nói Trừ phổ và lọc Wiener

- Xây dựng đƣợc chƣơng trình thực hiện xử lý nhiễu trong các file âm thanh đã bị nhiễu dựa trên thuật toán Trừ phổ và Lọc Wiener.

- Thực hiện và đánh giá tính hiệu quả của 2 thuật toán trong các môi trƣờng nhiễu và mức độ nhiễu khác nhau, từ đó đƣa ra các biện pháp tối ƣu hóa các thuật toán. Kết quả đạt đƣợc cho thấy Lọc Wiener là thuật toán giảm nhiễu tốt hơn trừ phổ. Các thuật toán giảm nhiễu có hiệu quả khác nhau đối với từng môi trƣờng nhiễu khác nhau

Tuy nhiên luận văn vẫn chƣa giải quyết hết đƣợc các vấn đề trong tăng cƣờng chất lƣợng tiếng nói, nên hƣớng phát triển của đề tài trong tƣơng lai sẽ là :

- Tìm hiểu, nghiên cứu và xây dựng các chƣơng trình thực hiện xử lý nhiễu dựa trên các thuật toán khác trong tăng cƣờng chất lƣợng tiếng nói nhƣ thuật toán Kalman, thuật toán tối thiểu hóa bình phƣơng tạp âm.

- Nghiên cứu và đƣa ra thuật toán mới về xử lý nhiễu và triệt nhiễu trong tăng cƣờng chất lƣợng tiếng nói.

PHỤ LỤC CHẠY THỰC NGHIỆM VÀ CÁC ĐOẠN CODE MATLAB * Phƣơng pháp chạy thực nghiệm trên Matlab.

- Công cụ: Sử dụng Matlab 2012 làm công cụ để chạy thực nghiệm. - Dữ liệu: Các file âm thanh thu ở các môi trƣờng nhiễu khác nhau, tập dữ liệu chƣơng trình chạy ứng dụng tăng cƣờng chất lƣợng tiếng nói.

- Các bƣớc thực hiện:

+ Cài chƣơng trình Matlab 2012

+ Coppy toàn bộ các file trong chƣơng trình ứng dụng tăng cƣờng chất lƣợng tiếng nói vào đƣờng dẫn chứa thƣ mục Bin của Matlab 2012 vừa đƣợc cài. Ví dụ: C:\Program Files\MATLAB\R2012a\bin.

+ Chạy chƣơng trình đã xây dựng:

+ Chọn file nhiễu cần lọc trong From Multilmedia file sau đó nhấn vào nút Start Simulation kết quả thu đƣợc âm thanh sau khử nhiễu và dạng phổ của tín hiệu:

* Các đoạn Code Matlab trong chƣơng trình

Matlab Code thuật toán phân đoạn tín hiệu

function Seg=segment(signal,W,SP,Window) if nargin<3 SP=.4; end if nargin<2 W=256; end if nargin<4 Window=hamming(W); end Window=Window(:); %make it a column vector

L=length(signal); SP=fix(W*SP); N=fix((L-W)/SP +1); %number of segments Index=(repmat(1:W,N,1)+repmat((0:(N-1))'*SP,1,W))'; % size 256 x 461 when W = 256, SP = .4 hw=repmat(Window,1,N); % size 256 x 461 Seg=signal(Index).*hw;

% size 256 x 461 : each column is a frame of signal, consist of 461 frames[5].

Matlab Code thuật toán VAD:

Function[NoiseFlag,SpeechFlag,NoiseCounter,Dist]=vad(signal,noise,NoiseCount er,NoiseMargin,Hangover) if nargin<4 NoiseMargin=3; end if nargin<5 Hangover=8; end if nargin<3 NoiseCounter=0; end FreqResol=length(signal); SpectralDist= max(20*(log10(signal)-log10(noise)),0); %SpectralDist(find(SpectralDist<0))=0; Dist=mean(SpectralDist);

if (Dist < NoiseMargin) NoiseFlag=1; NoiseCounter=NoiseCounter+1; else NoiseFlag=0; NoiseCounter=0; end

% Detect noise only periods and attenuate the signal if (NoiseCounter > Hangover)

SpeechFlag=0; else

SpeechFlag=1; End.

Matlab Code thuật toán xếp chồng:

function ReconstructedSignal=OverlapAdd2(XNEW,yphase,windowLen,ShiftLsen) if nargin<2 yphase=angle(XNEW); end if nargin<3 windowLen=size(XNEW,1)*2; end if nargin<4 ShiftLen=windowLen/2; end if fix(ShiftLen)~=ShiftLen ShiftLen=fix(ShiftLen);

disp('The shift length have to be an integer as it is the number of samples.');

end

disp(['shift length is fixed to ' num2str(ShiftLen)])

[FreqRes FrameNum]=size(XNEW); Spec=XNEW.*exp(j*yphase); if mod(windowLen,2)

%if FreqResol is odd

Spec=[Spec;flipud(conj(Spec(2:end,:)))]; else Spec=[Spec;flipud(conj(Spec(2:end-1,:)))]; end sig=zeros((FrameNum-1)*ShiftLen+windowLen,1); weight=sig; for i=1:FrameNum start=(i-1)*ShiftLen+1;

spec=Spec(:,i);

sig(start:start+windowLen-1)=sig(start:start+windowLen-1)+ real(ifft(spec,windowLen));

end

ReconstructedSignal=sig;

MATLAB code thuật toán Trừ phổ

function signalOut = Tru_Pho(signal)

% Nâng cao chat luong tieng noi bang phuong pháp Spectral Subtraction

fs = 10000; % tan so lay mau

IS = 0.25; %

if (nargin<3 || isstruct(IS)) IS=.25; %seconds

end

W=fix(.0256*fs); %Window length is 25,6 ms

nfft=W;

SP=.4; %Shift percentage is 40% (10ms) %Overlap-Add method works good with this value(.4)

% wnd=hamming(W);

wnd=hamming(256);

NIS=fix((IS*fs-W)/(SP*W) +1);%number of initial silence segments

Gamma=1;%Magnitude Power (1 for magnitude spectral subtraction 2 for power spectrum subtraction)

%Change Gamma to 1 to get a completely different performance % Segment Begin ---

Window=wnd(:); %make it a column vector

L=length(signal); SPNew=fix(W.*SP);

N=fix((L-W)/SPNew +1); %number of segments

T1=1:W; T2=0:(N-1); Index=(repmat(T1,N,1)+repmat((T2)'*SPNew,1,W))'; hw=repmat(Window,1,N); si=size(hw); y = zeros(si); for i=1:si(1)

for j=1:si(2) y(i,j)=signal(Index(i,j)); end end y=y.*hw; % Segment End --- Y=fft(y,nfft);

YPhase=angle(Y(1:fix(end/2)+1,:)); %Noisy Speech Phase

Y=abs(Y(1:fix(end/2)+1,:)).^Gamma;%Specrogram

numberOfFrames=size(Y,2); FreqResol=size(Y,1);

N=mean(Y(:,1:NIS)')'; %initial Noise Power Spectrum mean

NoiseCounter=0;

NoiseLength=9;%This is a smoothing factor for the noise updating

Beta=.03; minalpha=1; maxalpha=3; minSNR=-5; maxSNR=20; alphaSlope=(minalpha-maxalpha)/(maxSNR-minSNR); alphaShift=maxalpha-alphaSlope*minSNR; BN=Beta*N; X=zeros(FreqResol,numberOfFrames); for i=1:numberOfFrames

[NoiseFlag, SpeechFlag, NoiseCounter,

Dist]=vad(Y(:,i).^(1/Gamma),N.^(1/Gamma),NoiseCounter); %Magnitude Spectrum Distance VAD

if SpeechFlag==0

N=(NoiseLength*N+Y(:,i))/(NoiseLength+1); %Update and smooth noise

BN=Beta*N; end

SNR=10*log(Y(:,i)./N);

alpha=alphaSlope*SNR+alphaShift;

alpha=max(min(alpha,maxalpha),minalpha);

X(:,i)=max(D,BN); %if BY>D X=BY else X=D which sets very small values of subtraction result to an attenuated

%version of the input power spectrum.

end SigOverLapAdd=OverlapAdd2(X.^(1/Gamma),YPhase,W,SP*W); signalOut = signal; L=length(SigOverLapAdd); signalOut(1:L) = SigOverLapAdd(1:L); end function ReconstructedSignal=OverlapAdd2(XNEW,yphase,windowLen,ShiftLen) if nargin<2 yphase=angle(XNEW); end if nargin<3 windowLen=size(XNEW,1)*2; end if nargin<4 ShiftLen=windowLen/2; end if fix(ShiftLen)~=ShiftLen ShiftLen=fix(ShiftLen); end [FreqRes FrameNum]=size(XNEW); Spec=XNEW.*exp(1i*yphase);

if mod(windowLen,2) %if FreqResol is odd

Spec=[Spec;flipud(conj(Spec(2:end,:)))]; else Spec=[Spec;flipud(conj(Spec(2:end-1,:)))]; end sig=zeros((FrameNum-1)*ShiftLen+windowLen,1); for i=1:FrameNum start=(i-1)*ShiftLen+1; spec=Spec(:,i); xx=real(ifft(spec,windowLen)); xxx=sig(start:start+windowLen-1); for j=1:windowLen sig(start+j-1) = xxx(j) + xx(j);

end end

ReconstructedSignal=sig; end

function [NoiseFlag, SpeechFlag, NoiseCounter,

Dist]=vad(signal,noise,NoiseCounter,NoiseMargin,Hangover) if nargin<4 NoiseMargin=3; end if nargin<5 Hangover=8; end if nargin<3 NoiseCounter=0; end FreqResol=length(signal); SpectralDist= 20*(log10(signal)-log10(noise)); SpectralDist(find(SpectralDist<0))=0; Dist=mean(SpectralDist); if (Dist < NoiseMargin) NoiseFlag=1; NoiseCounter=NoiseCounter+1; else NoiseFlag=0; NoiseCounter=0; end

% Detect noise only periods and attenuate the signal

if (NoiseCounter > Hangover) SpeechFlag=0; else SpeechFlag=1; end end.

MATLAB thuật toán SW

function varargout = tangcuongamthanh(varargin)

% TANGCUONGAMTHANH, by itself, creates a new TANGCUONGAMTHANH or raises the existing

% singleton*. %

% H = TANGCUONGAMTHANH returns the handle to a new TANGCUONGAMTHANH or the handle to

% the existing singleton*. %

% TANGCUONGAMTHANH('CALLBACK',hObject,eventData,handles,...) calls the local

% function named CALLBACK in TANGCUONGAMTHANH.M with the given input arguments.

%

% TANGCUONGAMTHANH('Property','Value',...) creates a new TANGCUONGAMTHANH or raises the

% existing singleton*. Starting from the left, property value pairs are

% applied to the GUI before tangcuongamthanh_OpeningFcn gets called. An % unrecognized property name or invalid value makes property application % stop. All inputs are passed to tangcuongamthanh_OpeningFcn via varargin. %

% *See GUI Options on GUIDE's Tools menu. Choose "GUI allows only one % instance to run (singleton)".

%

% See also: GUIDE, GUIDATA, GUIHANDLES

% Edit the above text to modify the response to help tangcuongamthanh % Last Modified by GUIDE v2.5 21-Sep-2014 00:35:18

% Begin initialization code - DO NOT EDIT

gui_Singleton = 1;

gui_State = struct('gui_Name', mfilename, ... 'gui_Singleton', gui_Singleton, ...

'gui_OpeningFcn', @tangcuongamthanh_OpeningFcn, ... 'gui_OutputFcn', @tangcuongamthanh_OutputFcn, ... 'gui_LayoutFcn', [] , ...

if nargin && ischar(varargin{1})

gui_State.gui_Callback = str2func(varargin{1}); end

if nargout

[varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:}); else

gui_mainfcn(gui_State, varargin{:}); end

% End initialization code - DO NOT EDIT

% --- Executes just before tangcuongamthanh is made visible.

function tangcuongamthanh_OpeningFcn(hObject, eventdata, 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 tangcuongamthanh (see VARARGIN) % Choose default command line output for tangcuongamthanh

handles.output = hObject;

% Update handles structure

guidata(hObject, handles);

% UIWAIT makes tangcuongamthanh wait for user response (see UIRESUME) % uiwait(handles.figure1);

% --- Outputs from this function are returned to the command line.

function varargout = tangcuongamthanh_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 handles structure

varargout{1} = handles.output;

% --- Executes on button press in pushbutton1.

function pushbutton1_Callback(hObject, eventdata, handles)

% hObject handle to pushbutton1 (see GCBO)

% eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA)

[FileName,PathName] = uigetfile({'*.wav'},'Load Wav File'); [x,Fs] = wavread([PathName '/' FileName]); handles.x = x ./ max(abs(x)); handles.Fs = Fs; %axes(handles.axesSignal1); time = 0:1/Fs:(length(handles.x)-1)/Fs; %plot(time, handles.x); axis([0 max(time) -1 1]); axes(handles.axes1); specgram(handles.x, 1024, handles.Fs); %title('Signal Spectrogram'); handles.fileLoaded = 1; %axes(handles.axesSpecNoise); cla; %axes(handles.axesSpec2); cla; axes(handles.axes2); cla; handles.fileNoisy = 0; handles.fileFinal = 0; guidata(hObject, handles);

% --- Executes on button press in pushbutton3.

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)

sound(handles.x, handles.Fs); end

% --- Executes on button press in pushbutton4.

function pushbutton4_Callback(hObject, eventdata, handles)

% hObject handle to pushbutton4 (see GCBO)

% eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA)

N = 300; %Fpass = handles.Fstop; Fpass=1000; Fstop = Fpass - 30;

Hd_inv = generateHighPassFilter(Fpass, Fstop, handles.Fs, N);

%axes(handles.axesFilter);

%Hd_inv = inverseFilter(handles.Hd, handles.Fs,1,0);

[F,w] = freqz(Hd_inv, 1 , 1000, handles.Fs);

%semilogy(w,abs(F));

handles.Hd_inv = Hd_inv;

xFinal = filter(handles.Hd_inv, 1, handles.x);

handles.xFinal = xFinal / max(abs(xFinal)); axes(handles.axes2); specgram(handles.xFinal, 1024, handles.Fs); handles.fileFinal = 1; guidata(hObject, handles);

% --- Executes on button press in pushbutton5.

function pushbutton5_Callback(hObject, eventdata, handles)

% eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA)

if(handles.fileFinal==1)

sound(handles.xFinal, handles.Fs); end

% --- Executes on button press in pushbutton6.

function pushbutton6_Callback(hObject, eventdata, handles)

% hObject handle to pushbutton6 (see GCBO)

% eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA)

Close.

Matlab Code thuật toán SW dựa trên SS:

function [output,Speech]=SSBasedOnWF (signal,fs,IS) % output= SSBasedOnWF(signal,fs,IS)

% "A Parametric Formulation of the Generalized Spectral Subtraction Method"

if (nargin<3 | isstruct(IS))

IS=.25; %Initial Silence or Noise Only part in seconds end

W=fix(.025*fs); %Window length is 25 ms

SP=.4; %Shift percentage is 40% (10ms) %Overlap-Add method works good with

this value(.4)

wnd=hamming(W);

%IGNORE FROM HERE ...

if (nargin>=3 & isstruct(IS))%This option is for compatibility with another programme W=IS.windowsize SP=IS.shiftsize/W; %nfft=IS.nfft; wnd=IS.window; if isfield(IS,'IS') IS=IS.IS; else IS=.25; end

end

% ...UP TO HERE % pre_emph=0;

% signal=filter([1 -pre_emph],1,signal);

NIS=fix((IS*fs-W)/(SP*W) +1);%number of initial silence segments PowExp=1;% (1 for magnitude spectral subtraction, 2 for power spectrum subtraction)

y=segment(signal,W,SP,wnd); % This function chops the signal into frames Y=fft(y);

YPhase=angle(Y(1:fix(end/2)+1,:)); %Noisy Speech Phase Y=abs(Y(1:fix(end/2)+1,:)).^PowExp;%Specrogram

numberOfFrames=size(Y,2); FreqResol=size(Y,1);

N=mean((Y(:,1:NIS)').^(1/PowExp))'; %initial Noise Power Spectrum mean LambdaD=mean((Y(:,1:NIS)').^(2/PowExp))';%initial Noise Power Spectrum

variance

alpha=.99; %used in smoothing xi (For Deciesion Directed method for estimation of A Priori SNR)

NoiseCounter=0;

NoiseLength=9;%This is a smoothing factor for the noise updating G=ones(FreqResol,1);%Initial Gain used in calculation of the new xi

InitialGamma=ones(FreqResol,1);%Initial A posteriori SNR used in calculation of the new xi

X=zeros(size(Y)); % Initialize X (memory allocation) % h=waitbar(0,'Wait...');

for i=1:numberOfFrames

%%%%%%%%%%%%%%%%VAD and Noise Estimation START if i<=NIS % If initial silence ignore VAD SpeechFlag=0;

NoiseCounter=100; else % Else Do VAD

[NoiseFlag, SpeechFlag, NoiseCounter,

Dist]=vad(Y(:,i).^(1/PowExp),N,NoiseCounter); %Magnitude Spectrum Distance

VAD end

if SpeechFlag==0 % If not Speech Update Noise Parameters

smooth noise mean ( Eq 15 ) LambdaD=(NoiseLength*LambdaD +Y(:,i).^(2/PowExp)))./(1+NoiseLength);

%Update and smooth noise variance( Eq 34 ) end

Gamma = (Y(:,i).^(2/PowExp)./ LambdaD); if i>1

xi = ((1-alpha).*max(Y(:,i).^(2/PowExp) - LambdaD,0) + alpha*X(:,i-1).^(2/PowExp)) ./ LambdaD;

% Spectral Subtraction & estimate xi else xi = (1-alpha).*max(Gamma - 1,0) + alpha*(G.^2).*InitialGamma ; end G = sqrt(xi./(xi+1)); X(:,i) = G.* Y(:,i); %waitbar(i/numberOfFrames,h,num2str(fix(100*i/numberOfFrames))); end % close(h); output=OverlapAdd2(X.^(1/PowExp),YPhase,W,SP*W); %Overlap-add Synthesis of speech

CÁC TÀI LIỆU THAM KHẢO

[1] N. Milivojevi´c and Dragiˇsa Z. Balaneskovi´c(December 2009) - Enhancement Of The Perceptive Quality Of The Noisy-Zoran.

[2] Mohamed M. E. EL-Halawany(February 2012) -Signal Quality Enhancement of Acousto Optic Modulators for both High Modulation Speed and Transmission Data Rates.

[3] Nils Westerlund (May 2003) -Applied Speech Enhancement for personal communication.

[4] Dr.Philipos C.Loizou, chair(2004) -Noise estimation algorithms for highly non-stationary environments.

[5] Hoàng Minh Thảo (Jun 2012), speech enhencement algorithms.

[6] d. Deepa1, A. Shanmugam2( March 2010)- spectral subtraction method of speech enhancement using adaptive estimation of noise with pde method as a preprocessing technique (Department of Electronics and Communication, Bannari Amman Institute of Technology, Sathyamangalam, India).

[7] Alan V. Oppenheim and George C. Verghese (2010)-Wiener Filtering. [8] Ekaterina Verteletskaya, Boris Simak-Noise Reduction Based on Modified Spectral Subtraction Method (IAENG International Journal of Computer Science, 38:1, IJCS_38_1_10).

[9]. Nguyễn Quốc Trung, Xử lý tín hiệu số - tập 1, NXB Khoa học kĩ thuật. [10] Analysis of VoIP Signal Processing for Performance Enhancement. [11]. Lombard, E.(1911), Le signe de lelevation de la voix, Ann. Mal. Oreil. Larynx.,37, 101-119

[12]. Philippos C.Loizou, Speech Enhancement Theory and Practice,pp. 2-7. [13]. Ths.Hoàng Lê Uyên Thục, Giáo trình xử lý tín hiệu số, Đại học Bách Khoa –Đại học Đà Nẵng.

[14]. Lim, J. and Oppenheim, A.V.(1979), Enhancement and bandwidth compression of noisy speech, Proc. IEEE, 67(12),pp. 1586-1604.

[15]. Weiss, M., Aschkenasy, E., and Parsons, T.(1974), Study and the development of the INTEL technique for improving speech intelligibility, Technical Report NSC-FR/ 4023.

[16] Speech Enhancement using a minimum mean-square ieee transactions on acoustics, speech, and signal processing, vol. assp-32, no. 6, december 1984.

[17] ITU_T Recommendation P.800 ( August 1996) - “Methods for Subjective Determination of Transmission Quality”

[18] Hansen J. and Pellon B(1998). , “An effective quality evaluation protocol for Speech Enhancement algorithms”, Proc. Int Conf. Spoken Language Process.

Một phần của tài liệu Tìm hiểu một số phương pháp tăng cường chất lượng tiếng nói (Trang 58 - 76)

Tải bản đầy đủ (PDF)

(76 trang)