voxygen.py 1.1 KB

123456789101112131415161718192021222324252627282930313233343536
  1. import logging
  2. from core import AudioPlayer
  3. from tts import TTS
  4. logging.basicConfig()
  5. logger = logging.getLogger("kalliope")
  6. class Voxygen(TTS):
  7. TTS_VOICE_DEFAULT = "Michel"
  8. TTS_LANGUAGES_DEFAULT = "default"
  9. TTS_URL = "https://www.voxygen.fr/sites/all/modules/voxygen_voices/assets/proxy/index.php"
  10. def __init__(self):
  11. TTS.__init__(self)
  12. def say(self, words=None, voice=TTS_VOICE_DEFAULT, language=TTS_LANGUAGES_DEFAULT, cache=True):
  13. self.say_generic(cache, language, words, self.get_audio_voxygen, AudioPlayer.PLAYER_MP3, AudioPlayer.AUDIO_MP3_FREQUENCY, voice)
  14. def get_audio_voxygen(self, **kwargs):
  15. words = kwargs.get('words', None)
  16. cache = kwargs.get('cache', None)
  17. file_path = kwargs.get('file_path', None)
  18. voice = kwargs.get('voice', None)
  19. payload = Voxygen.get_payload(voice, words)
  20. return TTS.get_audio(file_path, cache, payload, self.TTS_URL)
  21. @staticmethod
  22. def get_payload(voice, words):
  23. return {
  24. "method": "redirect",
  25. "text": words,
  26. "voice": voice
  27. }