Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[MRG] Attempt to use a better fallback path for Kaldi #238

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions docs/installation.rst
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,8 @@ Here is an example of how to specify the path to required binaries in the ``sett

Here "sox" and "ffmpeg" must be available on the path and ``KALDI_ROOT`` specifies an absolute path. Note that these paths can also be specified as absolute paths if you wish.

``KALDI_ROOT_PATH`` can also be used to specify the path to your Kaldi installation but this is deprecated, please use ``KALDI_ROOT`` in your settings file.

Paths
~~~~~

Expand Down
16 changes: 15 additions & 1 deletion persephone/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@
"""
import configparser
import os
import pathlib

from pkg_resources import Requirement, resource_filename

config_file = configparser.ConfigParser()
Expand Down Expand Up @@ -43,7 +45,19 @@
# FFMPEG is used for normalizing WAVs
FFMPEG_PATH = config_file.get("PATHS", "FFMPEG_PATH", fallback="ffmpeg")
# Kaldi is used for pitch extraction
KALDI_ROOT = config_file.get("PATHS", "KALDI_ROOT_PATH", fallback="/home/oadams/tools/kaldi")
kaldi_fallback = pathlib.Path.home() / "tools" / "kaldi"

if 'KALDI_ROOT' in config_file and 'KALDI_ROOT_PATH' in config_file:
raise ValueError("Error both KALDI_ROOT and KALDI_ROOT_PATH were defined in settings.ini "
" aborting due to this ambiguity."
" Resolve this conflict by using only one of these, preferably KALDI_ROOT only")

_kaldi_root = config_file.get("PATHS", "KALDI_ROOT", fallback=str(kaldi_fallback))

if 'KALDI_ROOT' not in config_file:
_kaldi_root = config_file.get("PATHS", "KALDI_ROOT_PATH", fallback=str(kaldi_fallback))

KALDI_ROOT = _kaldi_root

# Fetch the path of the logging.ini file installed by setuptools.
logging_ini_path = resource_filename(Requirement.parse("persephone"), "persephone/logging.ini")
Expand Down