天天看點

基于MATLAB的說話人識别系統

基于MATLAB的說話人識别系統
  1. 語音識别的簡單介紹

基于MATLAB VQ算法的說話人識别系統,矢量量化起着雙重作用。在訓練階段,把每一個說話者所提取的特征參數進行分類,産生不同碼字所組成的碼本。在識别(比對)階段,我們用VQ方法計算平均失真測度(本系統在計算距離d時,采用歐氏距離測度),進而判斷說話人是誰。

語音識别系統結構框圖如圖1所示

基于MATLAB的說話人識别系統

圖1 語音識别系統結構框圖

  1. 語者識别的概念

語者識别就是根據說話人的語音信号來判别說話人的身份。語音是人的自然屬性之一,由于說話人發音器官的生理差異以及後天形成的行為差異,每個人的語音都帶有強烈的個人色彩,這就使得通過分析語音信号來識别說話人成為可能。用語音來鑒别說話人的身份有着許多獨特的優點,如語音是人的固有的特征,不會丢失或遺忘;語音信号的采集友善,系統裝置成本低;利用電話網絡還可實作遠端客戶服務等。是以,近幾年來,說話人識别越來越多的受到人們的重視。與其他生物識别技術如指紋識别、手形識别等相比較,說話人識别不僅使用友善,而且屬于非接觸性,容易被使用者接受,并且在已有的各種生物特征識别技術中,是唯一可以用作遠端驗證的識别技術。是以,說話人識别的應用前景非常廣泛:今天,說話人識别技術已經關系到多學科的研究領域,不同領域中的進步都對說話人識别的發展做出了貢獻。說話人識别技術是集聲學、語言學、計算機、資訊處理和人工智能等諸多領域的一項綜合技術,應用需求将十分廣闊。在吃力語音信号的時候如何提取信号中關鍵的成分尤為重要。語音信号的特征參數的好壞直接導緻了辨識的準确性。

  1. 示範分析

我們的功能分為兩部分:對已經儲存的9個數字的語音進行辨識和實時的判斷說話人說的是否為一個數.在前者的實驗過程中,先把9個數字的聲音儲存成wav的格式,放在一個檔案夾中,作為一個檢測的資料庫.然後對檢測者實行識别,系統給出提示是哪個數字.

在第二個功能中,實時的錄取一段說話人的聲音作為模闆,提取mfcc特征參數,随後緊接着進行遇着識别,也就是讓其他人再說相同的話,看是否是原說話者.

實驗過程及具體功能如下

先打開Matlab 使Current Directory為錄音及程式所所在的檔案夾

再打開檔案“enter.m”,點run運作,打開enter界面,點選“進入”按鈕進入系統。(注:檔案包未封裝完畢,目前隻能通過此方式打開運作。)(如下圖figure1)

基于MATLAB的說話人識别系統
figure1 在對資料庫中已有的語者進行識别子產品:
基于MATLAB的說話人識别系統

選擇載入語音庫語音個數;

點選語音庫錄制模版進行已存語音資訊的提取;

點選錄音-test進行現場錄音;

點選語者判斷進行判斷數字,并顯示出來。

在實時語者識别子產品:
基于MATLAB的說話人識别系統

點選實時錄制模闆上的“錄音-train”按鈕,是把新語者的聲音以wav格式存放在”實時模闆”檔案夾中, 接着點選“實時錄制模闆”,把新的模闆提取特征值。随後點選實時語者識别模闆上的“錄音-train”按鈕,是把語者的聲音以wav格式存放在”測試”檔案夾中,再點選“實時語者識别”,在對測得的聲音提取特征值的同時,和實時模闆進行比對,然後得出是否是實時模闆中的語者。另外面闆上的播放按鈕都是播放相對應左邊錄取的聲音。

想要測量多次,隻要接着錄音,自動儲存,然後程式比對音頻就可以。

退出隻要點選菜單File/Exit,退出程式。

運作代碼

附:GUI程式代碼

function varargout = untitled2(varargin)

% UNTITLED2 M-file for untitled2.fig

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

% singleton*.

%

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

% the existing singleton*.

%

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

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

%

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

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

% applied to the GUI before untitled2_OpeningFunction gets called. An

% unrecognized property name or invalid value makes property application

% stop. All inputs are passed to untitled2_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

% Copyright 2002-2003 The MathWorks, Inc.

% Edit the above text to modify the response to help untitled2

% Last Modified by GUIDE v2.5 08-Jun-2010 23:58:57

% Begin initialization code - DO NOT EDIT

gui_Singleton = 1;

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

