|
@@ -4,13 +4,20 @@ from core.OrderListener import OrderListener
|
|
|
|
|
|
class Google(OrderListener):
|
|
|
|
|
|
- def __init__(self, main_controller=None, **kwargs):
|
|
|
- OrderListener.__init__(self, main_controller)
|
|
|
+ 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:
|
|
|
+ """
|
|
|
+ OrderListener.__init__(self)
|
|
|
|
|
|
"""
|
|
|
Start recording the microphone
|
|
|
:return:
|
|
|
"""
|
|
|
+ # callback function to call after the translation speech/tex
|
|
|
+ self.callback = callback
|
|
|
# obtain audio from the microphone
|
|
|
r = sr.Recognizer()
|
|
|
with sr.Microphone() as source:
|
|
@@ -39,5 +46,7 @@ class Google(OrderListener):
|
|
|
print("Could not request results from Google Speech Recognition service; {0}".format(e))
|
|
|
|
|
|
def _analyse_audio(self, audio):
|
|
|
- if self.main_controller is not None:
|
|
|
- self.main_controller.analyse_order(audio)
|
|
|
+ # if self.main_controller is not None:
|
|
|
+ # self.main_controller.analyse_order(audio)
|
|
|
+ if self.callback is not None:
|
|
|
+ self.callback(audio)
|