Error in enhanceSpeech for audio enhancement
Show older comments
I am using enhanceSpeech (https://www.mathworks.com/help/audio/ref/enhancespeech.html) to proceed an audio file and encountered the following problem.
Index in position 1 exceeds array bounds. Index must not exceed 256384.
Error in audio.ai.metricgan.postprocess (line 39)
audioOut = audioOut(1:size(audioIn,1),1);
Error in enhanceSpeech (line 58)
audioOut = audio.ai.metricgan.postprocess(audioIn,fs,reconstructionPhase,netOutput,win);
I looked at the signal. It has certain noise in the very beginning.

I think this is the major reason because if I run:
enhancedSpeech = enhanceSpeech(noisySpeech(3000:end),fs);
there is no error. But if I run:
enhancedSpeech = enhanceSpeech(noisySpeech(2900:end),fs);
there will errors as shown above.
2 Comments
Wuxian HE
on 27 Aug 2024
MathWorks Audio Toolbox Team
on 27 Aug 2024
Edited: MathWorks Audio Toolbox Team
on 27 Aug 2024
Thank you for bringing this to our attention. This is indeed a bug and will be fixed shortly.
The underlying model operates on an STFT of 16 kHz audio data. This means we are resampling under-the-hood and padding to multiples of the hop length of the STFT. I believe the issue you encountered is due to a bug in the calculation of the padding happening before resampling. Another option to get around this issue without touching the source code is to resample to 16 kHz outside of the function.
[noisySpeech,fs] = audioread('yourfile');
a = audioresample(noisySpeech,InputRate=fs,OutputRate=16e3)
b = enhanceSpeech(a,16e3)
c = audioresample(b,InputRate=16e3,OutputRate=fs)
Answers (0)
Categories
Find more on Multirate Signal Processing 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!