From a8809862e909e4c703228e4bd583bb25fabc3ae9 Mon Sep 17 00:00:00 2001 From: schneefux Date: Wed, 8 Oct 2014 19:59:17 +0200 Subject: Use diagnose.check_executable for executable detection in g2p.py --- client/g2p.py | 17 ++--------------- 1 file changed, 2 insertions(+), 15 deletions(-) (limited to 'client') diff --git a/client/g2p.py b/client/g2p.py index b14ee98..a2b3982 100644 --- a/client/g2p.py +++ b/client/g2p.py @@ -1,14 +1,11 @@ # -*- coding: utf-8-*- import os -import sys import re import subprocess import tempfile -import shutil import logging -if sys.version_info < (3, 3): - import distutils.spawn +import diagnose import jasperpath import yaml @@ -17,16 +14,6 @@ class PhonetisaurusG2P(object): PATTERN = re.compile(r'^(?P.+)\t(?P\d+\.\d+)\t ' + r'(?P.*) ', re.MULTILINE) - @classmethod - def executable_found(cls): - if sys.version_info < (3, 3): - cmd_exists = distutils.spawn.find_executable - else: - cmd_exists = shutil.which - # Required binary for this class - cmd = 'phonetisaurus-g2p' - return cmd_exists(cmd) - @classmethod def execute(cls, fst_model, input, is_file=False, nbest=None): logger = logging.getLogger(__name__) @@ -94,7 +81,7 @@ class PhonetisaurusG2P(object): return conf def __new__(cls, fst_model=None, *args, **kwargs): - if not cls.executable_found(): + if not diagnose.check_executable('phonetisaurus-g2p'): raise OSError("Can't find command 'phonetisaurus-g2p'! Please " + "check if Phonetisaurus is installed and in your " + "$PATH.") -- cgit v1.3.1