mirror of
https://github.com/markqvist/Sideband.git
synced 2024-12-27 16:39:32 -05:00
26 lines
618 B
Python
26 lines
618 B
Python
import subprocess
|
|
from sbapp.plyer.facades import TTS
|
|
from sbapp.plyer.utils import whereis_exe
|
|
|
|
|
|
class EspeakTextToSpeech(TTS):
|
|
''' Speaks using the espeak program
|
|
'''
|
|
def _speak(self, **kwargs):
|
|
subprocess.call(["espeak", kwargs.get('message')])
|
|
|
|
|
|
class FliteTextToSpeech(TTS):
|
|
''' Speaks using the flite program
|
|
'''
|
|
def _speak(self, **kwargs):
|
|
subprocess.call(["flite", "-t", kwargs.get('message'), "play"])
|
|
|
|
|
|
def instance():
|
|
if whereis_exe('espeak'):
|
|
return EspeakTextToSpeech()
|
|
elif whereis_exe('flite'):
|
|
return FliteTextToSpeech()
|
|
return TTS()
|