From a7170b31c403e347bc264602d3a624c7ec56ea80 Mon Sep 17 00:00:00 2001 From: Janis Lesinskis Date: Wed, 4 Nov 2020 19:25:46 +1100 Subject: [PATCH 1/3] Attempt to use a better fallback path for Kaldi --- persephone/config.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/persephone/config.py b/persephone/config.py index 27018a5..5bcb56b 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,8 @@ # 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" +KALDI_ROOT = config_file.get("PATHS", "KALDI_ROOT_PATH", fallback=str(kaldi_fallback)) # Fetch the path of the logging.ini file installed by setuptools. logging_ini_path = resource_filename(Requirement.parse("persephone"), "persephone/logging.ini") From 640d5daea6f9080109046246f5e7d1def04c8ec5 Mon Sep 17 00:00:00 2001 From: Janis Lesinskis Date: Sun, 15 Nov 2020 16:20:53 +1100 Subject: [PATCH 2/3] Handle potential ambiguity in loading config for KALDI_ROOT and fix mismatch with docs --- persephone/config.py | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/persephone/config.py b/persephone/config.py index 5bcb56b..243997d 100644 --- a/persephone/config.py +++ b/persephone/config.py @@ -46,7 +46,18 @@ FFMPEG_PATH = config_file.get("PATHS", "FFMPEG_PATH", fallback="ffmpeg") # Kaldi is used for pitch extraction kaldi_fallback = pathlib.Path.home() / "tools" / "kaldi" -KALDI_ROOT = config_file.get("PATHS", "KALDI_ROOT_PATH", fallback=str(kaldi_fallback)) + +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") From eec34d472ee21b2abf59bbbec95abd32e44a7c64 Mon Sep 17 00:00:00 2001 From: Janis Lesinskis Date: Sun, 15 Nov 2020 16:46:04 +1100 Subject: [PATCH 3/3] Make comment about KALDI_ROOT_PATH deprecation in docs --- docs/installation.rst | 2 ++ 1 file changed, 2 insertions(+) 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 ~~~~~