### Install FFmpeg on Google Colab Source: https://github.com/hunterhogan/analyzeaudio/blob/main/README.md This snippet verifies the installation of FFmpeg on Google Colab. Ensure FFmpeg and FFprobe binaries are in your PATH. ```python from analyzeAudio.ffmpeg import verifyFFmpegColab verifyFFmpegColab() ``` -------------------------------- ### Example Usage of analyzeSpectralFlatness Source: https://github.com/hunterhogan/analyzeaudio/blob/main/_autodocs/api-reference/analyzersUseSpectrogram.md Demonstrates how to use the analyzeSpectralFlatness function and compute the mean of the resulting spectral flatness values. ```python from analyzeAudio.analyzersUseSpectrogram import analyzeSpectralFlatness spectral_flatness_db = analyzeSpectralFlatness(spectrogram_magnitude) sf_mean = spectral_flatness_db.mean() ``` -------------------------------- ### Set Multiprocessing Spawn Method Source: https://github.com/hunterhogan/analyzeaudio/blob/main/_autodocs/configuration.md Ensure consistent multiprocessing behavior across platforms by setting the start method to 'spawn' if it hasn't been configured already. This is handled by the audioAspectsRegistry module. ```python from multiprocessing import set_start_method import contextlib with contextlib.suppress(RuntimeError): set_start_method('spawn') ``` -------------------------------- ### List Available Audio Aspects and Contests Source: https://github.com/hunterhogan/analyzeaudio/blob/main/README.md Use these Python functions to retrieve lists of available audio aspects and contests from the installed package. Ensure the analyzeAudio package is installed. ```python from analyzeAudio import getListAvailableAudioAspects, getListAvailableAudioContests print(getListAvailableAudioAspects()) print(getListAvailableAudioContests()) ``` -------------------------------- ### Command-Line Interface for Audio Aspects and Contests Source: https://github.com/hunterhogan/analyzeaudio/blob/main/README.md These are the corresponding terminal commands to list available audio aspects and contests. These commands are available if the package is installed and configured in your system's PATH. ```powershell whatAspects whatContests ``` -------------------------------- ### File Format Example: Delimited Text Output Source: https://github.com/hunterhogan/analyzeaudio/blob/main/_autodocs/api-reference/misfit.md Illustrates the structure of the output file generated by dataTabularTOpathFilenameDelimited, showing header and data rows separated by a tab delimiter. ```text pathFilename LUFS integrated Spectral Flatness mean /path/to/track1.wav -23.5 0.12 /path/to/track2.wav -21.2 0.15 ``` -------------------------------- ### Python Example: Writing Tabular Data to Delimited Files Source: https://github.com/hunterhogan/analyzeaudio/blob/main/_autodocs/api-reference/misfit.md Demonstrates how to use dataTabularTOpathFilenameDelimited to write analysis results to TSV, CSV, and a file without a header. Ensure necessary imports are present. ```python from analyzeAudio import analyzeAudioListPathFilenames, dataTabularTOpathFilenameDelimited audio_files = ['/path/to/track1.wav', '/path/to/track2.wav'] aspects = ['LUFS integrated', 'Spectral Flatness mean'] rows = analyzeAudioListPathFilenames(audio_files, aspects) # Write as TSV (default) dataTabularTOpathFilenameDelimited( 'results.tsv', rows, ['pathFilename', *aspects] ) # Write as CSV dataTabularTOpathFilenameDelimited( 'results.csv', rows, ['pathFilename', *aspects], delimiterOutput=',' ) # No header dataTabularTOpathFilenameDelimited( 'results_no_header.txt', rows, tableColumns=None # Suppresses header ) ``` -------------------------------- ### Get List of Available Audio Aspects Source: https://github.com/hunterhogan/analyzeaudio/blob/main/_autodocs/aspects-registry.md Retrieve a sorted list of all available audio analysis aspects at runtime. This is useful for understanding the full scope of metrics provided by the library. ```python from analyzeAudio import getListAvailableAudioAspects all_aspects = getListAvailableAudioAspects() print(sorted(all_aspects)) ``` -------------------------------- ### Get Detailed Per-Frame Arrays Source: https://github.com/hunterhogan/analyzeaudio/blob/main/README.md Retrieve detailed, per-frame analysis results for specific audio aspects. This is useful for analyzing dynamic changes over time, as opposed to overall summary values. ```python from analyzeAudio.analyzersUseFilename import ( analyzeLUFSIntegratedOverall, analyzeLUFSMomentary, ) integrated = analyzeLUFSIntegratedOverall("voice.wav") momentaryFrames = analyzeLUFSMomentary("voice.wav") ``` -------------------------------- ### Get Mean Signal-to-Distortion Ratio Source: https://github.com/hunterhogan/analyzeaudio/blob/main/_autodocs/api-reference/analyzersUseFilename.md Computes the mean signal-to-distortion ratio between two audio files. This metric is useful for evaluating audio processing effects. ```python def getSDRmean( pathFilenameAlfa: str | PathLike[Any], pathFilenameBeta: str | PathLike[Any] ) -> float | None: pass ``` -------------------------------- ### Initialize Analyzer Registry Source: https://github.com/hunterhogan/analyzeaudio/blob/main/_autodocs/configuration.md The audioAspects registry is automatically populated when analyzer sub-modules are imported. This snippet shows how to access the registry and list available aspects. ```python from analyzeAudio import ( audioAspects, getListAvailableAudioAspects, analyzeAudioFile ) # Registry is now populated available_aspects = getListAvailableAudioAspects() ``` -------------------------------- ### Analyze Integrated Loudness (LUFS) Source: https://github.com/hunterhogan/analyzeaudio/blob/main/_autodocs/api-reference/analyzersUseFilename.md Computes the integrated programme loudness of an audio file. Use this function to get the overall loudness of an audio file in LUFS. ```python from analyzeAudio import analyzeAudioFile result = analyzeAudioFile('audio.wav', ['LUFS integrated']) # Returns something like [-23.5] ``` -------------------------------- ### Analyze Tensor-Based Metrics (Single File) Source: https://github.com/hunterhogan/analyzeaudio/blob/main/_autodocs/api-overview.md Compute audio quality metrics on PyTorch tensors for a single audio file. Requires the audio tensor, sample rate, and an optional flag for CPU usage. ```python def analyzer(tensorAudio: torch.Tensor, sampleRate: int, pytorchOnCPU: bool | None, **kwargs) -> float ``` -------------------------------- ### Measure Multiple Audio Files from Path Source: https://github.com/hunterhogan/analyzeaudio/blob/main/README.md Analyze multiple WAV files from a specified directory. Results are returned as rows, with each row containing the filename and its measurements. Rows are returned as files finish processing. ```python from pathlib import Path from analyzeAudio import analyzeAudioListPathFilenames listPathFilenames = tuple(Path("audio").glob("*.wav")) listAspectNames = [ "LUFS integrated", "LUFS loudness range", "true_peak maximum", ] rows = analyzeAudioListPathFilenames( listPathFilenames, listAspectNames, CPUlimit=4, ) for row in rows: print(row) ``` -------------------------------- ### Analyze Tensor-Based Metrics (Comparison) Source: https://github.com/hunterhogan/analyzeaudio/blob/main/_autodocs/api-overview.md Compute audio quality metrics on PyTorch tensors for comparing two or three audio files. These functions take the respective audio tensors as input. ```python def analyzer(tensorAudioAlfa: torch.Tensor, tensorAudioBeta: torch.Tensor, **kwargs) -> float def analyzer(tensorAudioAlfa: torch.Tensor, tensorAudioBeta: torch.Tensor, tensorAudioGamma: torch.Tensor, sampleRate: int, **kwargs) -> float ``` -------------------------------- ### Accessing Audio Aspects Registry Source: https://github.com/hunterhogan/analyzeaudio/blob/main/_autodocs/api-reference/audioAspectsRegistry.md Demonstrates how to access metadata for a registered audio aspect from the 'audioAspects' registry. Shows how to retrieve the analyzer function and its parameter names, and how to call an analyzer directly if needed. ```python from analyzeAudio import audioAspects # Get metadata for a registered aspect metadata = audioAspects['LUFS integrated'] analyzer_func = metadata['analyzer'] param_names = metadata['analyzerParameters'] # Call an analyzer directly if it needs more than pathFilename # Example: SI-SDR compares two files si_sdr_analyzer = audioAspects['SI-SDR mean']['analyzer'] result = si_sdr_analyzer(path_file1, path_file2) ``` -------------------------------- ### AnalyzeAudio API Parameter Mapping Source: https://github.com/hunterhogan/analyzeaudio/blob/main/_autodocs/api-overview.md Illustrates how `analyzeAudioFile` maps local variables to analyzer parameters. Analyzers expect parameters to be named from a fixed set of local variables available within the function. ```text Local variables (inside analyzeAudioFile): - pathFilename (from argument) - waveform (computed from audio file) - sampleRate (computed from audio file) - spectrogram (computed from waveform) - spectrogramMagnitude (from spectrogram) - spectrogramPower (from spectrogram) - tensorAudio (from waveform) - pytorchOnCPU (computed from torch.cuda.is_available()) ``` -------------------------------- ### Get Mean Scale-Invariant Signal-to-Distortion Ratio Source: https://github.com/hunterhogan/analyzeaudio/blob/main/_autodocs/api-reference/analyzersUseFilename.md Computes the mean scale-invariant signal-to-distortion ratio between two audio files. This is useful for comparing audio with different amplitudes, as it is forgiving of scaling factors. ```python from analyzeAudio import audioAspects si_sdr_analyzer = audioAspects['SI-SDR mean']['analyzer'] score = si_sdr_analyzer('reference.wav', 'processed.wav') ``` -------------------------------- ### analyzeTempoMean Source: https://github.com/hunterhogan/analyzeaudio/blob/main/_autodocs/INDEX.md Analyzes the tempo of an audio signal using Librosa, returning the mean tempo. ```APIDOC ## analyzeTempoMean analyzeTempoMean() ### Description Analyzes the tempo of an audio signal using Librosa, returning the mean tempo. ### Method Not applicable (SDK function) ### Endpoint Not applicable (SDK function) ### Parameters Parameters are detailed in the source documentation, including input types and mathematical descriptions. ### Request Example ```python # Example usage (assuming analyzeTempoMean is imported) # mean_tempo = analyzeTempoMean() ``` ### Response #### Success Response - Returns the mean tempo as a scalar value. #### Response Example ```json 120.5 ``` ``` -------------------------------- ### Get Mean Peak Signal-to-Noise Ratio Source: https://github.com/hunterhogan/analyzeaudio/blob/main/_autodocs/api-reference/analyzersUseFilename.md Computes the mean peak signal-to-noise ratio between two audio files. Use this to compare the quality of an original audio file against a processed version. ```python from analyzeAudio import audioAspects psnr_analyzer = audioAspects['Peak Signal-to-Noise Ratio mean']['analyzer'] result = psnr_analyzer('/path/to/original.wav', '/path/to/processed.wav') ``` -------------------------------- ### Get List of Available Audio Aspects Source: https://github.com/hunterhogan/analyzeaudio/blob/main/_autodocs/api-reference/audioAspectsRegistry.md Retrieves a sorted list of all registered audio aspect names from the 'audioAspects' registry. This list can be used to iterate through available metrics or as input for other analysis functions. ```python from analyzeAudio import getListAvailableAudioAspects available = getListAvailableAudioAspects() print(available) # Output: # ['Crest factor', 'Chromagram mean', 'DC offset', ...] # Use in downstream tools for aspect_name in available: print(f"Available metric: {aspect_name}") ``` -------------------------------- ### Configure SRMR computation with torchmetrics parameters Source: https://github.com/hunterhogan/analyzeaudio/blob/main/_autodocs/configuration.md The analyzeSRMR and analyzeSRMRMean functions allow configuration of the Short-time Reverberation Modulation Energy (SRMR) metric using parameters from torchmetrics. ```python from analyzeAudio.analyzersUseTensor import analyzeSRMRMean # Configure SRMR computation srmr_score = analyzeSRMRMean( tensorAudio, sampleRate=16000, pytorchOnCPU=True, n_cochlear_filters=23, low_freq=125.0, fast=True ) ``` -------------------------------- ### Analyze Mel-Scaled dB Mean Source: https://github.com/hunterhogan/analyzeaudio/blob/main/README.md Use `analyzeBleedFullMelDBMean` to get two scores, 'bleed' and 'full', representing differences in mel-scaled dB content between two spectrograms. Ensure `spectrogramMagnitudeReference` and `spectrogramMagnitudeEstimate` are defined beforehand. ```python from analyzeAudio.contestsSpectrogram import analyzeBleedFullMelDBMean bleedFull = analyzeBleedFullMelDBMean( spectrogramMagnitudeReference, spectrogramMagnitudeEstimate, ) print(bleedFull.bleed, bleedFull.full) ``` -------------------------------- ### Compare Audio Files Using Filename Source: https://github.com/hunterhogan/analyzeaudio/blob/main/README.md Use these functions to compare two audio files based on their filenames. They calculate metrics like PSNR and SDR. ```python from analyzeAudio.analyzersUseFilename import ( analyzePSNRmean, analyzeSDRmean, analyzeSI_SDRmean, ) pathReference = "reference.wav" pathEstimate = "estimate.wav" psnr = analyzePSNRmean(pathReference, pathEstimate) sdr = analyzeSDRmean(pathReference, pathEstimate) si_sdr = analyzeSI_SDRmean(pathReference, pathEstimate) ``` -------------------------------- ### Single File Analysis with Multiple Metrics Source: https://github.com/hunterhogan/analyzeaudio/blob/main/_autodocs/api-overview.md Perform analysis on a single audio file for multiple specified metrics and store the results in a dictionary. ```python from analyzeAudio import analyzeAudioFile metrics = ['LUFS integrated', 'RMS peak', 'Spectral Flatness mean', 'SRMR mean'] results = analyzeAudioFile('myaudio.wav', metrics) result_dict = dict(zip(metrics, results, strict=True)) print(f"Loudness: {result_dict['LUFS integrated']} LUFS") print(f"Peak RMS: {result_dict['RMS peak']} dB") ``` -------------------------------- ### Configure LogWMSE computation with frequency weighting Source: https://github.com/hunterhogan/analyzeaudio/blob/main/_autodocs/configuration.md The analyzeLogWMSEMean function allows customization of frequency weighting for LogWMSE calculations, including options to bypass filtering. ```python from analyzeAudio.analyzersUseTensor import analyzeLogWMSEMean logwmse = analyzeLogWMSEMean( reference, estimate, mixture, sampleRate=44100, bypass_filter=False, reduction='mean' ) ``` -------------------------------- ### Custom Comparative Analysis Source: https://github.com/hunterhogan/analyzeaudio/blob/main/_autodocs/api-overview.md Perform custom comparative analysis between two audio files using a specific analyzer, such as SI-SDR mean. This allows for targeted evaluation of audio processing. ```python from analyzeAudio import audioAspects # Get the SI-SDR analyzer si_sdr_analyzer = audioAspects['SI-SDR mean']['analyzer'] # Compare two files score = si_sdr_analyzer('reference.wav', 'processed.wav') print(f"SI-SDR: {score} dB") ``` -------------------------------- ### _formatTensorAudioForBatchFirstLoss Source: https://github.com/hunterhogan/analyzeaudio/blob/main/_autodocs/api-reference/analyzersUseTensor.md Adds a batch axis (leading singleton dimension) to audio tensors, preparing them for loss calculations that expect batch-first input. It handles 1D, 2D, and 3D inputs by prepending a batch dimension. ```APIDOC ## _formatTensorAudioForBatchFirstLoss ### Description Adds a batch axis (leading singleton dimension) for batch-first tensor losses. - 1D, 2D, 3D inputs: prepends one singleton batch axis - 4D+ inputs: returned unchanged ### Parameters #### Path Parameters - **tensorAudio** (torch.Tensor) - Required - The input waveform tensor. ### Returns `torch.Tensor` — The tensor with a prepended batch dimension if applicable. ### Source `analyzeAudio/analyzersUseTensor.py` lines 188–217 ``` -------------------------------- ### Batch Analysis to CSV Source: https://github.com/hunterhogan/analyzeaudio/blob/main/_autodocs/api-overview.md Analyze multiple audio files in a folder for specified metrics and save the results to a CSV file. This workflow is suitable for processing large collections of audio. ```python from analyzeAudio import analyzeAudioListPathFilenames, dataTabularTOpathFilenameDelimited import pathlib audio_files = list(pathlib.Path('audio_folder').glob('*.wav')) metrics = ['LUFS integrated', 'RMS peak'] rows = analyzeAudioListPathFilenames(audio_files, metrics, CPUlimit=4) dataTabularTOpathFilenameDelimited( 'output.csv', rows, ['pathFilename', *metrics], delimiterOutput=',' ) ``` -------------------------------- ### analyzeLogWMSEMean Source: https://github.com/hunterhogan/analyzeaudio/blob/main/_autodocs/INDEX.md Calculates the mean Frequency-weighted Mean Squared Error (WMSE) for an audio signal using PyTorch-based metrics. ```APIDOC ## analyzeLogWMSEMean analyzeLogWMSEMean() ### Description Calculates the mean Frequency-weighted Mean Squared Error (WMSE) for an audio signal using PyTorch-based metrics. ### Method Not applicable (SDK function) ### Endpoint Not applicable (SDK function) ### Parameters Tensor input requirements and full signatures with keyword-only parameters are detailed in the source documentation. ### Request Example ```python # Example usage (assuming analyzeLogWMSEMean is imported) # mean_log_wmse = analyzeLogWMSEMean() ``` ### Response #### Success Response - Returns the mean log WMSE as a scalar value. #### Response Example ```json 0.05 ``` ``` -------------------------------- ### analyzeAudioListPathFilenames() Source: https://github.com/hunterhogan/analyzeaudio/blob/main/_autodocs/api-overview.md Analyzes multiple audio files in parallel. It accepts a list of file paths, a list of aspect names, and an optional CPU limit. It returns a list of lists, where each inner list contains the analysis results for a single file. ```APIDOC ## analyzeAudioListPathFilenames() ### Description Analyzes multiple audio files in parallel. It accepts a list of file paths, a list of aspect names, and an optional CPU limit. It returns a list of lists, where each inner list contains the analysis results for a single file. ### Function Signature `analyzeAudioListPathFilenames(listPathFilenames, listAspectNames, CPUlimit)` ### Parameters - **listPathFilenames** (list[str]): A list of paths to the audio files to analyze. - **listAspectNames** (list[str]): A list of names of the audio aspects to extract. - **CPUlimit** (int, optional): The maximum number of CPUs to use for parallel processing. ### Output - **list[list[str | float]]**: A list of lists, where each inner list contains the analysis results for a corresponding audio file. ``` -------------------------------- ### Analyze Multiple Audio Files in Parallel Source: https://github.com/hunterhogan/analyzeaudio/blob/main/_autodocs/api-reference/analyze.md Computes requested audio aspect values for multiple audio files concurrently using process workers. Specify the number of CPU cores to use with `CPUlimit`. Results are returned in completion order, not input order. ```python from analyzeAudio import analyzeAudioListPathFilenames, dataTabularTOpathFilenameDelimited import pathlib audio_files = [ '/path/to/track1.wav', '/path/to/track2.wav', '/path/to/track3.wav', ] aspects = ['LUFS integrated', 'Spectral Flatness mean'] rows = analyzeAudioListPathFilenames(audio_files, aspects, CPUlimit=4) # Each row is like: ['/path/to/track1.wav', -23.5, 0.12] # Write to CSV/TSV dataTabularTOpathFilenameDelimited( 'output.tsv', rows, ['pathFilename', *aspects], delimiterOutput='\t' ) ``` -------------------------------- ### Batch Analyze Audio Files and Save to CSV Source: https://github.com/hunterhogan/analyzeaudio/blob/main/_autodocs/README.md Analyzes multiple audio files in a directory for specified metrics and saves the results to a CSV file. Supports parallel processing up to a specified CPU limit. ```python from analyzeAudio import analyzeAudioListPathFilenames, dataTabularTOpathFilenameDelimited import pathlib files = list(pathlib.Path('audio').glob('*.wav')) metrics = ['LUFS integrated', 'Spectral Flatness mean'] rows = analyzeAudioListPathFilenames(files, metrics, CPUlimit=4) dataTabularTOpathFilenameDelimited('output.csv', rows, ['file', *metrics], ',') ``` -------------------------------- ### Compare Tensor Spectrograms Source: https://github.com/hunterhogan/analyzeaudio/blob/main/README.md Compare two PyTorch magnitude spectrogram tensors using spectral convergence and STFT magnitude loss functions. ```python from analyzeAudio.contestsTensorSpectrogram import ( analyzeSpectralConvergenceLoss, analyzeSTFTMagnitudeLoss, ) spectralConvergence = analyzeSpectralConvergenceLoss( tensorSpectrogramMagnitudeReference, tensorSpectrogramMagnitudeEstimate, ) stftMagnitude = analyzeSTFTMagnitudeLoss( tensorSpectrogramMagnitudeReference, tensorSpectrogramMagnitudeEstimate, ) ``` -------------------------------- ### analyzeSpectralContrastMean Source: https://github.com/hunterhogan/analyzeaudio/blob/main/_autodocs/INDEX.md Analyzes the spectral contrast of an audio signal using Librosa, returning the mean spectral contrast. ```APIDOC ## analyzeSpectralContrastMean analyzeSpectralContrastMean() ### Description Analyzes the spectral contrast of an audio signal using Librosa, returning the mean spectral contrast. ### Method Not applicable (SDK function) ### Endpoint Not applicable (SDK function) ### Parameters Spectrogram input types and full signatures are detailed in the source documentation. ### Request Example ```python # Example usage (assuming analyzeSpectralContrastMean is imported) # mean_spectral_contrast = analyzeSpectralContrastMean() ``` ### Response #### Success Response - Returns the mean spectral contrast as a numerical array. #### Response Example ```json [1.3, 1.4] ``` ``` -------------------------------- ### Analyze Multiple Audio Files in Parallel Source: https://github.com/hunterhogan/analyzeaudio/blob/main/_autodocs/api-overview.md Use `analyzeAudioListPathFilenames` to analyze multiple audio files concurrently. Specify the list of file paths, aspect names, and an optional CPU limit. Returns a list of lists, where each inner list contains the results for a file. ```python def analyzeAudioListPathFilenames(listPathFilenames: list[str], listAspectNames: list[str], CPUlimit: int | None) -> list[list[str | float]] ``` -------------------------------- ### Configure L1SNR computation Source: https://github.com/hunterhogan/analyzeaudio/blob/main/_autodocs/configuration.md The analyzeL1SNRMean function supports parameters from the torch_l1_snr library for calculating the L1 Signal-to-Noise Ratio. ```python from analyzeAudio.analyzersUseTensor import analyzeL1SNRMean l1snr = analyzeL1SNRMean( reference_tensor, estimate_tensor, weight=1.0, eps=1e-3, l1_weight=0.0 ) ``` -------------------------------- ### analyzeAudioFile() Source: https://github.com/hunterhogan/analyzeaudio/blob/main/_autodocs/api-overview.md Analyzes a single audio file to extract specified aspects. It takes the file path and a list of aspect names as input and returns a list of results, which can be strings or floats. ```APIDOC ## analyzeAudioFile() ### Description Analyzes a single audio file to extract specified aspects. It takes the file path and a list of aspect names as input and returns a list of results, which can be strings or floats. ### Function Signature `analyzeAudioFile(pathFilename, listAspectNames)` ### Parameters - **pathFilename** (str): The path to the audio file to analyze. - **listAspectNames** (list[str]): A list of names of the audio aspects to extract. ### Output - **list[str | float]**: A list containing the extracted audio aspects. The elements can be strings or floating-point numbers. ``` -------------------------------- ### Analyze Tempo from Waveform Source: https://github.com/hunterhogan/analyzeaudio/blob/main/_autodocs/api-reference/analyzersUseWaveform.md Estimates the tempo in beats per minute from waveform periodicity. Requires waveform data and its sample rate. Additional parameters can be passed to librosa.feature.tempo. ```python import numpy import soundfile from analyzeAudio.analyzersUseWaveform import analyzeTempo with soundfile.SoundFile('audio.wav') as f: sampleRate = f.samplerate waveform = f.read(dtype='float32').astype(numpy.float32).T tempo = analyzeTempo(waveform, sampleRate) ``` -------------------------------- ### analyzeSpectralContrast Source: https://github.com/hunterhogan/analyzeaudio/blob/main/_autodocs/INDEX.md Analyzes the spectral contrast of an audio signal using Librosa, returning the full spectral contrast matrix. ```APIDOC ## analyzeSpectralContrast analyzeSpectralContrast() ### Description Analyzes the spectral contrast of an audio signal using Librosa, returning the full spectral contrast matrix. ### Method Not applicable (SDK function) ### Endpoint Not applicable (SDK function) ### Parameters Spectrogram input types and full signatures are detailed in the source documentation. ### Request Example ```python # Example usage (assuming analyzeSpectralContrast is imported) # spectral_contrast_data = analyzeSpectralContrast() ``` ### Response #### Success Response - Returns the spectral contrast as a 2D numerical array. #### Response Example ```json [[1.2, 1.5], [1.1, 1.3], [1.4, 1.6]] ``` ``` -------------------------------- ### Analyze LogWMSE Mean with PyTorch Tensors Source: https://github.com/hunterhogan/analyzeaudio/blob/main/_autodocs/api-reference/analyzersUseTensor.md Scores an estimated audio tensor against a reference tensor using frequency-weighted mean squared error in log scale. Requires reference, estimated, and mixture audio tensors, along with the sample rate. Optional parameters allow for custom frequency weighting and reduction modes. ```python def analyzeLogWMSEMean( tensorAudioAlfa: torch.Tensor, tensorAudioBeta: torch.Tensor, tensorAudioGamma: torch.Tensor, sampleRate: int, **keywordArguments: Any ) -> float: # ... implementation details ... ``` -------------------------------- ### Access Available Audio Metrics Registry Source: https://github.com/hunterhogan/analyzeaudio/blob/main/_autodocs/README.md Retrieves a list of all available audio metrics registered within the analyzeAudio package. Useful for discovering supported metrics. ```python from analyzeAudio import getListAvailableAudioAspects all_aspects = getListAvailableAudioAspects() print(f"Available metrics: {len(all_aspects)}") ``` -------------------------------- ### analyzeTempo Source: https://github.com/hunterhogan/analyzeaudio/blob/main/_autodocs/INDEX.md Analyzes the tempo of an audio signal using Librosa, returning the full tempo time-series. ```APIDOC ## analyzeTempo analyzeTempo() ### Description Analyzes the tempo of an audio signal using Librosa, returning the full tempo time-series. ### Method Not applicable (SDK function) ### Endpoint Not applicable (SDK function) ### Parameters Parameters are detailed in the source documentation, including input types and mathematical descriptions. ### Request Example ```python # Example usage (assuming analyzeTempo is imported) # tempo_series = analyzeTempo() ``` ### Response #### Success Response - Returns the tempo time-series as a numerical array. #### Response Example ```json [120.0, 121.5, 119.0, 122.0] ``` ``` -------------------------------- ### Analyzer Function (File Comparison Metrics) Source: https://github.com/hunterhogan/analyzeaudio/blob/main/_autodocs/api-overview.md Compares two audio files using FFmpeg filters to calculate metrics like Peak SNR, SDR, and SI-SDR. It takes the paths of the two audio files as input and returns a float value representing the comparison metric, or None if analysis fails. ```APIDOC ## Analyzer (File Comparison Metrics) ### Description Compares two audio files using FFmpeg filters to calculate metrics like Peak SNR, SDR, and SI-SDR. It takes the paths of the two audio files as input and returns a float value representing the comparison metric, or None if analysis fails. ### Module analyzeAudio.analyzersUseFilename ### Function Signature `analyzer(pathFilenameAlfa: str | PathLike[Any], pathFilenameBeta: str | PathLike[Any]) -> float | None` ### Parameters - **pathFilenameAlfa** (str | PathLike[Any]): The path to the first audio file. - **pathFilenameBeta** (str | PathLike[Any]): The path to the second audio file. ### Output - **float | None**: The calculated comparison metric, or None if the analysis could not be performed. ``` -------------------------------- ### Pass librosa parameters to Waveform Analyzers Source: https://github.com/hunterhogan/analyzeaudio/blob/main/_autodocs/configuration.md When using waveform analyzers like analyzeRMS, you can pass specific parameters supported by the underlying librosa implementation. ```python from analyzeAudio.analyzersUseWaveform import analyzeRMS # Pass librosa parameters rms_db = analyzeRMS(waveform, frame_length=2048, hop_length=512) ``` -------------------------------- ### Measure Single Audio File Source: https://github.com/hunterhogan/analyzeaudio/blob/main/README.md Analyze a single audio file for a list of specified aspects. Returns a dictionary of measurements. Unavailable aspects will be marked as 'not found'. ```python from analyzeAudio import analyzeAudioFile listAspectNames = [ "LUFS integrated", "true_peak maximum", "RMS_level overall", "Spectral Flatness mean", "Zero Crossing Rate mean", ] listValues = analyzeAudioFile("voice.wav", listAspectNames) measurements = dict(zip(listAspectNames, listValues, strict=True)) print(measurements) ``` -------------------------------- ### Compare Tensor Waveforms Source: https://github.com/hunterhogan/analyzeaudio/blob/main/README.md Compare two PyTorch waveform tensors using various signal-to-noise and loss functions. Ensure tensors are correctly imported. ```python from analyzeAudio.contestsTensor import ( analyzeL1SNRDBMean, analyzeMultiResolutionSTFTLoss, ) l1snrdb = analyzeL1SNRDBMean(tensorReference, tensorEstimate) mrstft = analyzeMultiResolutionSTFTLoss(tensorReference, tensorEstimate) ``` ```python from analyzeAudio.contestsTensor import analyzeLogWMSEMean logwmse = analyzeLogWMSEMean( tensorReference, tensorEstimate, tensorMixture, sampleRate, ) ``` -------------------------------- ### Configure L1SNRDB computation with regularization Source: https://github.com/hunterhogan/analyzeaudio/blob/main/_autodocs/configuration.md The analyzeL1SNRDBMean function enables level-matching regularization for L1SNRDB calculations, with customizable parameters. ```python from analyzeAudio.analyzersUseTensor import analyzeL1SNRDBMean l1snrdb = analyzeL1SNRDBMean( reference_tensor, estimate_tensor, lambda0=0.1, delta_lambda=0.9, use_regularization=True, lmin=-60.0 ) ``` -------------------------------- ### Compute Spectral Contrast from Spectrogram Source: https://github.com/hunterhogan/analyzeaudio/blob/main/_autodocs/api-reference/analyzersUseSpectrogram.md Computes octave-band peak-to-valley spectral contrast. Requires a magnitude-domain spectrogram. Additional parameters can be passed to librosa.feature.spectral_contrast. ```python def analyzeSpectralContrast( spectrogramMagnitude: SpectrogramMagnitude, **keywordArguments: Any ) -> libturd: """Computes octave-band peak-to-valley contrast. ### Parameters | Parameter | Type | Required | Description | |-----------|------|----------|-------------| | spectrogramMagnitude | `SpectrogramMagnitude` | Yes | Magnitude-domain spectrogram array. Type: `numpy.ndarray[tuple[int, int, int], numpy.dtype[numpy.floating[Any]]]` | | keywordArguments | `Any` | No | Additional parameters forwarded to `librosa.feature.spectral_contrast()`. | ### Returns `libturd` — Framewise contrast values for each octave band. ### Registered Aspect `'Spectral Contrast mean'` — Mean of the spectral contrast trajectory. """ pass ``` -------------------------------- ### analyzeSpectralFlatnessMean Source: https://github.com/hunterhogan/analyzeaudio/blob/main/_autodocs/INDEX.md Analyzes the spectral flatness of an audio signal using Librosa, returning the mean spectral flatness. ```APIDOC ## analyzeSpectralFlatnessMean analyzeSpectralFlatnessMean() ### Description Analyzes the spectral flatness of an audio signal using Librosa, returning the mean spectral flatness. ### Method Not applicable (SDK function) ### Endpoint Not applicable (SDK function) ### Parameters Spectrogram input types and full signatures are detailed in the source documentation. ### Request Example ```python # Example usage (assuming analyzeSpectralFlatnessMean is imported) # mean_spectral_flatness = analyzeSpectralFlatnessMean() ``` ### Response #### Success Response - Returns the mean spectral flatness as a scalar value. #### Response Example ```json 0.105 ``` ``` -------------------------------- ### analyzeTempogramMean Source: https://github.com/hunterhogan/analyzeaudio/blob/main/_autodocs/INDEX.md Analyzes the tempo of an audio signal using Librosa, returning the mean of the tempogram. ```APIDOC ## analyzeTempogramMean analyzeTempogramMean() ### Description Analyzes the tempo of an audio signal using Librosa, returning the mean of the tempogram. ### Method Not applicable (SDK function) ### Endpoint Not applicable (SDK function) ### Parameters Parameters are detailed in the source documentation, including input types and mathematical descriptions. ### Request Example ```python # Example usage (assuming analyzeTempogramMean is imported) # mean_tempogram = analyzeTempogramMean() ``` ### Response #### Success Response - Returns the mean tempo as a scalar value. #### Response Example ```json 110.5 ``` ``` -------------------------------- ### analyzeSpectralBandwidthMean Source: https://github.com/hunterhogan/analyzeaudio/blob/main/_autodocs/INDEX.md Analyzes the spectral bandwidth of an audio signal using Librosa, returning the mean spectral bandwidth. ```APIDOC ## analyzeSpectralBandwidthMean analyzeSpectralBandwidthMean() ### Description Analyzes the spectral bandwidth of an audio signal using Librosa, returning the mean spectral bandwidth. ### Method Not applicable (SDK function) ### Endpoint Not applicable (SDK function) ### Parameters Spectrogram input types and full signatures are detailed in the source documentation. ### Request Example ```python # Example usage (assuming analyzeSpectralBandwidthMean is imported) # mean_spectral_bandwidth = analyzeSpectralBandwidthMean() ``` ### Response #### Success Response - Returns the mean spectral bandwidth as a scalar value. #### Response Example ```json 1500.0 ``` ``` -------------------------------- ### Analyzer Function (File-Based Scalar Metrics) Source: https://github.com/hunterhogan/analyzeaudio/blob/main/_autodocs/api-overview.md Analyzes an audio file using FFprobe to extract scalar measurements like Zero Crossing, DC offset, Loudness, and Spectral Stats. It takes the file path as input and returns a single float value or None if analysis fails. ```APIDOC ## Analyzer (File-Based Scalar Metrics) ### Description Analyzes an audio file using FFprobe to extract scalar measurements like Zero Crossing, DC offset, Loudness, and Spectral Stats. It takes the file path as input and returns a single float value or None if analysis fails. ### Module analyzeAudio.analyzersUseFilename ### Function Signature `analyzer(pathFilename: str | PathLike[Any]) -> float | None` ### Parameters - **pathFilename** (str | PathLike[Any]): The path to the audio file. ### Output - **float | None**: The scalar measurement from the audio file, or None if the analysis could not be performed. ``` -------------------------------- ### analyzeRMSMean Source: https://github.com/hunterhogan/analyzeaudio/blob/main/_autodocs/INDEX.md Analyzes the Root Mean Square (RMS) energy of an audio signal using Librosa, returning the mean RMS value. ```APIDOC ## analyzeRMSMean analyzeRMSMean() ### Description Analyzes the Root Mean Square (RMS) energy of an audio signal using Librosa, returning the mean RMS value. ### Method Not applicable (SDK function) ### Endpoint Not applicable (SDK function) ### Parameters Parameters are detailed in the source documentation, including input types and mathematical descriptions. ### Request Example ```python # Example usage (assuming analyzeRMSMean is imported) # mean_rms = analyzeRMSMean() ``` ### Response #### Success Response - Returns the mean RMS value as a scalar. #### Response Example ```json 0.15 ``` ``` -------------------------------- ### Register Custom Analyzer Source: https://github.com/hunterhogan/analyzeaudio/blob/main/_autodocs/configuration.md Register a new custom audio analyzer using the @registrationAudioAspect decorator. This allows the custom metric to be accessed through the audioAspects registry. ```python from analyzeAudio.audioAspectsRegistry import registrationAudioAspect from os import PathLike from typing import Any @registrationAudioAspect('My Custom Metric') def myCustomAnalyzer(pathFilename: str | PathLike[Any]) -> float: # Compute metric return 42.0 # Now accessible via from analyzeAudio import audioAspects metric_value = audioAspects['My Custom Metric']['analyzer']('audio.wav') ``` -------------------------------- ### ffprobeShotgunAndCache Source: https://github.com/hunterhogan/analyzeaudio/blob/main/_autodocs/INDEX.md Internal helper function for running FFprobe with a shotgun approach and caching results. This is typically used by FFprobe-based analyzers. ```APIDOC ## ffprobeShotgunAndCache ffprobeShotgunAndCache() ### Description Internal helper function for running FFprobe with a shotgun approach and caching results. This is typically used by FFprobe-based analyzers. ### Method Not applicable (Internal helper function) ### Endpoint Not applicable (Internal helper function) ### Parameters Not explicitly documented for external use. ### Request Example Not applicable for external use. ### Response Not explicitly documented for external use. ### Response Example Not applicable for external use. ``` -------------------------------- ### Analyze Single Audio File Source: https://github.com/hunterhogan/analyzeaudio/blob/main/_autodocs/README.md Analyzes a single audio file for specified metrics. Use this for quick, individual file processing. ```python from analyzeAudio import analyzeAudioFile values = analyzeAudioFile('audio.wav', ['LUFS integrated', 'RMS peak']) # Returns: [-23.5, -15.2] ``` -------------------------------- ### Control worker process count with CPUlimit Source: https://github.com/hunterhogan/analyzeaudio/blob/main/_autodocs/configuration.md The analyzeAudioListPathFilenames function accepts a CPUlimit parameter to control the number of worker processes used, defaulting to the system's available CPUs if not specified. ```python from analyzeAudio import analyzeAudioListPathFilenames # Use system default rows = analyzeAudioListPathFilenames(files, aspects, CPUlimit=None) # Use exactly 4 workers rows = analyzeAudioListPathFilenames(files, aspects, CPUlimit=4) # Use all available CPUs import os rows = analyzeAudioListPathFilenames(files, aspects, CPUlimit=os.cpu_count()) ``` -------------------------------- ### Register New Audio Analyzer Source: https://github.com/hunterhogan/analyzeaudio/blob/main/_autodocs/api-overview.md Use the `@registrationAudioAspect` decorator to register a new analyzer function with a specified aspect name. ```python @registrationAudioAspect(aspectName: str) def analyzer(pathFilename: str | PathLike[Any]) -> float | None: # Analyzer implementation pass ``` -------------------------------- ### Compare Two Audio Files Source: https://github.com/hunterhogan/analyzeaudio/blob/main/_autodocs/api-overview.md Analyzers for comparing two audio files using metrics like Peak SNR and SDR. These functions take paths to two audio files as input. ```python def analyzer(pathFilenameAlfa: str | PathLike[Any], pathFilenameBeta: str | PathLike[Any]) -> float | None ``` -------------------------------- ### analyzeSpectralFlatness Source: https://github.com/hunterhogan/analyzeaudio/blob/main/_autodocs/INDEX.md Analyzes the spectral flatness of an audio signal using Librosa, returning the full spectral flatness time-series. ```APIDOC ## analyzeSpectralFlatness analyzeSpectralFlatness() ### Description Analyzes the spectral flatness of an audio signal using Librosa, returning the full spectral flatness time-series. ### Method Not applicable (SDK function) ### Endpoint Not applicable (SDK function) ### Parameters Spectrogram input types and full signatures are detailed in the source documentation. ### Request Example ```python # Example usage (assuming analyzeSpectralFlatness is imported) # spectral_flatness_series = analyzeSpectralFlatness() ``` ### Response #### Success Response - Returns the spectral flatness time-series as a numerical array. #### Response Example ```json [0.1, 0.12, 0.09, 0.11] ``` ``` -------------------------------- ### analyzeTempogram Source: https://github.com/hunterhogan/analyzeaudio/blob/main/_autodocs/INDEX.md Analyzes the tempo of an audio signal using Librosa, returning the full time-series tempogram. ```APIDOC ## analyzeTempogram analyzeTempogram() ### Description Analyzes the tempo of an audio signal using Librosa, returning the full time-series tempogram. ### Method Not applicable (SDK function) ### Endpoint Not applicable (SDK function) ### Parameters Parameters are detailed in the source documentation, including input types and mathematical descriptions. ### Request Example ```python # Example usage (assuming analyzeTempogram is imported) # tempogram_data = analyzeTempogram() ``` ### Response #### Success Response - Returns the full tempogram as a numerical array. #### Response Example ```json [[0.1, 0.2, 0.3], [0.4, 0.5, 0.6]] ``` ``` -------------------------------- ### Registering a Custom Audio Aspect Analyzer Source: https://github.com/hunterhogan/analyzeaudio/blob/main/_autodocs/api-reference/audioAspectsRegistry.md Uses the 'registrationAudioAspect' decorator factory to register a custom analyzer function with a specific aspect name. The decorator automatically stores the analyzer and its parameters in the 'audioAspects' registry. ```python from analyzeAudio.audioAspectsRegistry import registrationAudioAspect @registrationAudioAspect('My Custom Metric') def myAnalyzer(pathFilename: str | PathLike[Any]) -> float: # Compute and return a metric value return 42.0 # After decoration, the analyzer is registered: # audioAspects['My Custom Metric'] = { # 'analyzer': myAnalyzer, # 'analyzerParameters': ['pathFilename'] # } ``` -------------------------------- ### Analyze Tempogram from Waveform Source: https://github.com/hunterhogan/analyzeaudio/blob/main/_autodocs/api-reference/analyzersUseWaveform.md Computes a local autocorrelation tempogram from an audio waveform. Requires waveform data and its sample rate. Additional parameters can be passed to librosa.feature.tempogram. ```python import numpy import soundfile from analyzeAudio.analyzersUseWaveform import analyzeTempogram with soundfile.SoundFile('audio.wav') as f: sampleRate = f.samplerate waveform = f.read(dtype='float32').astype(numpy.float32).T tempogram = analyzeTempogram(waveform, sampleRate) ``` -------------------------------- ### Inspect Analyzer Registry Source: https://github.com/hunterhogan/analyzeaudio/blob/main/_autodocs/api-overview.md Inspect the analyzer registry to list all available metrics and check the parameter requirements for a specific analyzer. This is useful for understanding the API's capabilities and configuration needs. ```python from analyzeAudio import getListAvailableAudioAspects, audioAspects # List all available metrics metrics = getListAvailableAudioAspects() print(f"Available metrics: {len(metrics)}") # Check requirements for a specific analyzer analyzer_info = audioAspects['SI-SDR mean'] print(f"Analyzer requires: {analyzer_info['analyzerParameters']}") # Output: ['pathFilenameAlfa', 'pathFilenameBeta'] ``` -------------------------------- ### Save Measurements to TSV Source: https://github.com/hunterhogan/analyzeaudio/blob/main/README.md Analyze audio files and save the measurements to a Tab-Separated Values (TSV) file. Requires specifying the output filename, the measurement rows, and the columns to include. ```python from analyzeAudio import ( analyzeAudioListPathFilenames, dataTabularTOpathFilenameDelimited, ) listAspectNames = ["LUFS integrated", "true_peak maximum"] rows = analyzeAudioListPathFilenames(["one.wav", "two.wav"], listAspectNames) dataTabularTOpathFilenameDelimited( "measurements.tsv", rows, ["pathFilename", *listAspectNames], ) ``` -------------------------------- ### Analyze SRMR with PyTorch Tensor Source: https://github.com/hunterhogan/analyzeaudio/blob/main/_autodocs/api-reference/analyzersUseTensor.md Computes Speech-to-Reverberation Modulation Energy Ratio (SRMR) values from an audio tensor. Ensure the audio tensor and sample rate are correctly provided. The `pytorchOnCPU` parameter controls CPU execution path. ```python import torch from analyzeAudio.analyzersUseTensor import analyzeSRMR # Create dummy audio tensor audio_tensor = torch.randn(1, 16000) # 1 second at 16 kHz srmr_values = analyzeSRMR(audio_tensor, 16000, pytorchOnCPU=True) mean_srmr = srmr_values.mean() ``` -------------------------------- ### Analyze Single Audio File Source: https://github.com/hunterhogan/analyzeaudio/blob/main/_autodocs/api-overview.md Use `analyzeAudioFile` to analyze a single audio file. It takes the file path and a list of aspect names to compute. Returns a list of computed values. ```python def analyzeAudioFile(pathFilename: str | PathLike[Any], listAspectNames: list[str]) -> list[str | float] ```