how to use the pushbutton in GUI to record the voice

4 ビュー (過去 30 日間)
enas
enas 2014 年 4 月 26 日
コメント済み: Roberto 2014 年 4 月 27 日
hello , I was trying to apply GUI with guide to my code voice recognition I actually dont know a lot about GUI .first, what I want to do is to assgin a push button for recording , how can I do that? I know how to make the figure but I dont know how to proceed after that starting from the option view callbacks ,here is a simple code as a start ,
rec1 = audiorecorder(22050, 16, 2);
disp('Start speaking.')
recordblocking(rec1, 2);
disp('End of Recording.');
any advice would be appreciated .
  3 件のコメント
enas
enas 2014 年 4 月 27 日
it didnt work !!
Jan
Jan 2014 年 4 月 27 日
@enas: "Didn't work" does not allow us to recognize, what is happening. Please spend the time to explain any details. Show us your code and explain the problems.

サインインしてコメントする。

採用された回答

Roberto
Roberto 2014 年 4 月 27 日
編集済み: Roberto 2014 年 4 月 27 日
Try reading the getting started section of GUI's , and have a look in to these lines:
% Create the Audio recorder Object
>> rec = audiorecorder(22050, 16, 2);
% Create a Function to create the GUI
function test(rec)
f= figure ;
uicontrol(f,'style','pushbutton','position',[10 10 200 20],'String','Record','CallBack',@buttonCallback) ;
function buttonCallback(~,~)
disp('Recording... start talking');
rec.recordblocking(2);
disp('Stopped.');
end
end
% Execute the function with the object as a parameter
>> test(rec)
  2 件のコメント
enas
enas 2014 年 4 月 27 日
thanks that helped , do you know how to combine it with rest of my code ? I want the code be waiting for the pushbutton then continue excuting ,
[x1,fs]=wavread('C:\Users\user\Documents\MATLAB\red.wav');
X1=x1(:,1);
rec = audiorecorder(22050, 16, 2);
test(rec);
play(rec);
y= getaudiodata(rec);
Y=y(:,1);
z1=xcorr(X1,Y);
maxred=max(z1);
length1=length(z1);
t1=-((length1-1)/2):1:((length1-1)/2);
t1=t1';
max5=15; all=[maxred max5]
m=max(all);
if m<=maxred
soundsc(wavread('red.wav'),22050)
disp('red');
else soundsc(wavread('denied.wav'),8000)
disp('denied');
end
Roberto
Roberto 2014 年 4 月 27 日
try adding another button like the one to record and edit it's code...

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeAudio and Video Data についてさらに検索

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by