How do I properly update this code.

4 views (last 30 days)
wickedhurricane
wickedhurricane on 28 Nov 2015
Edited: Walter Roberson on 29 Nov 2015
How can I make this line of code that functioned properly in Matlab 2012 operate correctly in Matlab 2015b?
time = get(handles.time_slider,'Value');
x = wavrecord(time*8000,8000);
set(handles.gender,'String','See the estimated gender here');
set(handles.Fx1,'String', 'Fundamental Frequency');
Twice I've been directed to the following page but it hasn't helped.
The full code is attached.
  2 Comments
Steven Lord
Steven Lord on 29 Nov 2015
How does this code not "operate correctly" in release R2015b? Does it throw an error (and if so what is the FULL text of the error message), does it issue a warning (and post the full text of the warning), etc?
Image Analyst
Image Analyst on 29 Nov 2015
>> gui_speech_analysis
Undefined function or variable 'wavrecord'.
Error in gui_speech_analysis>pushbutton_record_Callback (line 113)
x = wavrecord(time*8000,8000);
Error in gui_mainfcn (line 95)
feval(varargin{:});
Error in gui_speech_analysis (line 42)
gui_mainfcn(gui_State, varargin{:});
Error in
matlab.graphics.internal.figfile.FigFile/read>@(hObject,eventdata)gui_speech_analysis('pushbutton_record_Callback',hObject,eventdata,guidata(hObject))
Error while evaluating UIControl Callback

Sign in to comment.

Answers (1)

Walter Roberson
Walter Roberson on 29 Nov 2015
function pushbutton_record_Callback(hObject, eventdata, handles)
% hObject handle to pushbutton_record (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
global x;
time = get(handles.time_slider,'Value');
recorder = audiorecorder(8000,8,1); %new
x = record(recorder, ceil(time*8000)); %changed
set(handles.gender,'String','See the estimated gender here');
set(handles.Fx1,'String', 'Fundamental Frequency');
guidata(hObject, handles);
  2 Comments
wickedhurricane
wickedhurricane on 29 Nov 2015
Thank you for your help, but when I make the changes I get the following error:
Error using audiorecorder/record
Too many output arguments.
Error in gui_speech_analysis>pushbutton_record_Callback (line 115)
x = record(recorder, ceil(time*8000));
What does too many output arguments mean?
Walter Roberson
Walter Roberson on 29 Nov 2015
Edited: Walter Roberson on 29 Nov 2015
function pushbutton_record_Callback(hObject, eventdata, handles)
% hObject handle to pushbutton_record (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
global x;
time = get(handles.time_slider,'Value');
recorder = audiorecorder(8000,8,1);
recordblocking(recorder, ceil(time*8000));
x = getaudiodata(recorder);
set(handles.gender,'String','See the estimated gender here');
set(handles.Fx1,'String', 'Fundamental Frequency');
guidata(hObject, handles);

Sign in to comment.

Categories

Find more on Entering Commands in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!