summaryrefslogtreecommitdiff
path: root/client/tts.py
diff options
context:
space:
mode:
authorschneefux <schneefux+commit@schneefux.xyz>2014-10-07 19:32:42 +0200
committerschneefux <schneefux+commit@schneefux.xyz>2014-10-07 19:32:42 +0200
commit7e6e87cf45831e53fd0b1bcc73315068738402f6 (patch)
tree6c6a5e30b7254dd82a25d2d8a0f3f4c6c7cc7fe5 /client/tts.py
parent016cc20ad8605371e820e509f9881c2750019d09 (diff)
parent68704f36d7c05e06ffdf65e2593aa296ffd3a64d (diff)
downloadjasper-client-7e6e87cf45831e53fd0b1bcc73315068738402f6.tar.gz
jasper-client-7e6e87cf45831e53fd0b1bcc73315068738402f6.zip
Merge pull request #210 from Holzhaus/diagnose-improvements
Diagnose improvements
Diffstat (limited to 'client/tts.py')
-rw-r--r--client/tts.py27
1 files changed, 14 insertions, 13 deletions
diff --git a/client/tts.py b/client/tts.py
index 244c0f4..55c33b0 100644
--- a/client/tts.py
+++ b/client/tts.py
@@ -10,23 +10,22 @@ Speaker methods:
import os
import platform
import re
-import sys
import tempfile
import subprocess
import pipes
import logging
+import wave
from abc import ABCMeta, abstractmethod
-from distutils.spawn import find_executable
import argparse
-
-import wave
try:
import mad
import gtts
except ImportError:
pass
+import diagnose
+
class AbstractTTSEngine(object):
"""
@@ -37,7 +36,7 @@ class AbstractTTSEngine(object):
@classmethod
@abstractmethod
def is_available(cls):
- return (find_executable('aplay') is not None)
+ return diagnose.check_executable('aplay')
def __init__(self, **kwargs):
self._logger = logging.getLogger(__name__)
@@ -67,7 +66,7 @@ class AbstractMp3TTSEngine(AbstractTTSEngine):
@classmethod
def is_available(cls):
return (super(AbstractMp3TTSEngine, cls).is_available() and
- 'mad' in sys.modules.keys())
+ diagnose.check_python_import('mad'))
def play_mp3(self, filename):
mf = mad.MadFile(filename)
@@ -123,7 +122,7 @@ class EspeakTTS(AbstractTTSEngine):
@classmethod
def is_available(cls):
return (super(cls, cls).is_available() and
- find_executable('espeak') is not None)
+ diagnose.check_executable('espeak'))
def say(self, phrase):
self._logger.debug("Saying '%s' with '%s'", phrase, self.SLUG)
@@ -158,8 +157,9 @@ class FestivalTTS(AbstractTTSEngine):
@classmethod
def is_available(cls):
if (super(cls, cls).is_available() and
- find_executable('text2wave') is not None and
- find_executable('festival') is not None):
+ diagnose.check_executable('text2wave') and
+ diagnose.check_executable('festival')):
+
logger = logging.getLogger(__name__)
cmd = ['festival', '--pipe']
with tempfile.SpooledTemporaryFile() as out_f:
@@ -205,8 +205,8 @@ class MacOSXTTS(AbstractTTSEngine):
@classmethod
def is_available(cls):
return (platform.system() == 'darwin' and
- find_executable('say') is not None and
- find_executable('afplay') is not None)
+ diagnose.check_executable('say') and
+ diagnose.check_executable('afplay'))
def say(self, phrase):
self._logger.debug("Saying '%s' with '%s'", phrase, self.SLUG)
@@ -247,7 +247,7 @@ class PicoTTS(AbstractTTSEngine):
@classmethod
def is_available(cls):
return (super(cls, cls).is_available() and
- find_executable('pico2wave') is not None)
+ diagnose.check_executable('pico2wave'))
@property
def languages(self):
@@ -303,7 +303,8 @@ class GoogleTTS(AbstractMp3TTSEngine):
@classmethod
def is_available(cls):
return (super(cls, cls).is_available() and
- 'gtts' in sys.modules.keys())
+ diagnose.check_python_import('gtts') and
+ diagnose.check_network_connection())
@property
def languages(self):