File size: 628 Bytes
5397a6e
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
import os

def get_audio_files_from_directory(directory, extensions=[".wav", ".mp3"]):
    """
    Retrieves all audio files from a specified directory.
    
    Parameters:
        directory (str): The directory to search for audio files.
        extensions (list): List of valid audio file extensions.
    
    Returns:
        audio_files (list): List of paths to audio files.
    """
    audio_files = []
    for root, _, files in os.walk(directory):
        for file in files:
            if any(file.endswith(ext) for ext in extensions):
                audio_files.append(os.path.join(root, file))
    return audio_files