Explorar o código

PEP8 + PEP 257

nico %!s(int64=8) %!d(string=hai) anos
pai
achega
a871a43aab

+ 6 - 6
kalliope.py

@@ -19,9 +19,9 @@ logger = logging.getLogger("kalliope")
 
 def signal_handler(signal, frame):
     """
-        Used to catch a keyboard signal like Ctrl+C in order to kill the kalliope program
-        :param signal: signal handler
-        :param frame: execution frame
+    Used to catch a keyboard signal like Ctrl+C in order to kill the kalliope program
+    :param signal: signal handler
+    :param frame: execution frame
     """
     print "\n"
     Utils.print_info("Ctrl+C pressed. Killing Kalliope")
@@ -33,7 +33,7 @@ ACTION_LIST = ["start", "gui"]
 
 def main():
     """
-        Entry point of Kalliope program
+    Entry point of Kalliope program
     """
     # create arguments
     parser = argparse.ArgumentParser(description='Kalliope')
@@ -92,8 +92,8 @@ def main():
 
 def configure_logging(debug=None):
     """
-        Prepare log folder in current home directory
-        :param debug: If true, set the lof level to debug
+    Prepare log folder in current home directory
+    :param debug: If true, set the lof level to debug
     """
     logger = logging.getLogger("kalliope")
     logger.propagate = False

+ 5 - 7
stt/apiai/Apiai.py

@@ -8,10 +8,9 @@ class Apiai(OrderListener):
 
     def __init__(self, callback=None, **kwargs):
         """
-            Start recording the microphone and analyse audio with Apiai api
-            :param callback: The callback function to call to send the text
-            :param kwargs:
-
+        Start recording the microphone and analyse audio with Apiai api
+        :param callback: The callback function to call to send the text
+        :param kwargs:
         """
         OrderListener.__init__(self)
 
@@ -43,10 +42,9 @@ class Apiai(OrderListener):
             Utils.print_danger("Could not request results from Apiai Speech Recognition service; {0}".format(e))
 
     def _analyse_audio(self, audio):
-
         """
-            Confirm the audio exists annd run it in a Callback
-            :param audio: the captured audio
+        Confirm the audio exists annd run it in a Callback
+        :param audio: the captured audio
         """
         # if self.main_controller is not None:
         #     self.main_controller.analyse_order(audio)

+ 5 - 6
stt/bing/Bing.py

@@ -8,13 +8,12 @@ class Bing(OrderListener):
 
     def __init__(self, callback=None, **kwargs):
         """
-            Start recording the microphone and analyse audio with Bing api
-            :param callback: The callback function to call to send the text
-            :param kwargs:
+        Start recording the microphone and analyse audio with Bing api
+        :param callback: The callback function to call to send the text
+        :param kwargs:
         """
         OrderListener.__init__(self)
 
-
         # callback function to call after the translation speech/tex
         self.callback = callback
         # obtain audio from the microphone
@@ -43,8 +42,8 @@ class Bing(OrderListener):
 
     def _analyse_audio(self, audio):
         """
-            Confirm the audio exists annd run it in a Callback
-            :param audio: the captured audio
+        Confirm the audio exists annd run it in a Callback
+        :param audio: the captured audio
         """
 
         # if self.main_controller is not None:

+ 5 - 5
stt/google/Google.py

@@ -8,9 +8,9 @@ class Google(OrderListener):
 
     def __init__(self, callback=None, **kwargs):
         """
-            Start recording the microphone and analyse audio with google api
-            :param callback: The callback function to call to send the text
-            :param kwargs:
+        Start recording the microphone and analyse audio with google api
+        :param callback: The callback function to call to send the text
+        :param kwargs:
         """
         OrderListener.__init__(self)
 
@@ -45,8 +45,8 @@ class Google(OrderListener):
 
     def _analyse_audio(self, audio):
         """
-            Confirm the audio exists annd run it in a Callback
-            :param audio: the captured audio
+        Confirm the audio exists annd run it in a Callback
+        :param audio: the captured audio
         """
 
         # if self.main_controller is not None:

+ 6 - 12
stt/houndify/Houndify.py

@@ -8,9 +8,9 @@ class Houndify(OrderListener):
 
     def __init__(self, callback=None, **kwargs):
         """
-            Start recording the microphone and analyse audio with Houndify api
-            :param callback: The callback function to call to send the text
-            :param kwargs:
+        Start recording the microphone and analyse audio with Houndify api
+        :param callback: The callback function to call to send the text
+        :param kwargs:
         """
         OrderListener.__init__(self)
 
@@ -26,14 +26,13 @@ class Houndify(OrderListener):
 
         # recognize speech using Houndify Speech Recognition
         try:
-
-
-            id = kwargs.get('client_id', None)
+            client_id = kwargs.get('client_id', None)
             key = kwargs.get('key', None)
             language = kwargs.get('language', "en-US")
             show_all = kwargs.get('show_all', False)
 
-            captured_audio = r.recognize_houndify(audio, client_id=id, client_key=key, language=language, show_all=show_all)
+            captured_audio = r.recognize_houndify(audio, client_id=client_id, client_key=key,
+                                                  language=language, show_all=show_all)
             Utils.print_success("Houndify Speech Recognition thinks you said %s" % captured_audio)
             self._analyse_audio(captured_audio)
 
@@ -52,8 +51,3 @@ class Houndify(OrderListener):
         #     self.main_controller.analyse_order(audio)
         if self.callback is not None:
             self.callback(audio)
-
-
-
-
-

+ 5 - 5
stt/wit/Wit.py

