Closed bill-orange closed 7 years ago
@bill-orange not sure why the sleep function doesn't work. I will try that out now.
Also I am not sure I understand what policies you are talking about. Can you clarify?
Thanks. I tried inserting the time.sleep(3) several places. All resulted in failure. The only place it would not fail would be usless, outside of the function blocks. I was able to add pauses in the speech by adding " . . . . . . . . . . . . ." at the end of sentences. A rather unsatisfying solution.
Regarding policies, I should have said roles. See I am so confused, I don't even know what to call it. I am referring to:
Perhaps the two questions are related. Maybe for time.sleep to work more roles thanbasic need to be added.
@bill-orange Regarding roles and permissions some good documentation is: Intro Permission Model
To add breaks we can use the SSML tags
An example would be:
'outputSpeech': { 'ssml': '<speak>Testing <break time="2ms"/> Reprompt</speak>', 'type': 'SSML' },
I think that would be the best way to add breaks and slow down the speech.
Sorry to be a pest.
Your solution makes perfect sense, much more elegant than time.sleep. I would still like to know why time. sleep does not work. Upon loading main.py into lambda, lambda does not throw up any errors. When I run the script by invoking Alexa, it just says " there was a problem with this skills request".
I tried adding
Can you tell me how to apply SSML break to this speech string taken from Main.py? Apparently, I did not understand exactly how your example applied to this situation. speech_output = ("Let's test your skills with FlashCards. I will ask you " + str(GAME_LENGTH) + " questions, try to get as many right" + "as you can. Just say the answer")
Any ideas on the time.sleep thing? Developing my own code without understanding what's happening here will bit me in the butt.
P.S. Considering that I am a Chemical Engineer it is embarrassing how many elements I got wrong.
No problem @bill-orange
Below should be a good example. I haven't tried it, but I think it should work. Not sure why time.sleep doesn't work, but might be that that function is not interpreted by alexa.
speech_output = ("Let's test your skills with FlashCards. I will ask you " +
str(GAME_LENGTH) + " questions, try to get as many right" +
"as you can. Just say the answer.<break time="2ms"/> Let's begin. ")
speech_output = "<speak>" + speech_output + reprompt_text + "</speak>"
def build_speechlet_response(title, output, reprompt_text, should_end_session):
return {
'outputSpeech': {
'type': 'SSML',
'ssml': output
},
'card': {
'type': 'Simple',
'title': title,
'content': output
},
'reprompt': {
'outputSpeech': {
'type': 'PlainText',
'text': reprompt_text
}
},
'shouldEndSession': should_end_session
}
I really don't mean to be a pest but. I had no luck with that either. Regarding this line:
speech_output = ("Let's test your skills with FlashCards. I will ask you " +
str(GAME_LENGTH) + " questions, try to get as many right" +
"as you can. Just say the answer.
The interpreter would not buy the quotes within quotes so I changed the quotes around the 2ms to single quotes to get past a syntax error. It would not accept single quotes around 'as you ... .... begin' with double quotes around the 2ms either.
I tried leaving the speech_output alone to see if 'def build_speechlet_response' would run with the existing speech output. Nope. There were no interpreter error but when I tried to run with Alexa, I got my old friend " there was a problem with this skills request". I looked up other examples on-line and your syntax looks just fine. I have to I idea what the problem is. Can you have a look, if time permits. Here's the modified main.py:
https://1drv.ms/f/s!AmXKqAwyCrbxhqYDB6KCwnTRHCmhDQ
On the line giving the final score, I fixed a typo "yog got" should be "you got" Also, I added some small graphics 108 X 108 and 512 X 512 for the last step in the skills setup. They are not all I had hoped for, but they look nice on my phone's Alexa app. I shot them myself this morning so you can use them if you want without any troublesome 'rights' issues.
Thanks in advance.
Bill
@bill-orange
I have been looking over why there is an error and I think it has to do with the quotes. I would suggest trying to escape the quotes
speech_output = ("Let's test your skills with FlashCards. I will ask you " +
str(GAME_LENGTH) + " questions, try to get as many right" +
"as you can. Just say the answer.<break time=\"2ms\"/> Let's begin. ")
speech_output = "<speak>" + speech_output + reprompt_text + "</speak>"
I found this in the an example on from @BrownDogTech Alexa_math_dog
speech_output = "<speak>" \
+ text + \
"<break time=\"500ms\" />" \
"Would you like to begin a game? " \
"</speak>"
Yes, escaping the quotes works but program still worked when tested by the within the Lamba site but failed on execution. I made these additional changes:
Delete:
speech_output = "
Revise:
def build_speechlet_response(title, output, reprompt_text, should_end_session): return { 'outputSpeech': { 'type': 'SSML',
'ssml': "<speak>" + output + "</speak>"
},
'card': {
'type': 'Simple',
'title': title,
'content': output
},
'reprompt': {
'outputSpeech': {
'type': 'PlainText',
'text': reprompt_text
}
},
'shouldEndSession': should_end_session
}
I will add pauses to man.py where it seems appropriate to me and send you the link. Where I also need the pauses is for a skill I am working on for reading weather underground’s json string on my personal weather station and reciting the weather in my backyard. Right now the report all “runs together” and is difficult to understand.
Thanks for the help. This stuff is tricky and the documentation is so scattered it is difficult for a layman to sort out.
Bill
From: Venkat Malladi Sent: Sunday, February 19, 2017 12:38 PM To: vsmalladi/alexa-skills-kit-python Cc: bill-orange ; Mention Subject: Re: [vsmalladi/alexa-skills-kit-python] speech runs together (#1)
@bill-orange
I have been looking over why there is an error and I think it has to do with the quotes. I would suggest trying to escape the quotes
speech_output = ("Let's test your skills with FlashCards. I will ask you " + str(GAME_LENGTH) + " questions, try to get as many right" + "as you can. Just say the answer.<break time=\"2ms\"/> Let's begin. ")
speech_output = "
speech_output = "<speak>" \
+ text + \
"<break time=\"500ms\" />" \
"Would you like to begin a game? " \
"</speak>"
— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub, or mute the thread.
@bill-orange sounds great. Ya if You can provide a pull request of your changes I can update in this example.
Will do. It still needs a bit more work, however. I just noticed that the break= expression is showing up in the text displayed in the card.
Well hopefully I got the pull request posted correctly. This is the first time I have been a contributor on GitHub.
There is still one problem I noticed with main.py which I did not attempt to fix. Yes / No responses crash the program. The easiest way to test this is to answer either yes or no when asked to identify a symbol. I looked over the code for yes /no intents and I could not find anything that even looked suspicious,
I will take a look at the yes / no problem later. On the pull request is deleted the text line on the card. Even without it, their is a lot of user feedback.
I am closing this comment. When I ave something on the yes know thing I will open a new issues.
I may use this quiz as a template to make a Dr Who quiz challenge :)
@bill-orange Thanks for the pull request I will look over this weekend and merge. Ya let me know what you discover about the yes/no problem.
thanks. Maybe you can find a better solution to the “card” issue with SSML prior to merging the pull request.
From: Venkat Malladi Sent: Friday, February 24, 2017 6:41 AM To: vsmalladi/alexa-skills-kit-python Cc: bill-orange ; Mention Subject: Re: [vsmalladi/alexa-skills-kit-python] speech runs together (#1)
@bill-orange Thanks for the pull request I will look over this weekend and merge. Ya let me know what you discover about the yes/no problem.
— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub, or mute the thread.
I am using your example to learn to build Alexa skill. There are not many Python examples. I got your example up and running with little difficulty. I do have a couple of questions.
Speech runs together in spots, particularly at the end where the score is given. I tried adding import time and time.sleep(3) in the appropriate places to main.py but this generates the vague error of "a problem with this skill" How could adding the simple sleep function possibly not work and cause a failure of the main.py code?
I am really confused on the purpose and use of policies. Can you point me to a resource that would explain it?