pico2wave.py 843 B

12345678910111213141516171819202122232425262728
  1. import subprocess
  2. from core import AudioPlayer
  3. from tts import TTS
  4. import logging
  5. import sys
  6. logging.basicConfig()
  7. logger = logging.getLogger("kalliope")
  8. class Pico2wave(TTS):
  9. TTS_LANGUAGES_DEFAULT = 'fr-FR'
  10. def __init__(self):
  11. TTS.__init__(self, AudioPlayer.PLAYER_WAV)
  12. def say(self, words=None, language=TTS_LANGUAGES_DEFAULT, cache=False):
  13. self.say_generic(cache, language, words, self.get_audio_pico2wave, AudioPlayer.PLAYER_WAV, AudioPlayer.AUDIO_MP3_FREQUENCY)
  14. @staticmethod
  15. def get_audio_pico2wave(**kwargs):
  16. language = kwargs.get('language', None)
  17. words = kwargs.get('words', None)
  18. file_path = kwargs.get('file_path', None)
  19. subprocess.check_output(["/usr/bin/pico2wave", "-l=%s" % language, "-w=%s" % file_path, words], stderr=sys.stderr)
  20. return True