How to make a matrix of data to put into gmdistribution from seperate sound files?
1 次查看(过去 30 天)
显示 更早的评论
I'm trying to use the gmdistribution.fit function for a speech recognition program that will take in a sound file of a speaker saying different numbers and turn it into a text file. The function requires me to input a matrix of sound data into one variable, which it then uses to predict the gmm parameters. I have 10 sound files for each digit that I probably need to combine into one variable for the function--how would I go about doing that?
0 个评论
采纳的回答
Kris Fedorenko
2017-8-7
Hi Jonathan!
You should be able to read in your audio files in MATLAB using "audioread". This will give you the audio data (m-by-n matrix, where m is the length of the audio and n is the number of audio channels) and the sample rate. You can refer to the following documentation for more details:
Now for "gmdistribution.fit" you need to input data as an n-by-d matrix, where n is the number of observations and d is the dimension of the data. Assuming that you would like to use the audio data as input to "gmdistribution.fit" and that your audio files have only one channel and are of the same length, you can construct the input using a workflow similar to this:
%%read in audio files
[data1, Fs] = audioread('audiofile1.wav');
[data2, Fs] = audioread('audiofile2.wav');
%%make an input matrix
input_matrix = [data1 data2]; % concatenate audio data
% rotate the input matrix such that first dimension is number of
% observations and second is number of dimensions:
input_matrix = input_matrix';
%%use input matrix as input to "gmdistribution.fit"
obj = gmdistribution.fit(input_matrix, number_of_components);
Note that input to "gmdistribution.fit" should have more rows than columns (i.e. more observations than number of dimensions). Depending on the length of your audio files, their number might not be enough to use a Gaussian mixture model.
Hope this helps!
Kris
0 个评论
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Measurements and Spatial Audio 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!