question

James Tankersley avatar image
James Tankersley asked

Python and playing an audio file

developing in python I'd like to play an audio clip after the text speech here, I'd like a straightforward hello world type example of this.


  def handle(self, handler_input):
        # type: (HandlerInput) -> Response
        speak_output = utils.todays_saint_name()

        return (
            handler_input.response_builder
                .speak(speak_output)
                #I'd like to play an audio file here
                .response
        )
pythonaudio playback
10 |5000

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

1 Answer

James Tankersley avatar image
James Tankersley answered

I don't know if this is the right way but I figure it out. I was hoping there was just .audio() method provided by ask that I could just tack on but I couldn't find one so this is what I did in one of my helper functions.

 audio = '<audio src="{0}" />'.format(mp3)
                    text = 'Today\'s saint of the day is {saint_title} {saint_name}'.format(**saint).replace("NULL","")
                    response = text + audio
10 |5000

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.