Browse Source

[Doc] Docstrings of TTS package

monf 8 năm trước cách đây
mục cha
commit
e60d2a8524

+ 30 - 0
tts/acapela/acapela.py

@@ -21,10 +21,22 @@ class Acapela(TTSModule):
             raise MissingTTSParameter("voice parameter is required by the Acapela TTS")
 
     def say(self, words):
+        """
+
+            :param words: The sentence to say
+        """
 
         self.generate_and_play(words, self._generate_audio_file)
 
     def _generate_audio_file(self):
+        """
+
+            Generic method used as a Callback in TTSModule
+                - must provided the audio file and write it on the disk
+
+            .. raises:: FailToLoadSoundFile
+        """
+
 
         # Prepare payload
         payload = self.get_payload()
@@ -48,6 +60,13 @@ class Acapela(TTSModule):
         FileManager.write_in_file(self.file_path, r.content)
 
     def get_payload(self):
+        """
+
+            Generic method used load the payload used to acces the remote api
+
+            :return: Payload to use to access the remote api
+        """
+
         return {
             "MyLanguages": self.language,
             "MySelectedVoice": self.voice,
@@ -58,6 +77,17 @@ class Acapela(TTSModule):
 
     @staticmethod
     def get_audio_link(url, payload, timeout_expected=TTS_TIMEOUT_SEC):
+
+        """
+            Return the audio link
+
+            :param url: the url to access
+            :param payload: the payload to use to acces the remote api
+            :param timeout_expected: timeout before the post request is cancel
+            :return: the audio link
+            :rtype: String
+        """
+
         r = requests.post(url, payload, timeout=timeout_expected)
         data = r.content
         return re.search("(?P<url>https?://[^\s]+).mp3", data).group(0)

+ 19 - 0
tts/googletts/googletts.py

@@ -16,10 +16,22 @@ class Googletts(TTSModule):
         super(Googletts, self).__init__(**kwargs)
 
     def say(self, words):
+        """
+
+            :param words: The sentence to say
+        """
 
         self.generate_and_play(words, self._generate_audio_file)
 
     def _generate_audio_file(self):
+        """
+
+            Generic method used as a Callback in TTSModule
+                - must provided the audio file and write it on the disk
+
+            .. raises:: FailToLoadSoundFile
+        """
+
 
         # Prepare payload
         payload = self.get_payload()
@@ -40,6 +52,13 @@ class Googletts(TTSModule):
         FileManager.write_in_file(self.file_path, r.content)
 
     def get_payload(self):
+        """
+
+            Generic method used load the payload used to acces the remote api
+
+            :return: Payload to use to access the remote api
+        """
+
         return {
             "q": self.words,
             "tl": self.language,

+ 12 - 0
tts/pico2wave/pico2wave.py

@@ -15,10 +15,22 @@ class Pico2wave(TTSModule):
         super(Pico2wave, self).__init__(**kwargs)
 
     def say(self, words):
+        """
+
+            :param words: The sentence to say
+        """
 
         self.generate_and_play(words, self._generate_audio_file)
 
     def _generate_audio_file(self):
+        """
+
+            Generic method used as a Callback in TTSModule
+                - must provided the audio file and write it on the disk
+
+            .. raises:: FailToLoadSoundFile
+        """
+
         pico2wave_exec_path = ["/usr/bin/pico2wave"]
 
         # pico2wave needs that the file path ends with .wav

+ 18 - 0
tts/voicerss/voicerss.py

@@ -16,10 +16,21 @@ class Voicerss(TTSModule):
         super(Voicerss, self).__init__(**kwargs)
 
     def say(self, words):
+        """
+
+            :param words: The sentence to say
+        """
 
         self.generate_and_play(words, self._generate_audio_file)
 
     def _generate_audio_file(self):
+        """
+
+            Generic method used as a Callback in TTSModule
+                - must provided the audio file and write it on the disk
+
+            .. raises:: FailToLoadSoundFile
+        """
 
         # Prepare payload
         payload = self.get_payload()
@@ -40,6 +51,13 @@ class Voicerss(TTSModule):
         FileManager.write_in_file(self.file_path, r.content)
 
     def get_payload(self):
+        """
+
+            Generic method used load the payload used to acces the remote api
+
+            :return: Payload to use to access the remote api
+        """
+
         return {
             "src": self.words,
             "hl": self.language,

+ 20 - 0
tts/voxygen/voxygen.py

@@ -24,9 +24,22 @@ class Voxygen(TTSModule):
             raise MissingTTSParameter("voice parameter is required by the Voxygen TTS")
 
     def say(self, words):
+        """
+
+            :param words: The sentence to say
+        """
+
         self.generate_and_play(words, self._generate_audio_file)
 
     def _generate_audio_file(self):
+        """
+
+            Generic method used as a Callback in TTSModule
+                - must provided the audio file and write it on the disk
+
+            .. raises:: FailToLoadSoundFile
+        """
+
         payload = self.get_payload(self.voice, self.words)
 
         # getting the mp3
@@ -45,6 +58,13 @@ class Voxygen(TTSModule):
 
     @staticmethod
     def get_payload(voice, words):
+        """
+
+            Generic method used load the payload used to acces the remote api
+
+            :return: Payload to use to access the remote api
+        """
+
         return {
             "method": "redirect",
             "text": words,