Эх сурвалжийг харах

Add tts settings + fix all tts

Unknown 8 жил өмнө
parent
commit
a239cd43bb

+ 3 - 1
core/AudioPlayer.py

@@ -36,7 +36,8 @@ class AudioPlayer:
             audio_buffer = audio_buffer
 
         audio_frequency = audio_frequency
-        pygame.mixer.init(audio_frequency, audio_size, audio_channel, audio_buffer)
+        pygame.mixer.pre_init(audio_frequency, audio_size, audio_channel, audio_buffer)
+        pygame.mixer.init()
 
     def play_audio(self, music_file):
         try:
@@ -61,4 +62,5 @@ class AudioPlayer:
         pygame.mixer.music.play()
         while pygame.mixer.music.get_busy():
             clock.tick(20)
+        pygame.mixer.quit()
         return

+ 10 - 0
settings.yml

@@ -53,6 +53,16 @@ text_to_speech:
       language: "fr"
       voice: "Emma"
       cache: True
+  - acapela:
+      language: "sonid15"
+      voice: "Manon"
+      cache: True
+  - googletts:
+      language: "fr"
+      cache: True
+  - voicerss:
+      language: "fr-fr"
+      cache: True
 
 # Trigger engine configuration
 # Available engine are:

+ 6 - 2
tts/TTS.py

@@ -5,7 +5,6 @@ import logging
 import os
 import requests
 import sys
-import re
 from core import FileManager
 
 logging.basicConfig()
@@ -25,7 +24,12 @@ class TTS:
     def say_generic(self, cache, language, words, get_audio_specific, audio_type, audio_frequency, voice=None):
         file_path = self.cache.get_audio_file_cache_path(words, language, voice)
 
-        if get_audio_specific(language, words, file_path, cache, voice):
+        if voice is None:
+            return_code = get_audio_specific(language, words, file_path, cache)
+        else:
+            return_code = get_audio_specific(language, words, file_path, cache, voice)
+
+        if return_code:
             self.play_audio(file_path, audio_type, audio_frequency, cache)
 
     @staticmethod

+ 2 - 2
tts/voxygen/voxygen.py

@@ -20,10 +20,10 @@ class Voxygen(TTS):
     def say(self, words=None, voice=TTS_VOICE_DEFAULT, language=TTS_LANGUAGES_DEFAULT, cache=True):
         self.say_generic(cache, language, words, self.get_audio_voxygen, AudioPlayer.PLAYER_MP3, AudioPlayer.AUDIO_MP3_FREQUENCY, voice)
 
-    def get_audio_voxygen(self, voice, words, file_path, cache):
+    def get_audio_voxygen(self, language, words, file_path, cache, voice):
         payload = {
             "method": "redirect",
             "text": words,
             "voice": voice
         }
-        return self.get_audio(file_path, cache, payload, self.TTS_URL, self.TTS_CONTENT_TYPE, self.TTS_TIMEOUT_SEC)
+        return self.get_audio(file_path, cache, payload, self.TTS_URL, self.TTS_CONTENT_TYPE, self.TTS_TIMEOUT_SEC)