- The parameters in audioFeatureExtractor, such as -- on one hand, the output of the feature extraction algorithm (e.g. NumBands), on the other, the buffering parameters (in this case Window and OverlapLength)
- The length of the actual input waveform segment
Incorrect input size. The input images must have a size of [98 50 1].
6 ビュー (過去 30 日間)
I am trying to voice command recognisation in audio toolbox
but i upload any coustom audio file i get Error"Incorrect input size. The input images must have a size of [98 50 1].".
Please can you guide
%% Speech Command Recognition Using Deep Learning
% This example shows how to train a deep learning model that detects the
% presence of speech commands in audio. The example uses the Speech
% Commands Dataset  to train a convolutional neural network to recognize
% a given set of commands.
% To train a network from scratch, you must first download the data set. If
% you do not want to download the data set or train the network, then you
% can load a pretrained network provided with this example and execute the
% next two sections of the example: _Recognize Commands with a Pre-Trained
% Network_ and _Detect Commands Using Streaming Audio from Microphone_.
%% Recognize Commands with a Pre-Trained Network
% Before going into the training process in detail, you will use a
% pre-trained speech recognition network to identify speech commands.
% Load the pre-trained network.
% The network is trained to recognize the following speech commands:
% * "yes"
% * "no"
% * "up"
% * "down"
% * "left"
% * "right"
% * "on"
% * "off"
% * "stop"
% * "go"
% Load a short speech signal where a person says "stop".
[x,fs] = audioread('audio.flac');
% Listen to the command.
% The pre-trained network takes auditory-based spectrograms as inputs. You
% will first convert the speech waveform to an auditory-based spectrogram.
% Use the function |extractAuditoryFeature| to compute the auditory
% spectrogram. You will go through the details of feature extraction later
% in the example.
auditorySpect = helperExtractAuditoryFeatures(x,fs);
% Classify the command based on its auditory spectrogram.
command = classify(trainedNet,auditorySpect)
回答 (1 件)
Gabriele Bunkheila 2021 年 5 月 24 日
Hi Cristina, I understand you are now sorted but I am including some more info below in case it can help others.
The network needs to see exactly the same type of input format it was trained with. In particular, the size of the input depends on:
In this example, you honored correctly (1) but not (2). This pre-trained network requires all waveform segments to all be of 1s in length (=16000 samples at a sample rate of 16 kHz). However, this test segment stop_command.flac only includes 12800 samples. The most common approach is to simply pad this with zeros after the end, as in the fourth line of code below:
[stopCmd, fs] = audioread('stop_command.flac');
len = 1; % in seconds
N = len*fs;
stopCmdIn = [stopCmd(:,1); zeros(N-size(stopCmd,1),1,'like',stopCmd)];
afe = audioFeatureExtractor( ...
features = extract(afe, stopCmdIn);
Better padding approaches tend to distribute zeros across both start and end, as in the function helperExtractAuditoryFeatures.m (lines 37-46) coming with the example Speech Command Recognition Using Deep Learning. To open that, execute the following in your local MATLAB installation: