Skip to main content

Python implementation of the 2f-model for estimating subjective quality of separated audio signals

Project description

the Seabass logo

Seabass - Python Implementation of the 2f Model

Seabass is a Python implementation of the 2f-model developed by the Internaltional Audio Laboratories Erlangen. It is a model for estimating subjective quality of separated audio source signals, specifically the mean MUSHRA score. The part of this code, particularly the computation of the Model Output Variables are based on the MATLAB implementation, PQEvalAudio, by Peter Kabal. See here for more details about the 2f-model.

Installation

git clone this-repository
cd 2f-model
pip install -e .

Usage

The computation of MOVs requires that the audio signal are scaled to have amplitudes in the range [-32768, 32767]. By default, seabass handles this automatically when using the CLI mode or estimate_mean_mushra_score_file, but not always when using estimate_mean_mushra_score.

When reading from files, soundfile reads the header and normalize it to floating point in the range [-1, 1). seabass then scales them up by 32768.

CLI

seabass --test-path /path/to/test-file.wav \
    --ref-path /path/to/reference-file.wav \
    --output-path /path/to/output.json

Python

Evaluating directly from files

from seabass.core.models.mms import estimate_mean_mushra_score_file

mms = estimate_mean_mushra_score_file(test_path, ref_path)

print(f"Estimated MMS: {mms:3.2f}")

Evaluating from loaded signals

When using loaded audio, make sure that your audio signals are either

  • in the range [-32768, 32767] and pass the argument signal_dtype='int16' to the function, or
  • in the range [-1, 1) and pass the argument signal_dtype='double' to the function.

If your audio signals are in the range [-1, 1), they will be multiplied by 32768 to scale them to [-32768, 32768). If this is not what you want, you can scale them yourself before passing them to the function with signal_dtype='int16'.

import soundfile as sf
from seabass.core.models.mms import estimate_mean_mushra_score

ref_signal, fs_r = sf.read(ref_path, always_2d=True)
test_signal, fs_t = sf.read(test_path, always_2d=True)

# soundfile returns (n_samples, n_channels) but seabass expectes (n_channels, n_samples)
ref_signal = ref_signal.T 
test_signal = test_signal.T

assert fs_r == fs_t == 48000
# PEAQ only works with 48 kHz signals
# if your signals are not 48 kHz, resample them

mms = estimate_mean_mushra_score(test_signal, ref_signal)

print(f"Estimated MMS: {mms:3.2f}")

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

seabass_2f-0.1.0.tar.gz (20.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

seabass_2f-0.1.0-py3-none-any.whl (23.2 kB view details)

Uploaded Python 3

File details

Details for the file seabass_2f-0.1.0.tar.gz.

File metadata

  • Download URL: seabass_2f-0.1.0.tar.gz
  • Upload date:
  • Size: 20.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for seabass_2f-0.1.0.tar.gz
Algorithm Hash digest
SHA256 496c9c0637baddde0f3c27bec3e1055db15285ef49d8e9679c289e3e90d321bd
MD5 9df5e38fd11cdc58ef2b9a7307b5052c
BLAKE2b-256 6b25249dbf6486d1305b4f0a5f6bd0d98bcd4f5b16b99eca1d71b0ed706d3d17

See more details on using hashes here.

Provenance

The following attestation bundles were made for seabass_2f-0.1.0.tar.gz:

Publisher: pypi-publish.yml on kwatcharasupat/2f-model

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file seabass_2f-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: seabass_2f-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 23.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for seabass_2f-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 8771c38c0ec684f36ec1dba1763a748ae57d5e258b7e8511676d01d5bc075aec
MD5 897c859a10c5e4a76ff256fd648d97cb
BLAKE2b-256 5052fe79add9db11092e9370329ce0eb2ce789589610025f32c633fd3dda072f

See more details on using hashes here.

Provenance

The following attestation bundles were made for seabass_2f-0.1.0-py3-none-any.whl:

Publisher: pypi-publish.yml on kwatcharasupat/2f-model

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page