Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SpeechSynthesisDataset returns speaker_ids #1206

Merged
merged 11 commits into from
Nov 10, 2023
10 changes: 8 additions & 2 deletions lhotse/dataset/speech_synthesis.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
'audio_lens': (B, ) int tensor
'features_lens': (B, ) int tensor
'tokens_lens': (B, ) int tensor
'speakers': List[str] of len B (optional) # if return_spk_ids is True
}
"""

Expand All @@ -34,13 +35,15 @@
feature_transforms: Union[Sequence[Callable], Callable] = None,
add_eos: bool = True,
add_bos: bool = True,
return_spk_ids: bool = False,
) -> None:
super().__init__()

self.cuts = cuts
self.token_collater = TokenCollater(cuts, add_eos=add_eos, add_bos=add_bos)
self.cut_transforms = ifnone(cut_transforms, [])
self.feature_input_strategy = feature_input_strategy
self.return_spk_ids = return_spk_ids

if feature_transforms is None:
feature_transforms = []
Expand All @@ -65,15 +68,18 @@
features = transform(features)

tokens, tokens_lens = self.token_collater(cuts)

return {
batch = {
"audio": audio,
"features": features,
"tokens": tokens,
"audio_lens": audio_lens,
"features_lens": features_lens,
"tokens_lens": tokens_lens,
}
if self.return_spk_ids:
batch["speakers"] = [cut.supervisions[0].speaker for cut in cuts]

Check warning on line 80 in lhotse/dataset/speech_synthesis.py

View check run for this annotation

Codecov / codecov/patch

lhotse/dataset/speech_synthesis.py#L80

Added line #L80 was not covered by tests

return batch


def validate_for_tts(cuts: CutSet) -> None:
Expand Down
Loading