Beispiel #1
0
def test_multivoice_noise(generate_audio_files, mock_stream, config):
	semaphore = Semaphore(1)
	event = Event()
	event.set()
	record.record(Queue(), config, semaphore, event)
	assert len(os.listdir(get_recording_dir())) == 1
	recording = read_wav(path.join(get_recording_dir(), os.listdir(get_recording_dir())[0]))
	original = read_wav(path.join(get_test_recording_dir(), 'hello+como_noise.wav'))
	start, end = generate_audio_files["multivoice_noise"]
	desired_speech = original[start + 15000:end - 15000]
	assert desired_speech in recording
	assert (len(recording) - len(desired_speech)) / (config.get("num_bytes") * config.get("rate")) < .5
Beispiel #2
0
def test_too_long(generate_audio_files, mock_stream, config):
	semaphore = Semaphore(1)
	event = Event()
	event.set()
	record.record(Queue(), config, semaphore, event)
	files = sorted(os.listdir(get_recording_dir()))
	assert len(files) == 2
	recording1 = read_wav(path.join(get_recording_dir(), files[0]))
	recording2 = read_wav(path.join(get_recording_dir(), files[1]))
	recording = recording1 + recording2
	original = read_wav(path.join(get_test_recording_dir(), 'tale.wav'))
	start, end = generate_audio_files["tale"]
	desired_speech = original[start + 20000:end - 20000]
	assert desired_speech in recording
	assert (len(recording) - len(desired_speech)) / (config.get("num_bytes") * config.get("rate")) < 0.5
Beispiel #3
0
def test_pauses(generate_audio_files, mock_stream, config):
	semaphore = Semaphore(1)
	event = Event()
	event.set()
	record.record(Queue(), config, semaphore, event)
	files = sorted(os.listdir(get_recording_dir()))
	assert len(files) == 2 # the first section of speech is below the length threshold
	recording1 = read_wav(path.join(get_recording_dir(), files[0]))
	recording2 = read_wav(path.join(get_recording_dir(), files[1]))
	original = read_wav(path.join(get_test_recording_dir(), 'star.wav'))
	((start1, end1), (start2, end2)) = generate_audio_files["star"]
	desired_speech1 = original[start1 + 20000:end1 - 20000]
	desired_speech2 = original[start2 + 5000:end2 - 20000]
	assert desired_speech1 in recording1
	assert desired_speech2 in recording2
	assert (len(recording1) - len(desired_speech1)) / (config.get("num_bytes") * config.get("rate")) < 1.5
	assert (len(recording2) - len(desired_speech2)) / (config.get("num_bytes") * config.get("rate")) < .5
Beispiel #4
0
def test_short(mock_stream, config):
	semaphore = Semaphore(1)
	event = Event()
	event.set()
	record.record(Queue(), config, semaphore, event)
	assert os.listdir(get_recording_dir()) == []