can someone help me explain what is wrong in my source code ? if i run, i can't get the result, i don't know where is this error

1 view (last 30 days)
function varargout = utama (varargin)
% --- Executes on button press in browse_btn.
function browse_btn_Callback (hObject, eventdata, handles)
clc
%read the file
[filename, pathname]=uigetfile ('*.wav*');
if ~isequal (filename, 0)
[y,Fs] = audioread(fullfile (pathname,filename));
a=0.97;
y2= filter ((1-a), 1, y);
time=(1:length(y))/Fs;
time1=(length(y))/Fs;
axes (handles.axe_original);
plot(time, y);
grid on
set (gca, 'unit', 'pixel');
set (handles.editbrowse, 'string',filename)
set (handles.editsamplerate,'string',Fs);
set (handles.editsampletime,'string',time1);
[y,Fs] = audioread(fullfile(pathname,filename));
else
return
end
handles.y2 = y2;
handles.y = y;
handles.Fs = Fs;
handles.timel = timel;
guidata(hObject,handles)
%---Executes on button press in Mel-Frequency Ceptral Coefficient_btn.
function Mel_Frequency_Ceptstral_Coefficient_btn_Callback(hObject, eventdata, handles)
%hObject handle to Mel-Frequency Cepstral Coefficient_btn (see GCBO)
%framingl
y=handles.y;
Fs=handles.Fs;
a=0.97;
y2=filter([1-a],1,y);
n=512 %Number of FAST FOURIER TRANSFORM points
Tf=(length(y))/Fs; %Frame duration in seconds
N=Fs*Tf; %Number of samples per frame
%fn=24; %Number of mel filters
l=length(y); %total number of sample speech
Ts=0.01; %Framse step in seconds
FrameStep=Fs*Ts; %Frame step in samples
noFrame=floor(1/FrameStep); %Maximum no of frames in speech sample
for i=1:noFrame
frame=y2((i-1)*FrameStep+1:(i-1)*FrameStep+N); %Holds individual frames
end
rata_frame = mean (frame);
set(handles.frameblocking,'string',rata_frame);
%figure;
%plot(frame(1,:));
handles.frame = frame ;
handles.rata_frame = rata_frame;
%proses.windowing
Fs=handles.Fs;
t=(1:512)'/Fs;
n=512;
f=n/t;
original=sin(2*pi*f*t)+0.2*randn(length(t),1);
windowed = original.*hamming(length(t));
rata_window = mean (windowed);
set (handles.windowing,'string',rata_window);
handles.rata_window = rata_window;
%FAST FOURIER TRANSFORM
Fs=handles.Fs;
a=0.97;
%y2=filter([1-a],1,y);
n=4096; %Power of 2 number of samples/length of FAST FOURIER TRANSFORM
%Get/Generate data
t=0:1/Fs:(n-1)/Fs; %n/fs sec sample
x=(1.3)*sin(2*pi*1500*t) ... % 1.5k Hz component
+ (1.7)*sin(2*pi*4000*(t-2)) ... %4.0k Hz component
+ (2.5)*randn(size(t));
%# Frequency Bins
bins = (0:1:n-1)*(Fs/n);
y = fft(x,n);
rata_fft = mean (y);
set(handles.fft, 'string', rata_fft);
handles.rata_fft = rata_fft;
%DISCRETE COSINE TRANSFORM
y=handles.y;
in_dct = f_fft_(y);
% Input for a DISCRETE COSINE TRANSFORM Transform
k=0 : ( length (in_dct)-1);
%limits for Variable K tends to N-1.
ex=exp (-j*k*pi/length(in_dct));
%Multiplaying Co-efficient.
in_dct=in_dct.*ex; %Point to point Multiplication.
in_dct=2*real(in_dct); % Extraction of Real-Part and Multiplaying with 2.
n=length(in_dct);
%Length of the input_dicrete cosine transform.
p=1:n; %To Get Even Symethric Output Waveform (DISCRETE COSINE TRANSFORM).
n=length (in_dct)/2;
%Length of the input_discrete cosine transform halved.
p=1:n; %samples halved
x(p)=in_dct(p);%Storing valves in another Variable.
x;
rata_dct=mean (x);
set(handles.dct,'string',rata_dct); %Cepstrallifter
Fs=handles.Fs;
y2=handles.y2;
y2 = y2 (:,1); %get the first channel
xmax = max (abs(y2)); %find the maximum value
y2=y2/xmax; %scale the sinal
%time vector generation
N= length (y2);
t= (0:N-1)/Fs;
% cepstral analysis
[C,q] = cepstrum (y2,Fs);
handles.C = C;
%plot of the signal
figure;
subplot (2,1,1)
plot (t,y2,'r')
xlim([0 max (t)])
ylim([-1.1*max(abs(y2)) 1.1*max(abs(y2))])
grid on
set (gca, 'FontName', 'Times New Roman', 'FontSize',12)
xlabel ('Time,s')
ylabel ('Normalized amplitude')
title ('The signal in the time domain')
%plot of the cepstrum
%1 ms minimum speech quefrency (1000 Hz) and 20 ms maximum speech qufrency(50 Hz)
subplot (2,1,2)
plot (q*1000, C, 'r');
grid on
xlim ([1 20])
set (gca, 'FontName', 'Times New Roman', 'FontSize', 12)
xlabel('Quefrency, ms')
ylabel('Amplitude')
title('Amplitude cepstrum of the signal(quefrencies from ms to 20 ms)')
%rata-rata nilai cepstrum
C=handles.C;
rata=mean(C);
handles.rata =rata;
set(handles.cepstrum, 'string',rata);
%handles.rata = rata;
%--- Executes on button press in uji_btn.
function uji_btn_Callback(h0bject,eventdata,handles)
% % a = data input training data dari excel
a=xlsread ('C:\Users\waf_r\Download\refsuara\input.xlsx','Sheet1');
cepstrum=handles.cepstrum
time1=handles.time1;
c=[cepstrum;time1];
t(1:3)=1;t(4:6)=2;t(7:9)=3;t(10:12)=4;t(13:15)=5;t(16:18)=6;t(19:21)=7;t(22:24)=8;
net = newff (a', t, [10 5], {'logsig', 'logsig'},'trainlm');
%melihat bobot, bobot akan diberikan secara acak oleh matlab
bobotawal_Input = net.IW(1,1);
bobotawal_bias_input = net.b(1,1);
%parameter training
net.trainParam.show = 25;
net.trainParam.epochs = 5000; %jumlah maksimum epoch
net.trainParam.goal = 0.00000000001; %nilai minimum error
net.trainParam.min_grad=le-10;
net.trainParam.max_fail=1000000000000000000000000000000000000000000000000000000
net.trainParam.Ir=0.01; %nilai learning rate
%training jaringan
net = train (net,a',t);
save net.mat
%uji jaringan;
y=sim(net,c');
y=round(y);
switch y
case 1
set (handles.edithasil, 'String','Sa','Visible','on')
case 2
set (handles.edithasil, 'String','Sho','Visible','on')
case 3
set (handles.edithasil, 'String','Dza','Visible','on')
case 4
set (handles.edithasil, 'String','Za','Visible','on')
case 5
set (handles.edithasil, 'String','Qo','Visible','on')
case 6
set (handles.edithasil, 'String','Ka','Visible','on')
case 7
set (handles.edithasil, 'String','A','Visible','on')
case 8
set (handles.edithasil, 'String','^A','Visible','on')
end
%akurasi hasil training
X= round (sim(net,a'));
%hasil=(t,X);
n=length(t);
b=0;
%b=jumlah input yang memiliki nilai sama dengan target
for i=1:n
if X(i)==t(i)
b=b+1;
end
end
b;
ak=(b/n)*100;
disp (['accuracy JARINGAN SYARAF TIRUAN =',num2str(ak,'%2f'),'%'])
% --- Executes on button press in play_ori_btn
function play_ori_btn_Callback(h0bject,eventdata,handles)
y=handles.y;
Fs=handles.Fs;
sound(y,Fs);
% --- Executes on button press in play_emphasis_btn.
function play_emphasis_btn_Callback(h0bject,eventdata, handles)
%h0bject handle to play_emphasis_btn (see GCBO)
%eventdata reserved - to be defined in a future version of MATLAB
%handles structure with handles and user data (see GUIDATA)
y=handles.y;
a=0.97;
y2=filter((1-a),1,y);
Fs=handles.Fs;
sound(y2,Fs);
  2 Comments
Walter Roberson
Walter Roberson on 1 Nov 2021
You get an error message? You get some result but not what you expect? You get no response when you click on your buttons? You can tell that Simulink was invoked but no output after that?
We don't have have your fig file. We do not have your Simulink model. We do not have your data. We do not have a description from you of what you are observing. But we are expected to tell you what the problem is??
Image Analyst
Image Analyst on 2 Nov 2021
Do you want to make it easy for us to help you? Can you attach your .m and .fig file along with any data files needed to run the code? Read Walter's comment above, and read this link:
Do what it says so we'll be able to help you.

Sign in to comment.

Answers (0)

Products


Release

R2015a

Community Treasure Hunt

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

Start Hunting!