Exemplo n.º 1
0
    def __init__(self, config=None, audio_player='default'):
        self.event_queue = queue.Queue()
        self.SpeechRecognizer = SpeechRecognizer(self)
        self.SpeechSynthesizer = SpeechSynthesizer(self)
        self.AudioPlayer = AudioPlayer(self, audio_player=audio_player)
        self.Speaker = Speaker(self)
        self.Alerts = Alerts(self)
        self.System = System(self)

        self.state_listener = AlexaStateListener()

        # put() will send audio to speech recognizer
        self.put = self.SpeechRecognizer.put

        # listen() will trigger SpeechRecognizer's Recognize event
        self.listen = self.SpeechRecognizer.Recognize

        self.done = False

        self.requests = requests.Session()

        self._configfile = config
        self._config = avs.config.load(configfile=config)

        self.last_activity = datetime.datetime.utcnow()
        self._ping_time = None
Exemplo n.º 2
0
    def __init__(self, config, audio):
        self.event_queue = queue.Queue()
        self.SpeechRecognizer = SpeechRecognizer(self)
        self.SpeechSynthesizer = SpeechSynthesizer(self)
        self.AudioPlayer = AudioPlayer(self)
        self.Speaker = Speaker(self)
        self.Alerts = Alerts(self)
        self.System = System(self)

        self.ready = threading.Event()
        self.done = threading.Event()

        self.audio = audio

        self.requests = requests.Session()

        self._config = config

        if ('host_url' not in self._config) or (not self._config['host_url']):
            self._config['host_url'] = 'avs-alexa-na.amazon.com'

        if self._config['host_url'] == 'dueros-h2.baidu.com':
            self._config['api'] = 'dcs/avs-compatible-v20160207'
            self._config[
                'refresh_url'] = 'https://openapi.baidu.com/oauth/2.0/token'
        else:
            self._config['api'] = 'v20160207'
            self._config[
                'refresh_url'] = 'https://api.amazon.com/auth/o2/token'

        self._last_activity = None
        self._ping_time = None
Exemplo n.º 3
0
    def __init__(self, config=None):
        self.event_queue = queue.Queue()
        self.SpeechRecognizer = SpeechRecognizer(self)
        self.SpeechSynthesizer = SpeechSynthesizer(self)
        self.AudioPlayer = AudioPlayer(self)
        self.Speaker = Speaker(self)
        self.Alerts = Alerts(self)
        self.System = System(self)

        self.state_listener = AlexaStateListener()

        # put() will send audio to speech recognizer
        self.put = self.SpeechRecognizer.put

        # listen() will trigger SpeechRecognizer's Recognize event
        self.listen = self.SpeechRecognizer.Recognize

        self.stop_listen = self.SpeechRecognizer.stop_listen

        self.done = False

        self.requests = requests.Session()

        self._configfile = config
        self._config = avs.config.load(configfile=config)

        if ('host_url' not in self._config) or (not self._config['host_url']):
            self._config['host_url'] = 'avs-alexa-na.amazon.com'

        if self._config['host_url'] == 'dueros-h2.baidu.com':
            self._config['api'] = 'dcs/avs-compatible-v20160207'
            self._config[
                'refresh_url'] = 'https://openapi.baidu.com/oauth/2.0/token'
        else:
            self._config['api'] = 'v20160207'
            self._config[
                'refresh_url'] = 'https://api.amazon.com/auth/o2/token'

        if 'port' not in self._config:
            self._config['port'] = 443

        if 'verify' not in self._config:
            self._config['verify'] = True

        self.last_activity = datetime.datetime.utcnow()
        self._ping_time = None