Creating a database of analysed audio filesΒΆ

Database objects are used to group audio files and their analyses into a single object in order to perform further operations (such as matching).

In [1]:
from sppysound.database import AudioDatabase
import analysis_config

Specify the directory to search recursively for audio files in.

In [2]:
file_dir = "./ExampleFiles"

Specify the directory to generate the database in.

In [3]:
database_dir = "./ExampleDatabase"

Create a list of analysis trings that determine the descriptors to be generated by the object

In [4]:
analysis_list = ["rms", "f0"]
In [5]:
database = AudioDatabase(
    file_dir,
    database_dir,
    analysis_list=analysis_list,
    config=analysis_config
)

The load_database method will search for any pre-existing analyses and load these, aswell as generating new analyses that aren’t already present. These will be organized and stored in the database directory in “data” and “audio” sub-directories.

In [6]:
database.load_database(reanalyse=True)

Once analysed, the database object can be used with objects such as the matcher object it’s entries to other databases.

A “config.py” file is required to be used as a configuration module for the database. This will contain configurations for initialising audio files contained in the database. The example config.py looks like this:

rms = {
    "window_size": 100,
    "overlap": 2,
}

analysis_dict = {
    "f0": "log2_median",
    "rms": "mean"
}

analysis = {
    "reanalyse": False
}

output_file = {
    "samplerate": 44100,
    "format": 131075,
    "channels": 1
}