def multi_file_recording(): recording = lhotse.RecordingSet.from_recordings( [ lhotse.Recording( id="lbi-1272-135031-0000", sources=[ lhotse.AudioSource( type="file", channels=[0], source="nonexistent-c1.wav" ), lhotse.AudioSource( type="file", channels=[1], source="nonexistent-c2.wav" ), ], sampling_rate=16000, num_samples=174160, duration=174160.0 / 16000.0, transforms=None, ) ] ) supervision = lhotse.SupervisionSet.from_segments( [ lhotse.SupervisionSegment( id="lbi-1272-135031-0000-A", recording_id="lbi-1272-135031-0000", start=0.0, duration=10.885, channel=0, text="SOMETHING", speaker="lbi-1272-135031-A", gender="m", language="en-US", ), lhotse.SupervisionSegment( id="lbi-1272-135031-0000-B", recording_id="lbi-1272-135031-0000", start=0.0, duration=10.885, channel=1, text="SOMETHING ELSE", speaker="lbi-1272-135031-B", gender="f", language="en-US", ), ] ) return recording, supervision
def test_ok_on_file_singlechannel_wav_source_type(tmp_path, channel): source = lhotse.AudioSource( type="file", channels=[channel], source="nonexistent.wav" ) out = lhotse.kaldi.make_wavscp_channel_string_map(source, 16000) assert list(out.keys()) == [channel] assert out[channel] == "nonexistent.wav"
def test_ok_on_file_singlechannel_mp3_source_type(tmp_path, channel): source = lhotse.AudioSource( type="file", channels=[channel], source="nonexistent.mp3" ) out = lhotse.kaldi.make_wavscp_channel_string_map(source, 16000) assert list(out.keys()) == [channel] assert out[channel].startswith("ffmpeg") assert "nonexistent.mp3" in out[channel]
def test_ok_on_file_multichannel_wav_source_type(tmp_path): source = lhotse.AudioSource( type="file", channels=[0, 1, 2], source="nonexistent.wav" ) out = lhotse.kaldi.make_wavscp_channel_string_map(source, 16000) assert list(out.keys()) == [0, 1, 2] for channel in out.keys(): assert out[channel].startswith("ffmpeg") assert "nonexistent.wav" in out[channel]
def test_ok_on_command_singlechannel_source_type(tmp_path): source = lhotse.AudioSource(type="command", channels=[0], source="true") out = lhotse.kaldi.make_wavscp_channel_string_map(source, 16000) assert list(out.keys()) == [0] assert out[0] == "true |"
def test_fail_on_command_multichannel_source_type(tmp_path): source = lhotse.AudioSource(type="command", channels=[0, 1], source="false") with pytest.raises(ValueError): lhotse.kaldi.make_wavscp_channel_string_map(source, 16000)
def test_fail_on_url_source_type(tmp_path): source = lhotse.AudioSource(type="url", channels=[0], source="http://example.com/") with pytest.raises(ValueError): lhotse.kaldi.make_wavscp_channel_string_map(source, 16000)