'gui_Singleton', gui_Singleton, ...

'gui_OpeningFcn', @untitled2_OpeningFcn, ...

'gui_OutputFcn', @untitled2_OutputFcn, ...

'gui_LayoutFcn', [] , ...

'gui_Callback', []);

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 untitled2 is made visible.

function untitled2_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 untitled2 (see VARARGIN)

% Choose default command line output for untitled2

handles.output = hObject;

% Update handles structure

guidata(hObject, handles);

axes(findobj('tag','axes13'));

imshow('3.jpg');

axes(findobj('tag','axes12'));

imshow('1.jpg');

% UIWAIT makes untitled2 wait for user response (see UIRESUME)

% uiwait(handles.figure1);

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

function varargout = untitled2_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)

Channel_Str=get(handles.popupmenu3,'String');

Channel_Number=str2double(Channel_Str{get(handles.popupmenu3,'Value')});

global moodle;

moodle = train('模版\',Channel_Number) %¶Ô´ýÇóÓïÒô½øÐÐÌáÈ¡Âë±¾

% --- Executes on button press in pushbutton2.

function pushbutton2_Callback(hObject, eventdata, handles)

% hObject handle to pushbutton2 (see GCBO)

% eventdata reserved - to be defined in a future version of MATLAB

% handglobal data1;

global moodle ;

test('測試\',1,moodle)%ʵʱÓïÒô¼ì²â

% --------------------------------------------------------------------

function Open_Callback(hObject, eventdata, handles)

% hObject handle to Open (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('')

file=get(handles.edits,[filename,pathname])

[y,f,b]=wavread(file);

% --------------------------------------------------------------------

function Exit_Callback(hObject, eventdata, handles)

% hObject handle to Exit (see GCBO)

% eventdata reserved - to be defined in a future version of MATLAB

% handles structure with handles and user data (see GUIDATA)

exit

% --------------------------------------------------------------------

function About_Callback(hObject, eventdata, handles)

% hObject handle to About (see GCBO)

% eventdata reserved - to be defined in a future version of MATLAB

% handles structure with handles and user data (see GUIDATA)

H=['語者識别']

helpdlg(H,'help text')

% --------------------------------------------------------------------

function File_Callback(hObject, eventdata, handles)

% hObject handle to File (see GCBO)

% eventdata reserved - to be defined in a future version of MATLAB

% handles structure with handles and user data (see GUIDATA)

% --------------------------------------------------------------------

function Edit_Callback(hObject, eventdata, handles)

% hObject handle to Edit (see GCBO)

% eventdata reserved - to be defined in a future version of MATLAB

% handles structure with handles and user data (see GUIDATA)

% --------------------------------------------------------------------

function Help_Callback(hObject, eventdata, handles)

% hObject handle to Help (see GCBO)

% eventdata reserved - to be defined in a future version of MATLAB

% handles structure with handles and user data (see GUIDATA)

% --- Executes on button press in pushbutton7.

function pushbutton7_Callback(hObject, eventdata, handles)

% hObject handle to pushbutton7 (see GCBO)

% eventdata reserved - to be defined in a future version of MATLAB

% handles structure with handles and user data (see GUIDATA)

msg='請速度錄音¡'

msgbox(msg)

clear

global data1;

%global dataDN1;

AI = analoginput('winsound');

chan = addchannel(AI,1:2);

duration = 3; %1 second acquisition

set(AI,'SampleRate',8000)

ActualRate = get(AI,'SampleRate');

set(AI,'SamplesPerTrigger',duration*ActualRate)

set(AI,'TriggerType','Manual')

blocksize = get(AI,'SamplesPerTrigger');

Fs = ActualRate;

start(AI)

trigger(AI)

[data1,time,abstime,events] = getdata(AI);

fname=sprintf('E:\\Matlab語音識别系統\\實時模版\\s1.wav')

%dataDN1=wden(data1,'heursure','s','one',5,'sym8');denoise

wavwrite(data1,fname)

msgbox(fname)

% --- Executes on button press in pushbutton8.

function pushbutton8_Callback(hObject, eventdata, handles)

% hObject handle to pushbutton8 (see GCBO)

% eventdata reserved - to be defined in a future version of MATLAB

% handles structure with handles and user data (see GUIDATA)

global data1;

%global dataDN1;

sound(data1)

%sound(dataDN1)

axes(handles.axes1)%set to plot at axes1

plot(data1);

%plot(dataDN1);

xlabel('訓練采樣序列'),ylabel('信号幅');

%xlabel('ѵÁ·²ÉÑùÐòÁÐ'),ylabel('sym8С²¨½µÔëºóµÄÐźŷù');

grid on;

clear

% --- Executes on button press in pushbutton9.

function pushbutton9_Callback(hObject, eventdata, handles)

% hObject handle to pushbutton9 (see GCBO)

% eventdata reserved - to be defined in a future version of MATLAB

% handles structure with handles and user data (see GUIDATA)

msg='請速度錄音¡'

msgbox(msg)

clear

global data2;

%global dataDN2;

AI = analoginput('winsound');

chan = addchannel(AI,1:2);

duration = 3; %1 second acquisition

set(AI,'SampleRate',8000)

ActualRate = get(AI,'SampleRate');

set(AI,'SamplesPerTrigger',duration*ActualRate)

set(AI,'TriggerType','Manual')

blocksize = get(AI,'SamplesPerTrigger');

Fs = ActualRate;

start(AI)

trigger(AI)

[data2,time,abstime,events] = getdata(AI);

fname=sprintf('E:\\Matlab語音識别系統\\測試\\s1.wav')

%dataDN1=wden(data1,'heursure','s','one',5,'sym8');denoise

wavwrite(data2,fname)

msgbox(fname)

% --- Executes on button press in pushbutton10.

function pushbutton10_Callback(hObject, eventdata, handles)

% hObject handle to pushbutton10 (see GCBO)

% eventdata reserved - to be defined in a future version of MATLAB

% handles structure with handles and user data (see GUIDATA)

global data2;

%global dataDN2;

sound(data2)

%sound(dataDN2)

axes(handles.axes2)%set to plot at axes1

plot(data2);

%plot(dataDN2);

xlabel('測試采樣序列'),ylabel('信号幅');

%xlabel('²âÊÔ²ÉÑùÐòÁÐ'),ylabel('sym8С²¨½µÔëºóµÄÐźŷù');%%

grid on;

clear

% --- Executes on button press in pushbutton11.

function pushbutton11_Callback(hObject, eventdata, handles)

% hObject handle to pushbutton11 (see GCBO)

% eventdata reserved - to be defined in a future version of MATLAB

% handles structure with handles and user data (see GUIDATA)

global moodle ;

testDB('測試\',1,moodle)

% --- Executes on button press in pushbutton12.

function pushbutton12_Callback(hObject, eventdata, handles)

% hObject handle to pushbutton12 (see GCBO)

% eventdata reserved - to be defined in a future version of MATLAB

% handles structure with handles and user data (see GUIDATA)

global moodle;

moodle = train('實時模闆\',1)

% --- Executes on selection change in popupmenu3.

function popupmenu3_Callback(hObject, eventdata, handles)

% hObject handle to popupmenu3 (see GCBO)

% eventdata reserved - to be defined in a future version of MATLAB

% handles structure with handles and user data (see GUIDATA)

% Hints: contents = get(hObject,'String') returns popupmenu3 contents as cell array

% contents{get(hObject,'Value')} returns selected item from popupmenu3

str=get(handles.popupmenu3,'String');

val=str2num(str{get(handles.popupmenu3,'Value')});

switch val

case 1

case 2

case 3

case 4

case 5

case 6

case 7

case 8

case 9

end

% --- Executes during object creation, after setting all properties.

function popupmenu3_CreateFcn(hObject, eventdata, handles)

% hObject handle to popupmenu3 (see GCBO)

% eventdata reserved - to be defined in a future version of MATLAB

% handles empty - handles not created until after all CreateFcns called

% Hint: popupmenu controls usually have a white background on Windows.

% See ISPC and COMPUTER.

if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))

set(hObject,'BackgroundColor','white');

end

% --- Executes on button press in pushbutton9.

function pushbutton13_Callback(hObject, eventdata, handles)

% hObject handle to pushbutton9 (see GCBO)

% eventdata reserved - to be defined in a future version of MATLAB

% handles structure with handles and user data (see GUIDATA)

% --- Executes on button press in pushbutton10.

function pushbutton14_Callback(hObject, eventdata, handles)

% hObject handle to pushbutton10 (see GCBO)

% eventdata reserved - to be defined in a future version of MATLAB

% handles structure with handles and user data (see GUIDATA)

% --- Executes during object creation, after setting all properties.

%function axes8_CreateFcn(hObject, eventdata, handles)

% hObject handle to axes8 (see GCBO)

% eventdata reserved - to be defined in a future version of MATLAB

% handles empty - handles not created until after all CreateFcns called

% Hint: place code in OpeningFcn to populate axes8

繼續閱讀