Sound processing dividing words

Good day, I'm audioreading a audio file with words said seperately, I.G, "One, two, three, four, five, six" till twenty. I plotted it and used the movemax() function to obtain a better idea of where the words start and end. The problem however is, to determine the starting point and ending point of each word. Everything I've tried fails and it's this task is due for tommorrow. Some of the words such as "six-teen" has two syllables and shouldn't have 2 start and ending points. This is what I have:
You can see the later words have 2 syllables and this is what makes most my ideas fail. I want to then use these startpoints and endpoints to plot word alone. (I've already made this function). Help would be extremely appreciated!! I really don't have much time left for this project and still have many others.

 Risposta accettata

You can do this easily for well separated words (that have silence between them) by thresholding.
mask = y > 0.01; % Whatever. It's a word if the amplitude is higher than 0.01
% Don't include "words" less than 5 elements long (or whatever you want);
mask = bwareaopen(mask, 5);
% Label each word with a unique identifying number ("label").
[labeledSignal, numWords] = bwlabel(mask);
% Extract each word
for k = 1 : numWords
indexes = ismember(labeledSignal, k)
thisWord = y(indexes);
% Do whatever you want with thisWord.
end

6 Commenti

I'm trying this, but it gives an error: The logical indices contain a true value outside of the array bounds.
My function is:
mask = sentence > 0.0077;
mask = bwareaopen(mask, 5);
[labeledSignal, numWords]=bwlabel(mask);
for k=1:count
indexes=ismember(labeledSignal,k);
thisWord=y(indexes);
end
It gives the error on line "tisWord=y(indexes).
Image Analyst
Image Analyst il 13 Set 2021
Modificato: Image Analyst il 13 Set 2021
That was not my code. I used
for k = 1 : numWords
not
for k = 1 : count
Please attach your signal in a mat or txt file if you want us to work with it.
If you use sentence instead of y, you'll have to use
thisWord = sentence(indexes);
This is my array used to plot what was in the original question.
Leon:
Here's a start. I didn't do all your homework for you since I'm sure your professor want your solution, not mine.
% Demo by Image Analyst
clc; % Clear the command window.
close all; % Close all figures (except those of imtool.)
clear; % Erase all existing variables. Or clearvars if you want.
workspace; % Make sure the workspace panel is showing.
format long g;
format compact;
fontSize = 20;
s = load('sentence.mat')
y = s.sentence;
subplot(2, 1, 1);
plot(y, 'b-');
grid on;
% Adjust threshold as necessary.
threshold = 0.003;
yline(threshold, 'color', 'r');
mask = y > threshold; % Whatever. It's a word if the amplitude is higher than 0.01
% Get length of each word in number of elements.
props = regionprops(mask, 'Area');
allWordLengths = [props.Area]
% Get length of each silent part in number of elements.
% You'll need this to join two syllable words together into a single word.
props = regionprops(~mask, 'Area');
allSilentLengths = [props.Area]
% Don't include "words" less than 5 elements long (or whatever you want);
mask = bwareaopen(mask, 500);
subplot(2, 1, 2);
plot(mask, 'b-');
grid on;
% Get length of each word in number of elements.
props = regionprops(mask, 'Area');
allLengths = [props.Area]
% Label each word with a unique identifying number ("label").
[labeledSignal, numWords] = bwlabel(mask);
r = ceil(sqrt(numWords));
figure;
% Extract each word
for k = 1 : numWords
indexes = ismember(labeledSignal, k);
thisWord = y(indexes);
% Plot this word.
subplot(r, r, k);
plot(thisWord, 'b-');
caption = sprintf('Word #%d of %d', k, numWords);
title(caption);
drawnow;
% Do whatever you want with thisWord.
end
Each word is plotted. For you to do, join each two syllable word into a single word based on the length of the silent part between the words.
I cannot thank you enough, I had to just change the elements used to determine words with 1 syllable and 2. This was a great solution and work perfectly! I will change it up quite a bit but the concept will stay the same. Thank you very very much!
My impression is that this is a homework assignment:
Everything I've tried fails and it's this task is due for tommorrow.
I really don't have much time left for this project and still have many others.
I decided to propose a solution to the problem of separating the words, since a complete solution would not be in the long-term best interests of the OP, and leave the rest. I’ve deleted my Answer.
.

Accedi per commentare.

Più risposte (0)

Categorie

Prodotti

Release

R2020a

Community Treasure Hunt

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

Start Hunting!

Translated by