Index in position 2 is invalid. Array indices must be positive integers or logical values.

2 次查看(过去 30 天)
I have a problem. I want to do a speech command recognition,
This error occurs when I try to make spectograms with my own data. I don't know what format this voice data should be. I recorded them using audacity and exported them as: Mono, 32-bit folat with a frequency of 16000 HZ each 'yes' is 1 length one second. I don't know where to change or what format the recording should be to load it. I don't know if this is a mistake in the code or badly saved sound files.
Index in position 2 is invalid. Array indices must be positive integers or logical values.
Error in speechSpectrograms (line 41)
X(:,ind,1,i) = spec;
The attachment added is the code from speechSpectrograms
  5 个评论

请先登录,再进行评论。

回答(1 个)

Guillaume
Guillaume 2019-12-18
The error message is clear, the index in position two is invalid because it contains either non-integer values or values less than one.
The index in position two is the ind variable, so look inside that variable and see what the values are. They're going to be integer due to the way you construct ind, but if left is 0 or negative, then some ind values will indeed be invalid.
You can then work backward throught the code to find why left is less than 1. Without any of your inputs it's not something we can answer. Possible reason at first glance is that size(spec, 2) is greater than numHops.
By the way, isn't spec a vector? In which case, numel(spec) would be simpler and safer than size(spec, 2).

类别

Help CenterFile Exchange 中查找有关 Speech Recognition 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by