[Bugfix] Re-enable benchmarking of librispeech dataset. (#47033)

Signed-off-by: Anna Mayne <anna.mayne@arm.com>
This commit is contained in:
almayne
2026-07-08 16:19:26 +00:00
committed by GitHub
parent f05603fa28
commit d1f1d86797
2 changed files with 18 additions and 7 deletions
+9 -2
View File
@@ -123,15 +123,22 @@ def test_asr_dataset_sample_handles_local_audio_paths(tmp_path: Path) -> None:
) )
def test_asr_dataset_sample_handles_embedded_audio_bytes(tmp_path: Path) -> None: @pytest.mark.parametrize("has_filepath", [True, False])
def test_asr_dataset_sample_handles_embedded_audio_bytes(
tmp_path: Path, has_filepath: bool
) -> None:
audio_path = tmp_path / "earnings.wav" audio_path = tmp_path / "earnings.wav"
_write_wav(audio_path, duration_s=0.1) _write_wav(audio_path, duration_s=0.1)
test_path = None
if has_filepath:
test_path = audio_path
dataset = object.__new__(datasets_module.ASRDataset) dataset = object.__new__(datasets_module.ASRDataset)
dataset.data = [ dataset.data = [
{ {
"audio": { "audio": {
"path": None, "path": test_path,
"bytes": audio_path.read_bytes(), "bytes": audio_path.read_bytes(),
}, },
"text": "quarterly earnings call", "text": "quarterly earnings call",
+9 -5
View File
@@ -4090,9 +4090,10 @@ class ASRDataset(HuggingFaceDataset):
EARNINGS22_TINY_FILTERED_DATASET = ( EARNINGS22_TINY_FILTERED_DATASET = (
"D4nt3/esb-datasets-earnings22-validation-tiny-filtered" "D4nt3/esb-datasets-earnings22-validation-tiny-filtered"
) )
LIBRISPEECH_DATASET = "openslr/librispeech_asr"
SUPPORTED_DATASET_PATHS = { SUPPORTED_DATASET_PATHS = {
"openslr/librispeech_asr", LIBRISPEECH_DATASET,
"facebook/voxpopuli", "facebook/voxpopuli",
"LIUM/tedlium", "LIUM/tedlium",
"edinburghcstr/ami", "edinburghcstr/ami",
@@ -4120,7 +4121,10 @@ class ASRDataset(HuggingFaceDataset):
self.data = self.data.shuffle(seed=self.random_seed) self.data = self.data.shuffle(seed=self.random_seed)
self._materialize_local_audio_column() self._materialize_local_audio_column()
return return
if self.hf_name == self.EARNINGS22_TINY_FILTERED_DATASET: if self.hf_name in (
self.EARNINGS22_TINY_FILTERED_DATASET,
self.LIBRISPEECH_DATASET,
):
super().load_data() super().load_data()
self._disable_audio_decode() self._disable_audio_decode()
return return
@@ -4199,14 +4203,14 @@ class ASRDataset(HuggingFaceDataset):
elif isinstance(audio, str): elif isinstance(audio, str):
duration_s = sf.info(audio).duration duration_s = sf.info(audio).duration
mm_content = {"audio_path": audio} mm_content = {"audio_path": audio}
elif isinstance(audio, dict) and audio.get("path"):
duration_s = sf.info(audio["path"]).duration
mm_content = {"audio_path": audio["path"]}
elif isinstance(audio, dict) and audio.get("bytes") is not None: elif isinstance(audio, dict) and audio.get("bytes") is not None:
with BytesIO(audio["bytes"]) as audio_buffer: with BytesIO(audio["bytes"]) as audio_buffer:
y, sr = sf.read(audio_buffer, dtype="float32") y, sr = sf.read(audio_buffer, dtype="float32")
duration_s = get_audio_duration(y=y, sr=sr) duration_s = get_audio_duration(y=y, sr=sr)
mm_content = {"audio": (y, sr)} mm_content = {"audio": (y, sr)}
elif isinstance(audio, dict) and audio.get("path"):
duration_s = sf.info(audio["path"]).duration
mm_content = {"audio_path": audio["path"]}
else: else:
raise ValueError( raise ValueError(
"ASR samples must provide decoded audio arrays, " "ASR samples must provide decoded audio arrays, "