SpeakDirective doesn't create correct audio src directive
jallwork opened this issue · 1 comments
I'm submitting a...
[x ] Bug report
Expected Behaviour
I'm using ask_sdk_model.services.directive > SpeakDirective
to generate progressive response using <audio src
I expect SpeakDirective to create the directive:
{'object_type': 'VoicePlayer.Speak',
'speech': '<audio src="https://s3.amazonaws.com/16b...a7f"/>'}
Current Behavior
It splits audio and src and creates the following directive:
{'object_type': 'VoicePlayer.Speak',
'speech': '<audio '
'src="https://s3.amazonaws.com/16b...a7f"/>'}
This gets reported by the cloudwatch as Directive not valid.:
2021-11-18T20:32:15.796+00:00 [INFO] 2021-11-18T20:32:15.796Z 8fa4ebf4-24d5-40f3-bff8-286071fcf136 {'directive': {'object_type': 'VoicePlayer.Speak',
2021-11-18T20:32:15.796+00:00 'speech': '<audio '
2021-11-18T20:32:15.796+00:00 'src="https://s3.amazonaws.com/16bfd...a7f"/>'},
2021-11-18T20:32:15.796+00:00 'header': {'request_id': 'amzn1.echo-api.request.28628c2e-804f-4191-a031-7ef8dac9a7dd'}}
2021-11-18T20:32:15.974+00:00 [ERROR] 2021-11-18T20:32:15.971Z 8fa4ebf4-24d5-40f3-bff8-286071fcf136 Directive not valid.
Possible Solution
// Not required, but suggest a fix/reason for the bug,
// or ideas how to implement the addition or change
Steps to Reproduce (for bugs)
// Provide a self-contained, concise snippet of code
// For more complex issues provide a repo with the smallest sample that reproduces the bug
// Including business logic or unrelated code makes diagnosis more difficult
Start a new python Alexa Hosted Skill
Save a valid mp3 file to s3 bucket
Change the lambda code to:
- Add this at the top of the code:
from utils import create_presigned_url
from ask_sdk_model.services.directive import (
SendDirectiveRequest, Header, SpeakDirective)
from ask_sdk_core.skill_builder import CustomSkillBuilder
from ask_sdk_core.api_client import DefaultApiClient
sb = CustomSkillBuilder(api_client=DefaultApiClient())
def get_progressive_response(handler_input):
# type: (HandlerInput) -> None
request_id_holder = handler_input.request_envelope.request.request_id
directive_header = Header(request_id=request_id_holder)
url = create_presigned_url('Media/rmrudolph.mp3').replace("&","&")
speech='<audio src="'+ url + '"/>'
logger.info(speech)
speech = SpeakDirective(speech)
logger.info("SPEAK DIRECTIVE")
logger.info(speech)
directive_request = SendDirectiveRequest(
header=directive_header, directive=speech)
logger.info(directive_request)
directive_service_client = handler_input.service_client_factory.get_directive_service()
directive_service_client.enqueue(directive_request)
return
- Comment out the line at the end:
#sb = SkillBuilder()
- Change the Launch request handler to add the following (replacing the mp3 file name with what you saved) before the ‘return:
url = create_presigned_url('Media/rmrudolph.mp3').replace("&","&")
get_progressive_response(handler_input)
Save and Deploy
Look at error messages in Cloudwatch
Apologies if I've got it wrong...
Context
Your Environment
- ASK SDK for Python used: x.x.x
- Operating System and version:
Python version info
- Python version used for development:
Closing this as it looks like a more complicated issue. Alexa team is looking into the problem.