def test_pitch_praat(base_filenames): for f in base_filenames: wavpath = f + '.wav' func = PitchTrackFunction(time_step=0.01, min_pitch=75, max_pitch=600) pitch = func(wavpath) sig, sr = librosa.load(wavpath) pitch2 = func(SignalSegment(sig, sr))
def test_intensity_praat(praatpath, base_filenames): for f in base_filenames: wavpath = f + '.wav' func = PraatIntensityTrackFunction(praat_path=praatpath, time_step=0.01) pitch = func(wavpath) sig, sr = librosa.load(wavpath) pitch2 = func(SignalSegment(sig, sr))
def test_mfcc(base_filenames): for f in base_filenames: wavpath = f + '.wav' func = MfccFunction(time_step=0.01, min_frequency=80, max_frequency=7800, num_filters=26, num_coefficients=13, use_power=True, deltas=False) mfccs = func(wavpath) sig, sr = librosa.load(wavpath) mfccs2 = func(SignalSegment(sig, sr))
def test_envelopes(base_filenames): for f in base_filenames: wavpath = f + '.wav' func = AmplitudeEnvelopeFunction(num_bands=8, min_frequency=80, max_frequency=7800) envelopes = func(wavpath) sig, sr = librosa.load(wavpath) envelopes2 = func(SignalSegment(sig, sr))
def test_pitch_reaper(noise_path, y_path, reaperpath): func = ReaperPitchTrackFunction(reaper_path=reaperpath, time_step=0.01, min_pitch=75, max_pitch=600) pitch = func(noise_path) assert (mean(x['F0'] for x in pitch.values()) == -1) sr, sig = wavfile.read(noise_path) pitch2 = func(SignalSegment(sig, sr)) # assert pitch == pitch2 pitch = func(y_path) assert (mean(x['F0'] for x in pitch.values()) - 98.514) < 0.001 sr, sig = wavfile.read(y_path) pitch2 = func(SignalSegment(sig, sr))
def test_mfcc_praat(praatpath, base_filenames): for f in base_filenames: wavpath = f + '.wav' func = PraatMfccFunction(praat_path=praatpath, window_length=0.025, time_step=0.01, max_frequency=7800, num_coefficients=13) mfccs = func(wavpath) sig, sr = librosa.load(wavpath) mfccs2 = func(SignalSegment(sig, sr)) break
def test_formants_praat(base_filenames): for f in base_filenames: wavpath = f + '.wav' func = FormantTrackFunction(time_step=0.01, window_length=0.025, num_formants=5, max_frequency=5500) formants = func(wavpath) sig, sr = librosa.load(wavpath) formants2 = func(SignalSegment(sig, sr))
def test_pitch_pulses_praat(praatpath, noise_path, y_path): func = PraatPitchTrackFunction(praat_path=praatpath, time_step=0.01, min_pitch=75, max_pitch=600, with_pulses=True) pitch, pulses = func(noise_path) assert (all(x['F0'] is None for x in pitch.values())) sr, sig = wavfile.read(noise_path) pitch2, pulses2 = func(SignalSegment(sig, sr)) # assert pitch == pitch2 pitch, pulses = func(y_path) assert (mean(x['F0'] for x in pitch.values()) - 100) < 1 sr, sig = wavfile.read(y_path) pitch2, pulses2 = func(SignalSegment(sig, sr))
def test_segment_formant_track_praat(praatpath, acoustic_corpus_path): func = PraatSegmentFormantTrackFunction(praat_path=praatpath, time_step=0.01, window_length=0.025, num_formants=5, max_frequency=5500) segment = FileSegment(acoustic_corpus_path, 2.142, 2.245, 0, padding=0.1) formants = func(segment) assert all(x >= 2.142 and x <= 2.245 for x in formants.keys()) sig, sr = librosa.load(acoustic_corpus_path) with pytest.raises(FunctionMismatch): formants2 = func(SignalSegment(sig, sr))
def test_formant_point_praat(praatpath, base_filenames): for f in base_filenames: wavpath = f + '.wav' func = PraatFormantPointFunction(praat_path=praatpath, time_step=0.01, window_length=0.025, num_formants=5, max_frequency=5500, point_percent=0.33) formants = func(wavpath) sig, sr = librosa.load(wavpath) formants2 = func(SignalSegment(sig, sr))
def test_segment_pitch_track_praat(praatpath, acoustic_corpus_path): func = PraatSegmentPitchTrackFunction(praat_path=praatpath, time_step=0.01, min_pitch=75, max_pitch=600) segment = FileSegment(acoustic_corpus_path, 2.142, 2.245, 0, padding=0.1) pitch = func(segment) assert all(x >= 2.142 and x <= 2.245 for x in pitch.keys()) segment = FileSegment(acoustic_corpus_path, 2.142, 2.245, 0, padding=10) pitch = func(segment) assert all(x >= 2.142 and x <= 2.245 for x in pitch.keys()) segment = FileSegment(acoustic_corpus_path, 2.142, 2.245, 0, padding=0) pitch = func(segment) assert all(x >= 2.142 and x <= 2.245 for x in pitch.keys()) sig, sr = librosa.load(acoustic_corpus_path) with pytest.raises(FunctionMismatch): formants2 = func(SignalSegment(sig, sr))
def test_segment_formant_point_praat(praatpath, acoustic_corpus_path): func = PraatSegmentFormantPointFunction(praat_path=praatpath, time_step=0.01, window_length=0.025, num_formants=5, max_frequency=5500, point_percent=0.33) with pytest.raises(FunctionMismatch): formants = func(acoustic_corpus_path) segment = FileSegment(acoustic_corpus_path, 2.142, 2.245, 0, padding=0.1) formants = func(segment) assert abs(formants['F1'] - 480) < 50 assert abs(formants['F2'] - 1496) < 100 assert abs(formants['F3'] - 2593) < 250 assert abs(formants['F4'] - 3673) < 500 sig, sr = librosa.load(acoustic_corpus_path) with pytest.raises(FunctionMismatch): formants2 = func(SignalSegment(sig, sr))
def test_segment_pitch_track_praat(praatpath, base_filenames): for f in base_filenames: if f != 'acoustic_corpus': continue wavpath = f + '.wav' func = PraatSegmentIntensityTrackFunction(praat_path=praatpath, time_step=0.01) segment = FileSegment(wavpath, 2.142, 2.245, 0, padding=0.1) pitch = func(segment) assert all(x >= 2.142 and x <= 2.245 for x in pitch.keys()) segment = FileSegment(wavpath, 2.142, 2.245, 0, padding=10) pitch = func(segment) assert all(x >= 2.142 and x <= 2.245 for x in pitch.keys()) segment = FileSegment(wavpath, 2.142, 2.245, 0, padding=0) pitch = func(segment) assert all(x >= 2.142 and x <= 2.245 for x in pitch.keys()) sig, sr = librosa.load(wavpath) with pytest.raises(FunctionMismatch): formants2 = func(SignalSegment(sig, sr))