Azzera filtri
Azzera filtri

Feature Extraction in Time-Frequency Domain - Audio Classification

3 visualizzazioni (ultimi 30 giorni)
Hi, I'm fairly new to MATLAB, really appreciate if I can get some help here.
I'm doing a project on audio classification, where I have loaded labelled audio datasets into MATLAB. I am currently encountering an issue where I want to apply discrete wavelet transform on all the signals in the datasets and convert them to images, subsequently saving them in a folder according to their labels. The images will then be fed into a neural network for classification learning.
I am trying to replicate another projet where they created a function to automatically convert CWT coefficients into images but I'm having no luck trying to make it work for DWT.
Thanks in advance for helping, and if I'm missing out any details please let me know.
my code:
The function code for CWT

Risposte (1)

Yash Sharma
Yash Sharma il 2 Mag 2024
To convert audio signals to Discrete Wavelet Transform (DWT) images and save them according to their labels, you can modify the function you provided for CWT. Below is a concise guide and a modified function tailored for DWT.
Modified Function for DWT
This function, helperCreateImagesFromDWT, processes audio files, applies DWT, and saves the coefficients as images in labeled folders.
function helperCreateImagesFromDWT(ads, outputFolder)
for i = 1:length(ads.Files)
[audioIn, info] = audioread(ads.Files{i}); % Read audio file
[cA, cD] = dwt(audioIn, 'db1'); % Apply DWT with 'db1' wavelet
% Process and normalize coefficients
coeffs = [cA; cD];
coeffsNorm = (coeffs - min(coeffs)) / (max(coeffs) - min(coeffs));
img = im2uint8(mat2gray(coeffsNorm)); % Convert to image
% Prepare image file path
label = char(ads.Labels(i));
imgFileName = strcat(label, '_', num2str(i), '.png');
imgFolderPath = fullfile(outputFolder, label);
if ~exist(imgFolderPath, 'dir'), mkdir(imgFolderPath); end % Ensure folder exists
imwrite(imresize(img, [224, 224]), fullfile(imgFolderPath, imgFileName)); % Save image
end
end
Applying the Function
  1. Set Up the Output Folder: Change datafolder_scallogram to a new folder name that reflects you're working with DWT images, for example, datafolder_dwtImages.
  2. Call the Function: Replace the call to helperCreateRGBfromTF in your script with helperCreateImagesFromDWT, passing the audio datastore and the new output folder path.
datafolder_dwtImages = "C:\Users\leere\Documents\MATLAB\DWT_Images"; % New folder for DWT images
helperCreateImagesFromDWT(ads, datafolder_dwtImages); % Process and save DWT images
This approach applies DWT to your audio signals, normalizes and processes the coefficients to create images, and organizes these images in folders based on their labels, ready for neural network classification.

Categorie

Scopri di più su AI for Signals and Images in Help Center e File Exchange

Prodotti

Community Treasure Hunt

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

Start Hunting!

Translated by