summaryrefslogtreecommitdiff
path: root/external/plyer/platforms/linux/tts.py
blob: 0a609e119a0073f0832d05435e7f56555146e995 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
import subprocess
from plyer.facades import TTS
from 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):
        subprocess.call(["flite", "-t", kwargs.get('message'), "play"])


def instance():
    if whereis_exe('espeak'):
        return EspeakTextToSpeech()
    elif whereis_exe('flite'):
        return FlitetextToSpeech()
    return TTS()