|
@@ -19,10 +19,10 @@ 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
|
|
|
- :return:
|
|
|
+ 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")
|
|
@@ -34,8 +34,11 @@ signal.signal(signal.SIGINT, signal_handler)
|
|
|
class ShellGui:
|
|
|
def __init__(self, brain=None):
|
|
|
"""
|
|
|
- Load a GUI in a shell console for testing TTS, STT and brain configuration
|
|
|
- :param brain:
|
|
|
+ Load a GUI in a shell console for testing TTS, STT and brain configuration
|
|
|
+ :param brain: The Brain object provided by the brain.yml
|
|
|
+ :type brain: Brain
|
|
|
+
|
|
|
+ .. seealso:: Brain
|
|
|
"""
|
|
|
# override brain
|
|
|
self.brain = brain
|
|
@@ -52,9 +55,8 @@ class ShellGui:
|
|
|
|
|
|
def show_main_menu(self):
|
|
|
"""
|
|
|
- Main menu of the shell UI.
|
|
|
- Provide a list of action the user can select to test his settings
|
|
|
- :return:
|
|
|
+ Main menu of the shell UI.
|
|
|
+ Provide a list of action the user can select to test his settings
|
|
|
"""
|
|
|
|
|
|
code, tag = self.d.menu("Test your Kalliope settings from this menu",
|
|
@@ -72,9 +74,8 @@ class ShellGui:
|
|
|
|
|
|
def show_stt_test_menu(self):
|
|
|
"""
|
|
|
- Show the list of available STT.
|
|
|
- Clicking on a STT will load the engine to catch the user audio and return a text
|
|
|
- :return:
|
|
|
+ Show the list of available STT.
|
|
|
+ Clicking on a STT will load the engine to catch the user audio and return a text
|
|
|
"""
|
|
|
# we get STT from settings
|
|
|
stt_list = self.settings.stts
|
|
@@ -97,11 +98,11 @@ class ShellGui:
|
|
|
|
|
|
def show_tts_test_menu(self, sentence_to_test=None):
|
|
|
"""
|
|
|
- A menu for testing text to speech
|
|
|
- - select a TTS engine to test
|
|
|
- - type a sentence
|
|
|
- - press ok and listen the generated audio from the typed text
|
|
|
- :return:
|
|
|
+ A menu for testing text to speech
|
|
|
+ - select a TTS engine to test
|
|
|
+ - type a sentence
|
|
|
+ - press ok and listen the generated audio from the typed text
|
|
|
+ :param sentence_to_test: the screen written sentence to test
|
|
|
"""
|
|
|
continue_bool = True
|
|
|
# if we don't have yet a sentence to test, we ask the user to type one
|
|
@@ -136,10 +137,9 @@ class ShellGui:
|
|
|
@staticmethod
|
|
|
def _run_tts_test(tts_name, sentence_to_test):
|
|
|
"""
|
|
|
- Call the TTS
|
|
|
- :param tts_name: Name of the TTS module to launch
|
|
|
- :param sentence_to_test: String text to send to the TTS engine
|
|
|
- :return:
|
|
|
+ Call the TTS
|
|
|
+ :param tts_name: Name of the TTS module to launch
|
|
|
+ :param sentence_to_test: String text to send to the TTS engine
|
|
|
"""
|
|
|
sentence_to_test = sentence_to_test.encode('utf-8')
|
|
|
tts_name = tts_name.encode('utf-8')
|
|
@@ -149,9 +149,10 @@ class ShellGui:
|
|
|
@staticmethod
|
|
|
def _get_choices_tuple_from_list(list_to_convert):
|
|
|
"""
|
|
|
- Return a list of tup that can be used in Dialog menu
|
|
|
- :param list_to_convert: List of object to convert into tuple
|
|
|
- :return:
|
|
|
+ Return a list of tup that can be used in Dialog menu
|
|
|
+ :param list_to_convert: List of object to convert into tuple
|
|
|
+ :return: List of choices
|
|
|
+ :rtype: List
|
|
|
"""
|
|
|
# create a list of tuple that can be used by the dialog menu
|
|
|
choices = list()
|
|
@@ -163,9 +164,9 @@ class ShellGui:
|
|
|
|
|
|
def callback_stt(self, audio):
|
|
|
"""
|
|
|
- Callback function called after the STT has finish his job
|
|
|
- Print the text of what the STT engine think we said on the screen
|
|
|
- :param audio: Text from the translated audio
|
|
|
+ Callback function called after the STT has finish his job
|
|
|
+ Print the text of what the STT engine think we said on the screen
|
|
|
+ :param audio: Text from the translated audio
|
|
|
"""
|
|
|
code = self.d.msgbox("The STT engine think you said:\n %s" % audio, width=50)
|
|
|
|
|
@@ -174,8 +175,7 @@ class ShellGui:
|
|
|
|
|
|
def show_synapses_test_menu(self):
|
|
|
"""
|
|
|
- Show a list of available synapse in the brain to run it directly
|
|
|
- :return:
|
|
|
+ Show a list of available synapse in the brain to run it directly
|
|
|
"""
|
|
|
|
|
|
# create a tuple for the list menu
|