コード例 #1
0
ファイル: osx.py プロジェクト: kowo-zahl/Naomi
 def __init__(self, *args, **kwargs):
     if not platform.system().lower() == 'darwin':
         raise ImportError('Invalid platform!')
     if not diagnose.check_executable(EXECUTABLE):
         raise ImportError("Executable '%s' not found!" % EXECUTABLE)
     plugin.TTSPlugin.__init__(self, *args, **kwargs)
     self._logger = logging.getLogger(__name__)
     self._logger.warning("This TTS plugin doesn't have multilanguage " +
                          "support!")
コード例 #2
0
ファイル: flite.py プロジェクト: kowo-zahl/Naomi
import logging
import os
import pipes
import subprocess
import tempfile
import unittest
from naomi import diagnose
from naomi import plugin
from naomi import profile

EXECUTABLE = 'flite'

if not diagnose.check_executable(EXECUTABLE):
    raise unittest.SkipTest(
        "Skipping flite-tts, executable '{}' not found".format(EXECUTABLE))
    raise ImportError("Executable '%s' not found!" % EXECUTABLE)


class FliteTTSPlugin(plugin.TTSPlugin):
    """
    Uses the flite speech synthesizer
    Requires flite to be available
    """
    def __init__(self, *args, **kwargs):
        plugin.TTSPlugin.__init__(self, *args, **kwargs)

        self._logger = logging.getLogger(__name__)
        self._logger.warning(
            "This TTS plugin doesn't have multilanguage support!")
        voice = profile.get(['flite-tts', 'voice'], 'slt')
        self._logger.info("Voice: {}".format(voice))
コード例 #3
0
ファイル: julius.py プロジェクト: kowo-zahl/Naomi
import re
import subprocess
import tempfile
import unittest
from collections import OrderedDict
from naomi import diagnose
from naomi import plugin
from naomi import profile
from . import juliusvocab

if not diagnose.check_executable('julius'):
    raise unittest.SkipTest("Skipping julius, 'julius' executable not found")
    raise ImportError("Can't find julius executable")

RE_SENTENCE = re.compile(r'sentence(\d+): <s> (.+) </s>')


class JuliusSTTPlugin(plugin.STTPlugin):
    """
    A very basic Speech-to-Text engine using Julius.
    """
    def __init__(self, *args, **kwargs):
        plugin.STTPlugin.__init__(self, *args, **kwargs)

        vocabulary_path = self.compile_vocabulary(
            juliusvocab.compile_vocabulary)

        self._dfa_file = juliusvocab.get_dfa_path(vocabulary_path)
        self._dict_file = juliusvocab.get_dict_path(vocabulary_path)

        hmmdefs = profile.get(
コード例 #4
0
ファイル: espeak.py プロジェクト: TuxSeb/Naomi-1
import collections
import logging
import pipes
import re
import subprocess
import tempfile
from naomi import diagnose
from naomi import plugin

if not diagnose.check_executable('espeak'):
    raise ImportError("espeak executable not found!")

RE_PATTERN = re.compile(r'(?P<pty>\d+)\s+' + r'(?P<lang>[a-z-]+)\s+' +
                        r'(?P<gender>[MF-])\s+' +
                        r'(?P<name>[\w-]+)\s+\S+\s+' +
                        r'(?P<other>(?:\([a-z-]+\s+\d+\))*)')
RE_OTHER = re.compile(r'\((?P<lang>[a-z-]+)\s+(?P<pty>\d+)\)')

Voice = collections.namedtuple('Voice',
                               ['name', 'gender', 'priority', 'language'])


class EspeakTTSPlugin(plugin.TTSPlugin):
    """
    Uses the eSpeak speech synthesizer included in the Naomi disk image
    Requires espeak to be available
    """
    def __init__(self, *args, **kwargs):
        plugin.TTSPlugin.__init__(self, *args, **kwargs)

        self._logger = logging.getLogger(__name__)
コード例 #5
0
ファイル: festival.py プロジェクト: TuxSeb/Naomi-1
import logging
import pipes
import subprocess
import tempfile
from naomi import diagnose
from naomi import plugin

if not all(diagnose.check_executable(e) for e in ('text2wave', 'festival')):
    raise ImportError('Executables "text2wave" and/or  "festival" not found!')


class FestivalTTSPlugin(plugin.TTSPlugin):
    """
    Uses the festival speech synthesizer
    Requires festival (text2wave) to be available
    """
    def __init__(self, *args, **kwargs):
        plugin.TTSPlugin.__init__(self, *args, **kwargs)

        self._logger = logging.getLogger(__name__)

        available_voices = self.get_voices()
        if len(available_voices) == 0:
            raise ValueError('No voices available!')

        self._logger.warning("This TTS plugin doesn't have multilanguage " +
                             "support!")
        self._logger.info('Available voices: %s', ', '.join(available_voices))

        try:
            voice = self.profile['festival-tts']['voice']