Audio Analysis¶
soundscapy.audio.audio_analysis
¶
Audio analysis module for psychoacoustic analysis of audio files.
This module provides functionality for analyzing audio files using psychoacoustic metrics. It includes the AudioAnalysis class for processing single files or entire folders.
| CLASS | DESCRIPTION |
|---|---|
AudioAnalysis |
A class for performing psychoacoustic analysis on audio files. |
AudioAnalysis
¶
A class for performing psychoacoustic analysis on audio files.
This class provides methods to analyze single audio files or entire folders of audio files using parallel processing. It handles configuration management, calibration, and saving of analysis results.
| ATTRIBUTE | DESCRIPTION |
|---|---|
config_manager |
Manages the configuration settings for audio analysis
TYPE:
|
settings |
The current configuration settings
TYPE:
|
| METHOD | DESCRIPTION |
|---|---|
analyze_file |
Analyze a single audio file |
analyze_folder |
Analyze all audio files in a folder using parallel processing |
save_results |
Save analysis results to a file |
update_config |
Update the current configuration |
save_config |
Save the current configuration to a file |
Initialize the AudioAnalysis with a configuration.
| PARAMETER | DESCRIPTION |
|---|---|
config_path
|
Path to the configuration file. If None, uses default configuration. |
Source code in src/soundscapy/audio/audio_analysis.py
analyze_file
¶
analyze_file(
file_path: str | Path,
calibration_levels: dict[str, float]
| list[float]
| None = None,
resample: int | None = None,
) -> pd.DataFrame
Analyze a single audio file using the current configuration.
| PARAMETER | DESCRIPTION |
|---|---|
file_path
|
Path to the audio file to analyze. |
calibration_levels
|
Dictionary containing calibration levels for left and right channels. |
resample
|
Sampling rate to resample the audio to before analysis.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
DataFrame
|
DataFrame containing the analysis results. |
Source code in src/soundscapy/audio/audio_analysis.py
analyze_folder
¶
analyze_folder(
folder_path: str | Path,
calibration_file: str | Path | None = None,
max_workers: int | None = None,
resample: int | None = None,
) -> pd.DataFrame
Analyze all audio files in a folder using parallel processing.
| PARAMETER | DESCRIPTION |
|---|---|
folder_path
|
Path to the folder containing audio files. |
calibration_file
|
Path to a JSON file containing calibration levels for each audio file. |
max_workers
|
Maximum number of worker processes to use. If None, it will use the number of CPU cores.
TYPE:
|
resample
|
Sampling rate to resample the audio to before analysis.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
DataFrame
|
DataFrame containing the analysis results for all files. |
Source code in src/soundscapy/audio/audio_analysis.py
save_results
¶
Save analysis results to a file.
| PARAMETER | DESCRIPTION |
|---|---|
results
|
DataFrame containing the analysis results.
TYPE:
|
output_path
|
Path to save the results file. |
Source code in src/soundscapy/audio/audio_analysis.py
update_config
¶
Update the current configuration.
| PARAMETER | DESCRIPTION |
|---|---|
new_config
|
Dictionary containing the new configuration settings.
TYPE:
|
Source code in src/soundscapy/audio/audio_analysis.py
save_config
¶
Save the current configuration to a file.
| PARAMETER | DESCRIPTION |
|---|---|
config_path
|
Path to save the configuration file. |