diff --git a/docs/installation.rst b/docs/installation.rst index d12a530..7c73fa1 100644 --- a/docs/installation.rst +++ b/docs/installation.rst @@ -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 ~~~~~ diff --git a/persephone/config.py b/persephone/config.py index 27018a5..243997d 100644 --- a/persephone/config.py +++ b/persephone/config.py @@ -10,6 +10,8 @@ """ import configparser import os +import pathlib + from pkg_resources import Requirement, resource_filename config_file = configparser.ConfigParser() @@ -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")