why my code run in online matlab, and in app has an error?

I have a simple code with function "detectspeech" (see button) but in my pc app (version R2023a) don't work (in online version yes), give me this error:
error:
"Error using gather
Too many input arguments.
Error in detectSpeech (line 88)
[fs,varargin{:}] = gather(fs,varargin{:});
Error in teste_detetar_fala (line 18)
detectSpeech(audioIn,fs,"Window",win,"OverlapLength",overlap,"MergeDistance",mergeDist)"
Anyone know to solve this problem or why this hapenning?
code:
[audioIn,fs]=audioread('Sujeito_Teste.wav');
windowDuration = 0.074; % seconds
numWindowSamples = round(windowDuration*fs);
win = hamming(numWindowSamples,'periodic');
percentOverlap = 35;
overlap = round(numWindowSamples*percentOverlap/100);
mergeDuration = 0.44;
mergeDist = round(mergeDuration*fs);
detectSpeech(audioIn,fs,"Window",win,"OverlapLength",overlap,"MergeDistance",mergeDist)
Thanks for your attention.
Felipe L. Teixeira

5 Comments

If you have any more questions, then zip up your wav file and attach your file with the paperclip icon after you read this:
Are you using this function - detectSpeech? If yes, then note that this function requires the Signal Processing Toolbox.
Do you have access to the said toolbox and have it downloaded?
@Dyuman JoshiThank you for you feedback and attention, but the problem is not derived this topics, because i have all needed toolboxes to run (I said this because if i put only this:
detectSpeech(audioIn,fs)
my code run normaly,
but if i put this:
[idx,treshold] = detectSpeech(audioIn,fs,'Window',win,'OverlapLength',overlap,'MergeDistance',mergeDist);
give me an error.
error:
Error using gather
Too many input arguments.
Error in detectSpeech (line 88)
[fs,varargin{:}] = gather(fs,varargin{:});
Error in teste_detetar_fala (line 19)
[idx,treshold] = detectSpeech(audioIn,fs,'Window',win,'OverlapLength',overlap,'MergeDistance',mergeDist);
Which MATLAB release is being used? detectSpeech from the Signal Processing Toolbox does call gather(), but at least in the current version the line
[fs,varargin{:}] = gather(fs,varargin{:});
does not exist.
Please also show
which -all detectSpeech

Sign in to comment.

 Accepted Answer

It looks like a bug in the detectSpeech code for R2023a if you call detectSpeech with more than one parameter.
That section of the code was reworked a fair bit for R2023b beta

1 Comment

In version 2023b already works correctly.
Thank you all very much.
Felipe L. Teixeira

Sign in to comment.

More Answers (2)

Harsh Kumar
Harsh Kumar on 14 Jul 2023
Edited: Harsh Kumar on 19 Jul 2023
Hi Felipe ,
I understand that you are facing an error while running a code in MATLAB App which runs fine in MATLAB online .
It is happening because MATLAB online has all packages preinstalled in cloud .Since , you are using 'audioread ' function you will need to install the neccesary toolboxes like 'Audio System Toolbox' and 'Signal Processing Toolbox' before using it.
Follow the given steps to install the toolbox :
  1. Open MATLAB App.
  2. Click in Add-Ons
  3. Select Get Add-Ons
  4. Install the required toolbox
Refer to the this given documentation for details : https://in.mathworks.com/help/audio/ref/detectspeech.html

4 Comments

@Harsh Kumar Thank you for you feedback and attention, but the problem is not derived this topics, because i have installed all mandatory "add-ons" to run (I said this because if i put only this:
detectSpeech(audioIn,fs)
my code run normaly,
but if i put this:
[idx,treshold] = detectSpeech(audioIn,fs,'Window',win,'OverlapLength',overlap,'MergeDistance',mergeDist);
give me an error.
Hi Felipe,can you please share the full code as it is showing error at line 88 in gather function which is difficult to debug or reproduce from the provided code snippet as it is incomplete .Thanks.
audioread is basic MATLAB, and does not require Signal Processing Toolbox.
The Signal Processing Toolbox has little to do with reading or writing audio signals from devices or files.
The toolboxes that come to mind that deal with reading or writing audio signals include:
  • Audio System Toolbox
  • Computer Vision Toolbox (it deals with multimedia files)
  • DSP Toolbox
  • Simulink has some audio blocks
It would also be common for people to talk to audio devices using Data Acquisition Toolbox, and potentially Instrument Control Toolbox; also potentially Arduino or Raspberry Pi support packages.
But those are all irrelevant to audioread() which is basic MATLAB.
@Harsh Kumar I only use this code, i don't know why give me an error in "gather function". I not invoque in any moment this function.
Thanks.

Sign in to comment.

When I run it on my computer, it says
'detectSpeech' requires Audio Toolbox.
Error in test1 (line 17)
detectSpeech(audioIn,fs,"Window",win,"OverlapLength",overlap,"MergeDistance",mergeDist)
so you need the "Audio Toolbox". The online version of MATLAB will have that toolbox while your local computer installation does not. Use the Add-ons button on the Home tab of the tool ribbon to get that toolbox.

2 Comments

OK, but you're calling it with more than the number of input arguments it expects. Check the documentation.

Sign in to comment.

Categories

Community Treasure Hunt

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

Start Hunting!