@@ -8,9 +8,9 @@ class Wit(OrderListener):
 
     def __init__(self, callback=None, **kwargs):
         """
-            Start recording the microphone and analyse audio with Wit.ai api
-            :param callback: The callback function to call to send the text
-            :param kwargs:
+        Start recording the microphone and analyse audio with Wit.ai api
+        :param callback: The callback function to call to send the text
+        :param kwargs:
         """
         OrderListener.__init__(self)
 
@@ -40,8 +40,8 @@ class Wit(OrderListener):
 
     def _analyse_audio(self, audio):
         """
-            Confirm the audio exists annd run it in a Callback
-            :param audio: the captured audio
+        Confirm the audio exists annd run it in a Callback
+        :param audio: the captured audio
         """
 
         # if self.main_controller is not None:

+ 0 - 1
trigger/snowboy/snowboydecoder.py

@@ -114,7 +114,6 @@ class HotwordDetector(object):
             frames_per_buffer=2048,
             stream_callback=audio_callback)
 
-
     def start(self, detected_callback=play_audio_file,
               interrupt_check=lambda: False,
               sleep_time=0.03):

+ 12 - 18
tts/acapela/acapela.py

@@ -22,22 +22,18 @@ class Acapela(TTSModule):
 
     def say(self, words):
         """
-
-            :param words: The sentence to say
+        :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
 
-            Generic method used as a Callback in TTSModule
-                - must provided the audio file and write it on the disk
-
-            .. raises:: FailToLoadSoundFile
+        .. raises:: FailToLoadSoundFile
         """
-
-
         # Prepare payload
         payload = self.get_payload()
 
@@ -61,10 +57,9 @@ class Acapela(TTSModule):
 
     def get_payload(self):
         """
+        Generic method used load the payload used to acces the remote api
 
-            Generic method used load the payload used to acces the remote api
-
-            :return: Payload to use to access the remote api
+        :return: Payload to use to access the remote api
         """
 
         return {
@@ -77,15 +72,14 @@ class Acapela(TTSModule):
 
     @staticmethod
     def get_audio_link(url, payload, timeout_expected=TTS_TIMEOUT_SEC):
-
         """
-            Return the audio link
+        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
+        :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)

+ 6 - 10
tts/googletts/googletts.py

@@ -17,22 +17,19 @@ class Googletts(TTSModule):
 
     def say(self, words):
         """
-
-            :param words: The sentence to say
+        :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
 
-            Generic method used as a Callback in TTSModule
-                - must provided the audio file and write it on the disk
-
-            .. raises:: FailToLoadSoundFile
+        .. raises:: FailToLoadSoundFile
         """
 
-
         # Prepare payload
         payload = self.get_payload()
 
@@ -53,10 +50,9 @@ class Googletts(TTSModule):
 
     def get_payload(self):
         """
+        Generic method used load the payload used to access the remote api
 
-            Generic method used load the payload used to acces the remote api
-
-            :return: Payload to use to access the remote api
+        :return: Payload to use to access the remote api
         """
 
         return {

+ 4 - 8
tts/pico2wave/pico2wave.py

@@ -16,19 +16,17 @@ class Pico2wave(TTSModule):
 
     def say(self, words):
         """
-
-            :param words: The sentence to say
+        :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
 
-            Generic method used as a Callback in TTSModule
-                - must provided the audio file and write it on the disk
-
-            .. raises:: FailToLoadSoundFile
+        .. raises:: FailToLoadSoundFile
         """
 
         pico2wave_exec_path = ["/usr/bin/pico2wave"]
@@ -49,5 +47,3 @@ class Pico2wave(TTSModule):
 
         # remove the extension .wav
         os.rename(tmp_path, self.file_path)
-
-

+ 6 - 11
tts/voicerss/voicerss.py

@@ -17,21 +17,18 @@ class Voicerss(TTSModule):
 
     def say(self, words):
         """
-
-            :param words: The sentence to say
+        :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
 
-            Generic method used as a Callback in TTSModule
-                - must provided the audio file and write it on the disk
-
-            .. raises:: FailToLoadSoundFile
+        .. raises:: FailToLoadSoundFile
         """
-
         # Prepare payload
         payload = self.get_payload()
 
@@ -52,10 +49,9 @@ class Voicerss(TTSModule):
 
     def get_payload(self):
         """
+        Generic method used load the payload used to acces the remote api
 
-            Generic method used load the payload used to acces the remote api
-
-            :return: Payload to use to access the remote api
+        :return: Payload to use to access the remote api
         """
 
         return {
@@ -63,4 +59,3 @@ class Voicerss(TTSModule):
             "hl": self.language,
             "c": "mp3"
         }
-

+ 8 - 11
tts/voxygen/voxygen.py

@@ -3,7 +3,7 @@ import logging
 import requests
 
 from core import FileManager
-from core.TTS.TTSModule import TTSModule, MissingTTSParameter, FailToLoadSoundFile
+from core.TTS.TTSModule import TTSModule, MissingTTSParameter
 
 logging.basicConfig()
 logger = logging.getLogger("kalliope")
@@ -25,19 +25,17 @@ class Voxygen(TTSModule):
 
     def say(self, words):
         """
-
-            :param words: The sentence to say
+        :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
 
-            Generic method used as a Callback in TTSModule
-                - must provided the audio file and write it on the disk
-
-            .. raises:: FailToLoadSoundFile
+        .. raises:: FailToLoadSoundFile
         """
 
         payload = self.get_payload(self.voice, self.words)
@@ -59,14 +57,13 @@ class Voxygen(TTSModule):
     @staticmethod
     def get_payload(voice, words):
         """
+        Generic method used load the payload used to access the remote api
 
-            Generic method used load the payload used to acces the remote api
-
-            :return: Payload to use to access the remote api
+        :return: Payload to use to access the remote api
         """
 
         return {
             "method": "redirect",
             "text": words,
             "voice": voice
-        }
+        }