소스 검색

[Doc] Docstrings of TTS package

monf 8 년 전
부모
커밋
6372ea8c5b
2개의 변경된 파일30개의 추가작업 그리고 25개의 파일을 삭제
  1. 7 4
      core/TTS/TTSLauncher.py
  2. 23 21
      core/TTS/TTSModule.py

+ 7 - 4
core/TTS/TTSLauncher.py

@@ -13,10 +13,13 @@ class TTSLauncher(object):
     @classmethod
     def get_tts(cls, tts):
         """
-        Return an instance of a TTS module from the name of this module
-        :param tts: TTS model
-        :type tts: Tts
-        :return: TTS module instance
+            Return an instance of a TTS module from the name of this module
+            :param tts: TTS model
+            :type tts: Tts
+            :return: TTS module instance
+
+            .. seealso::  TTS
+            .. warnings:: Class Method and Public
         """
         logger.debug("get TTS module \"%s\" with parameters %s" % (tts.name, tts.parameters))
         return Utils.get_dynamic_class_instantiation("tts", tts.name.capitalize(), tts.parameters)

+ 23 - 21
core/TTS/TTSModule.py

@@ -24,13 +24,14 @@ class FailToLoadSoundFile(Exception):
 
 
 class TTSModule(object):
-
-    def __init__(self, **kwargs):
-        """
+    """
         Mother class of TTS module. Handle:
         - Cache: call cache object to create file, delete file, check if file exist
         - Player: call the default player to play the generated file
-        """
+    """
+
+    def __init__(self, **kwargs):
+
         # set parameter from what we receive from the settings
         self.cache = kwargs.get('cache', False)
         self.language = kwargs.get('language', None)
@@ -53,17 +54,19 @@ class TTSModule(object):
 
     def play_audio(self):
         """
-        Play the audio file
-        :return:
+            Play the audio file
         """
         Mplayer.play(self.file_path)
 
     def generate_and_play(self, words, generate_audio_function_from_child=None):
         """
-        Generate an audio file from <words> if not already in cache and call the Player to play it
-        :param words: Sentence text from which we want to generate an audio file
-        :param generate_audio_function_from_child: The child function to generate a file if necessary
-        :return:
+            Generate an audio file from <words> if not already in cache and call the Player to play it
+            :param words: Sentence text from which we want to generate an audio file
+            :type words: String
+            :param generate_audio_function_from_child: The child function to generate a file if necessary
+            :type generate_audio_function_from_child; Callback function
+
+            .. raises:: TtsGenerateAudioFunctionNotFound
         """
         if generate_audio_function_from_child is None:
             raise TtsGenerateAudioFunctionNotFound
@@ -89,15 +92,15 @@ class TTSModule(object):
 
     def _get_path_to_store_audio(self):
         """
-        Get a sentence (a text) an return the full path of the file
+            Get a sentence (a text) an return the full path of the file
 
-        Path syntax:
-        </path/in/settings>/<tts.name>/tts.parameter["language"]/tts.parameter["voice"]/<md5_of_sentence.tts
+            Path syntax:
+            </path/in/settings>/<tts.name>/tts.parameter["language"]/tts.parameter["voice"]/<md5_of_sentence.tts
 
-        E.g:
-        /tmp/kalliope/voxygene/fr/abcd12345.tts
+            E.g:
+            /tmp/kalliope/voxygene/fr/abcd12345.tts
 
-        :return: path String
+            :return: path String
         """
         md5 = self.generate_md5_from_words(self.words)+".tts"
         self.base_cache_path = os.path.join(self.settings.cache_path, self.tts_caller_name, self.language, self.voice)
@@ -109,9 +112,9 @@ class TTSModule(object):
     @staticmethod
     def generate_md5_from_words(words):
         """
-        Generate a md5 hash from received text
-        :param words: Text to convert into md5 hash
-        :return: String md5 hash from the received words
+            Generate a md5 hash from received text
+            :param words: Text to convert into md5 hash
+            :return: String md5 hash from the received words
         """
         if isinstance(words, unicode):
             words = words.encode('utf-8')
@@ -119,8 +122,7 @@ class TTSModule(object):
 
     def is_file_already_in_cache(self):
         """
-        Return true if the file to generate has already been generated before
-        :return:
+            Return true if the file to generate has already been generated before
         """
         # generate sub folder
         FileManager.create_directory(self.base_cache_path)