Skip to content

Commit

Permalink
cherry-pick pulled praat call from aligner.py
Browse files Browse the repository at this point in the history
  • Loading branch information
JoFrhwld committed Oct 3, 2022
1 parent ed23a05 commit bee97a8
Showing 1 changed file with 18 additions and 16 deletions.
34 changes: 18 additions & 16 deletions fave/align/aligner.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
from . import transcriptprocessor
from fave import cmudictionary
from fave import praat

import parselmouth

class Aligner():
"""
Expand Down Expand Up @@ -129,21 +129,23 @@ def get_duration(self, FADIR='', PRAATPATH=''):
f.close()
duration = round((nx / sr), 3)
except wave.Error: # wave.py does not seem to support 32-bit .wav files???
self.logger.debug('Script path is %s',os.path.join(
FADIR, "praatScripts", "get_duration.praat"))
if PRAATPATH:
dur_command = "%s %s %s" % (PRAATPATH, os.path.join(
FADIR, "praatScripts", "get_duration.praat"), self.audio)
else:
dur_command = "praat %s %s" % (os.path.join(
FADIR, "praatScripts", "get_duration.praat"), self.audio)
duration = round(
float(
subprocess.Popen(
dur_command,
shell=True,
stdout=subprocess.PIPE).communicate()[0].strip()),
3)
sound = parselmouth.Sound(self.audio)
duration = round(sound.duration, 3)
# self.logger.debug('Script path is %s',os.path.join(
# FADIR, "praatScripts", "get_duration.praat"))
# if PRAATPATH:
# dur_command = "%s %s %s" % (PRAATPATH, os.path.join(
# FADIR, "praatScripts", "get_duration.praat"), self.audio)
# else:
# dur_command = "praat %s %s" % (os.path.join(
# FADIR, "praatScripts", "get_duration.praat"), self.audio)
# duration = round(
# float(
# subprocess.Popen(
# dur_command,
# shell=True,
# stdout=subprocess.PIPE).communicate()[0].strip()),
# 3)

return duration

Expand Down

0 comments on commit bee97a8

Please sign in to comment.