Skip to content

Commit

Permalink
Merge pull request fgnt#3 from TCord/main
Browse files Browse the repository at this point in the history
Fix usage of scenario_key for LibriSpeech database
  • Loading branch information
TCord authored Aug 18, 2022
2 parents 976bdb3 + f67055a commit d295dd4
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 26 deletions.
10 changes: 7 additions & 3 deletions mms_msg/databases/single_speaker/librispeech/database.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
from typing import Iterable

from lazy_dataset.database import JsonDatabase
from mms_msg import keys
from mms_msg.simulation.utils import load_audio
Expand All @@ -16,13 +18,15 @@ def load_example(self, example):

def add_scenario(self, example):
example['scenario'] = '_'.join([example[key] for key in sorted(self.scenario_key)])
return example

def get_dataset(self, name=None):
dataset = super().get_dataset(name)
if self.scenario_key is not None:
dataset.map(self.add_scenario)
dataset = dataset.map(self.add_scenario)
return dataset


class LibriSpeech8kHz(LibriSpeech):
def __init__(self, json_path=database_jsons / 'librispeech_8k.json'):
super().__init__(json_path)
def __init__(self, json_path=database_jsons / 'librispeech_8k.json', scenario_key=None):
super().__init__(json_path, scenario_key=scenario_key)
24 changes: 1 addition & 23 deletions mms_msg/databases/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,31 +33,9 @@ def check_audio_files_exist(
speedup=None,
):
"""
Verifies all files denoted in a dabatase_dict as paths actually exist.
No structure for the database_dict is assumed. It will just search for all
string values ending with a certain file type (e.g. wav).
>>> check_audio_files_exist({2: [1, '/net/db/timit/pcm/train/dr1/fcjf0/sa1.wav', 'abc.wav']})
Traceback (most recent call last):
...
AssertionError: ('abc.wav', (2, '2'))
>>> check_audio_files_exist(1)
Traceback (most recent call last):
...
AssertionError: Expect at least one wav file. It is likely that the database folder is empty and the greps did not work. to_check: {}
>>> check_audio_files_exist('abc.wav')
Traceback (most recent call last):
...
AssertionError: ('abc.wav', ())
>>> check_audio_files_exist('/net/db/timit/pcm/train/dr1/fcjf0/sa1.wav')
>>> check_audio_files_exist(1, speedup='thread')
Traceback (most recent call last):
...
AssertionError: Expect at least one wav file. It is likely that the database folder is empty and the greps did not work. to_check: {}
>>> check_audio_files_exist('abc.wav', speedup='thread')
Traceback (most recent call last):
...
AssertionError: ('abc.wav', ())
>>> check_audio_files_exist('/net/db/timit/pcm/train/dr1/fcjf0/sa1.wav', speedup='thread')
"""

def path_exists(path):
Expand Down

0 comments on commit d295dd4

Please sign in to comment.