alexa-pi / AlexaPi

Alexa client for all your devices! # No active development. PRs welcome # consider https://github.com/respeaker/avs instead
MIT License
1.33k stars 396 forks source link

Alexa lifecycle proposal #170

Closed y-nk closed 7 years ago

y-nk commented 7 years ago

Hi,

First of all, thanks for the amazing work. I kickstarted my project in seconds. As I work with Alexa for quite some time now, I found myself struggling while dealing with the indicate callbacks provided in devices ; sure enough, I made my own implementation to fit the need of our project, but still.

I'd like to propose to make steps of talking with Alexa more granular, not only by giving booleans as arguments, but by providing hooks reflecting the real lifecycle of a conversation with Alexa. The terminology I chose in my proposal is toward something more human-like in the lifecycle, which make sens to me as we deal with a VUi.

For now, and as far as i traced it, here's the current lifecycle :

~ setup ~

1. indicate_success
2. indicate_playback True
3. indicate_playback False
4. after_setup

~ user says Alexa ~

5. indicate_playback True
6. indicate_playback False

7. indicate_recording True

~ user queries ~

8. indicate_recording False

9. indicate_processing True
10. indicate_processing False

11a. indicate_playback True
12a. indicate_playback False

11b. ø (if null response)
11c. indidate_failure (if 204)

I would propose the following :

~ setup ~

1. indicate_setup_success
2. indicate_greeting_start
3. indicate_greeting_end

~ user says Alexa ~

5. indicate_awaking_start
6. indicate_awaking_end

7. indicate_listening_start

~ user queries ~

8. indicate_listening_end

9. indicate_processing_start
10. indicate_processing_end

11a. indicate_answering_start
12a. indicate_answering_end

11b. indicate_muting_start (if null response)
12b. indicate_muting_end

11c. indicate_crashing_start (if 204)
12c. indicate_crashing_end

This is totally open to discussion, and in case of approval I would do my best to fill a proper PR with documentation.

Thanks, J.

renekliment commented 7 years ago

Hey! Thanks for the idea. From a brief look it makes sense. Have you thought about how this would work with #52?

Couple of observations:

y-nk commented 7 years ago

I do agree crashing might be the best verb to define "a dead end because of server failure".

You are right about muting, maybe then idling would be better ?

I do understand your concern about the other terms ; maybe it's all about finding the best verbs ; as for "awaking", my team and I described this phase that way because the real amazon echo does not speak while turning awake, rather emit a beep sound.

I'd be glad to implement it the way of #52 if more people like it this way ; I honestly didn't look at it before, and proposed simple callback fashion by personal preference.

renekliment commented 7 years ago

@ynk Any work on AlexaPi is appreciated, so if you like to, knock yourself out :smile:

y-nk commented 7 years ago

@renekliment thank you. I've done a lot of work during the 2 last days. I'll submit my PR tonight hopefully.