Skip to content

Commit

Permalink
Create separate_sounds_by_pitch
Browse files Browse the repository at this point in the history
  • Loading branch information
drfeinberg committed Apr 17, 2019
1 parent f749f13 commit 2857d7a
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions separate_sounds_by_pitch
Original file line number Original file line Diff line number Diff line change
@@ -0,0 +1,22 @@
import parselmouth
from parselmouth.praat import call
import glob
import os

output_directory = '/output/'
maximum_period = 0.02
mean_period = 0.01


for wave_file in glob.glob("/home/david/work/stimuli/All_Vowels/to_separate/*.wav"):
i = 0
name = os.path.splitext((os.path.basename(wave_file)))[0]
sound = parselmouth.Sound(wave_file)
pitch = sound.to_pitch_ac(pitch_floor = 50, pitch_ceiling = 600)
PointProcess = call([sound, pitch], "To PointProcess (cc)")
textgrid = call(PointProcess, "To TextGrid (vuv)", maximum_period, mean_period)
newsounds = call([sound, textgrid], "Extract all intervals", 1, False)
for sound in newsounds:
i += 1
newname = output_directory + '/' + name + '_' + str(i) + ".wav"
call(sound, 'Write to WAV file', newname)

0 comments on commit 2857d7a

Please sign in to comment.