Audio speech quality evaluation operator – calculates multiple audio quality metrics based on ClearerVoice-Studio/speechscore
metrics parameter; by default, all supported metrics are calculatedreference_audio_paths is optionalInput column names | Description |
|---|---|
audio_paths | An array of audio file paths (string type), supports: TOS URL, http(s) URL, S3 URL, local file path |
reference_audio_paths | Optional; an array of reference audio paths (string type) corresponding to each audio If not provided, the operator runs in reference-free scoring mode |
Structured result array, where each element is a struct containing multiple metrics with the following fields:
Audio processing failures return a struct containing null values
If a parameter does not have a default value, it is required
Parameter name | Type | Default value | Description |
|---|---|---|---|
model_path | str | /opt/las/models | Local model root path |
model_name | str | ClearerVoice-Studio/speechscore | SpeechScore model name or directory |
device | Optional[str] | None | Execution device; None means automatic selection (prefer cuda, otherwise cpu) |
metrics | Optional[list[str]] | None | List of metric names to be calculated (case-insensitive); by default, all supported metrics are calculated: ["BSSEval","CBAK","COVL","CSIG","DISTILL_MOS","DNSMOS","FWSEGSNR","LLR","LSD","MCD","NB_PESQ","NISQA","PESQ","SISDR","SNR","SRMR","SSNR","STOI"] |
The following code demonstrates how to use daft to evaluate the speech quality of audio.
from __future__ import annotations import logging import os import ray import daft from daft import col from daft.las.functions.audio import AudioSpeechScore from daft.las.functions.udf import las_udf def configure_logging(): logging.basicConfig( level=logging.INFO, format="%(asctime)s - %(name)s - %(levelname)s - %(message)s", datefmt="%Y-%m-%d %H:%M:%S.%s".format(), ) logging.getLogger("tracing.span").setLevel(logging.WARNING) logging.getLogger("daft_io.stats").setLevel(logging.WARNING) logging.getLogger("DaftStatisticsManager").setLevel(logging.WARNING) logging.getLogger("DaftFlotillaScheduler").setLevel(logging.WARNING) logging.getLogger("DaftFlotillaDispatcher").setLevel(logging.WARNING) configure_logging() if __name__ == "__main__": TOS_INPUT_DIR_URL = os.getenv("TOS_INPUT_DIR_URL", "las-cn-beijing-public-online.tos-cn-beijing.volces.com") ray.init(dashboard_host="0.0.0.0", runtime_env={"worker_process_setup_hook": configure_logging}) daft.set_runner_ray() samples = { "audio_paths": [os.path.join(f"https://{TOS_INPUT_DIR_URL}", "public/shared_audio_dataset/video_demo.mp3")], "reference_audio_paths": [os.path.join(f"https://{TOS_INPUT_DIR_URL}", "public/shared_audio_dataset/video_demo_denoised.mp3")], } df = daft.from_pydict(samples) df = df.with_column( "audio_speech_score", las_udf( AudioSpeechScore, construct_args={}, num_gpus=1, batch_size=8, concurrency=1, )(col("audio_paths"), col("reference_audio_paths")), ) df.show() # ╭────────────────────────────────┬────────────────────────────────┬───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮ # │ audio_paths ┆ reference_audio_paths ┆ audio_speech_score │ # │ --- ┆ --- ┆ --- │ # │ String ┆ String ┆ Struct[BSSEval: Struct[ISR: Float64, SAR: Float64, SDR: Float64], CBAK: Float64, COVL: Float64, CSIG: Float64, DISTILL_MOS: Float64, DNSMOS: Struct[BAK: Float64, OVRL: Float64, P808_MOS: Float64, SIG: Float64], FWSEGSNR: │ # │ ┆ ┆ Float64, LLR: Float64, LSD: Float64, MCD: Float64, NB_PESQ: Float64, NISQA: Struct[col_pred: Float64, dis_pred: Float64, loud_pred: Float64, mos_pred: Float64, noi_pred: Float64], PESQ: Float64, SISDR: Float64, SNR: │ # │ ┆ ┆ Float64, SRMR: Float64, SSNR: Float64, STOI: Float64] │ # ╞════════════════════════════════╪════════════════════════════════╪═══════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════╡ # │ https://las-public-data-qa.to… ┆ https://las-public-data-qa.to… ┆ {BSSEval: {ISR: 15.0130389824… │ # ╰────────────────────────────────┴────────────────────────────────┴───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