Skip to content

Commit

Permalink
Use distutils.spawn.find_executable instead of which
Browse files Browse the repository at this point in the history
  • Loading branch information
Holzhaus committed Sep 19, 2014
1 parent bbd482f commit 410c203
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions client/speaker.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
import tempfile
import subprocess
from abc import ABCMeta, abstractmethod
from distutils.spawn import find_executable

import yaml
import pyaudio
Expand Down Expand Up @@ -78,7 +79,7 @@ class eSpeakSpeaker(AbstractSpeaker):

@classmethod
def is_available(cls):
return (super(eSpeakSpeaker, cls).is_available() and subprocess.call(['which','espeak']) == 0)
return (super(eSpeakSpeaker, cls).is_available() and find_executable('espeak') is not None)

def say(self, phrase, voice='default+m3', pitch_adjustment=40, words_per_minute=160):
with tempfile.NamedTemporaryFile(suffix='.wav', delete=False) as f:
Expand All @@ -102,7 +103,7 @@ class saySpeaker(AbstractSpeaker):

@classmethod
def is_available(cls):
return (platform.system() == 'darwin')
return (platform.system() == 'darwin' and find_executable('say') is not None and find_executable('afplay') is not None)

def say(self, phrase):
cmd = ['say', str(phrase)]
Expand All @@ -122,7 +123,7 @@ class picoSpeaker(AbstractSpeaker):

@classmethod
def is_available(cls):
return (super(picoSpeaker, cls).is_available() and subprocess.call(['which','pico2wave']) == 0)
return (super(picoSpeaker, cls).is_available() and find_executable('pico2wave') is not None)

@property
def languages(self):
Expand Down

0 comments on commit 410c203

Please sign in to comment.