Using Amazon Alexa device as LMS player

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • philippe_44
    Senior Member
    • May 2008
    • 9344

    #31
    Originally posted by malted
    I will.

    Fiddling around with lms and the echo as a player, the latency is really a disaster. It's around 60 seconds here. I tried to reencode the lms stream.mp3 with ffmpeg to use HLS.
    Code:
    ffmpeg -fflags nobuffer -flags low_delay  -i http://192.168.1.78:9000/stream.mp3?player=Echo  -acodec aac -strict -2 -hls_time 1  -hls_wrap 6 -f hls stream.m3u8
    I hoped to decrease the buffer in the echo device through chunking, but it doesn't really work. I'm even considing streaming wav/pcm to the echo device, because the buffer could be set to a certain size and would be filled quickly with very few wav seconds... does anybody have a idea, how to reduce latency?
    I think the only option is to starve the player with pseudo-real-time stream. I did an Alexa version of my bridges and I discussed that with Paul. It works as well, but for me, the real showstopper is that you can’t really control it from LMS. We did not find a way for commands (play/pause/stop) to be relayed to a skill. So I can easily do the audio data ´starving’ but I don’t feel it will be a great solution anyway. In addition, in the tests I’ve done you can sent pcm to Alexa (in a wav or in an audio/L16 format) so the pseudo real-time will not be accurate. My bridge can decompress any stream on the fly to à given format amongst plain pcm, flac or mp3 so the only viable option would be mp3 at CBR and use that for throughput estimation ... not great anyway
    LMS 8.2 on Odroid-C4 - SqueezeAMP!, 5xRadio, 5xBoom, 2xDuet, 1xTouch, 1xSB3. Sonos PLAY:3, PLAY:5, Marantz NR1603, Foobar2000, ShairPortW, 2xChromecast Audio, Chromecast v1 and v2, Squeezelite on Pi, Yamaha WX-010, AppleTV 4, Airport Express, GGMM E5, RivaArena 1 & 3

    Comment

    • malted
      Junior Member
      • Mar 2019
      • 3

      #32
      Originally posted by philippe_44
      I think the only option is to starve the player with pseudo-real-time stream. I did an Alexa version of my bridges and I discussed that with Paul. It works as well, but for me, the real showstopper is that you can’t really control it from LMS. We did not find a way for commands (play/pause/stop) to be relayed to a skill. So I can easily do the audio data ´starving’ but I don’t feel it will be a great solution anyway. In addition, in the tests I’ve done you can sent pcm to Alexa (in a wav or in an audio/L16 format) so the pseudo real-time will not be accurate. My bridge can decompress any stream on the fly to à given format amongst plain pcm, flac or mp3 so the only viable option would be mp3 at CBR and use that for throughput estimation ... not great anyway
      I tried to feed a rtmp:// stream to alexa, but that doesn't work, even though exoplayer should support that. Maybe a skill using webrtc could stream the low latency stream to the alexa, but all in all, I concur, that it won't be a great solution.
      The plex alexa skill managed to stream audio from a local streaming server, and that my media alexa - service also achieved to get an echo device to be a functional media player. I wonder how they did that. Do they just play a serverip/stream.mp3 and just restart that, whenever they get a control?

      I would have a look at these skills, but I'm out of ideas, how to pull them from the app store or extract them any other way...

      Comment

      • philippe_44
        Senior Member
        • May 2008
        • 9344

        #33
        Originally posted by malted
        I tried to feed a rtmp:// stream to alexa, but that doesn't work, even though exoplayer should support that. Maybe a skill using webrtc could stream the low latency stream to the alexa, but all in all, I concur, that it won't be a great solution.
        The plex alexa skill managed to stream audio from a local streaming server, and that my media alexa - service also achieved to get an echo device to be a functional media player. I wonder how they did that. Do they just play a serverip/stream.mp3 and just restart that, whenever they get a control?

        I would have a look at these skills, but I'm out of ideas, how to pull them from the app store or extract them any other way...
        Unfortunately I cannot help a lot here. I have no "skill" expertise. I can create the stream in any sort of format, make is a pull from from a webserver or a push using RTP and then proxy LMS commands (play/pause/stop/volume) to almost anything, but that "anything" is unknown to me when Alexa is concerned. Paul thinks that there is no way to directly send commands to an Alexa and/or a skill.
        LMS 8.2 on Odroid-C4 - SqueezeAMP!, 5xRadio, 5xBoom, 2xDuet, 1xTouch, 1xSB3. Sonos PLAY:3, PLAY:5, Marantz NR1603, Foobar2000, ShairPortW, 2xChromecast Audio, Chromecast v1 and v2, Squeezelite on Pi, Yamaha WX-010, AppleTV 4, Airport Express, GGMM E5, RivaArena 1 & 3

        Comment

        • Paul Webster
          Senior Member
          • Apr 2005
          • 10347

          #34
          I see that Alexa devices should also support HLS.
          This document lists codecs, containers, streaming formats, and playlists, that your product should support to provide a familiar Alexa experience to your customers. Living Docu...

          and that WAV/PCM is supposed to be supported but the document does not specify how it can be delivered.
          Paul Webster
          Author of "Now Playing" plugins covering Radio France (FIP etc), PlanetRadio (Bauer - Kiss, Absolute, Scala, JazzFM etc), KCRW, ABC Australia and CBC/Radio-Canada
          and, via the extra "Radio Now Playing" plugin lots more - see https://forums.slimdevices.com/showt...Playing-plugin

          Comment

          • Paul Webster
            Senior Member
            • Apr 2005
            • 10347

            #35
            Originally posted by malted
            The plex alexa skill managed to stream audio from a local streaming server, and that my media alexa - service also achieved to get an echo device to be a functional media player. I wonder how they did that. Do they just play a serverip/stream.mp3 and just restart that, whenever they get a control?
            As far as I could see, neither of those Skills allow the music to be initiated by anything other than voice to Alexa.

            Having the media server (e.g.) stop/next/pause once the stream is already playing does work ... but for it to be actioned in a short time after the request is issued requires the Alexa device to have a small amount in its local buffer otherwise it can take tens of seconds for the action to take effect.
            One way to achieve that is to starve the device by sending it just enough data to have 1-2 seconds in the buffer.

            If the published Skills manage to do that in a different way then it would be interesting to find out.
            Paul Webster
            Author of "Now Playing" plugins covering Radio France (FIP etc), PlanetRadio (Bauer - Kiss, Absolute, Scala, JazzFM etc), KCRW, ABC Australia and CBC/Radio-Canada
            and, via the extra "Radio Now Playing" plugin lots more - see https://forums.slimdevices.com/showt...Playing-plugin

            Comment

            • Paul Webster
              Senior Member
              • Apr 2005
              • 10347

              #36
              Another way to have the Alexa device play the tracks would be harder to do but might provide a better user experience - especially for those with display-enabled Alexa devices (such as Echo Dot).
              Rather than telling the device to play a continuous stream, it could be told to play one song at a time. Then each song can have its own metadata (including cover art) sent to the device as a playlist item.

              There is a callback from Alexa when the currently playing song is "nearly finished" (not defined when that is) so that the next item can be added to the device playlist.
              As far as I can see ... it still does not allow the skill to proactively tell the device what to do.

              Would need LMS plugin to tell the Skill (via an alternative route) the details of the next song including (part of) a URL that the Alexa device will have to access to get the contents of the song. NOTE: I think there is a good chance that this URL would have to be HTTPS with a certificate that can be verified.

              In this case I think the flow would be ...
              User asks device to start playing (something)
              Amazon calls Skill
              Skill gives Alexa device an initial URL to play (via response to Amazon which then passes it to Alexa device)
              Parallel events:
              - As song comes towards the end (undefined when that is) ... Amazon calls Skill to say Playback nearly finished

              - LMS plugin calls Skill via different route to give details of next item in playlist (ideally before "Playback nearly finished" event above)
              Skill adds next item to the device playlist

              Clearly more work - and if the only benefit is that Alexa devices with a display can see what song is playing then it is of limited use (my guess is that not many devices with screens are installed compared to those without screens).

              If this technique resulted in the web-based alexa.amazon.com showing the media controls ... then it would have the benefit of being able to have LMS tell the device to change volume or skip to next track (through some highly dubious and unsupported emulation of Alexa browser interface).
              Paul Webster
              Author of "Now Playing" plugins covering Radio France (FIP etc), PlanetRadio (Bauer - Kiss, Absolute, Scala, JazzFM etc), KCRW, ABC Australia and CBC/Radio-Canada
              and, via the extra "Radio Now Playing" plugin lots more - see https://forums.slimdevices.com/showt...Playing-plugin

              Comment

              • Paul Webster
                Senior Member
                • Apr 2005
                • 10347

                #37
                I have had confirmation from Amazon that the media controls are not available via web interface (and hence, unofficial API) for Skills in general but only for specific ones like Spotify.
                They suggested I ask for an enhancement.
                So I have.
                You could add your support at
                Paul Webster
                Author of "Now Playing" plugins covering Radio France (FIP etc), PlanetRadio (Bauer - Kiss, Absolute, Scala, JazzFM etc), KCRW, ABC Australia and CBC/Radio-Canada
                and, via the extra "Radio Now Playing" plugin lots more - see https://forums.slimdevices.com/showt...Playing-plugin

                Comment

                • buck
                  Member
                  • Sep 2005
                  • 43

                  #38
                  Originally posted by Paul Webster
                  I added a vote and a comment to the suggestion. Thanks for working on this, Paul
                  "I have come to chew bubblegum and kick ass. And I am all out of bubblegum" - "Rowdy" Roddy Piper as John Nada in "They Live"

                  Squeezebox v.1(x2)(retired),Squeezebox v.2, Squeezebox Boom, Squeezebox Controller, Squeezebox v.3, I use OrangeSqueeze for Android on Samsung Galaxy S8

                  Comment

                  • NFLnut
                    Senior Member
                    • Sep 2007
                    • 386

                    #39
                    Originally posted by Paul Webster
                    Rather than telling the device to play a continuous stream, it could be told to play one song at a time. Then each song can have its own metadata (including cover art) sent to the device as a playlist item.

                    There is a callback from Alexa when the currently playing song is "nearly finished" (not defined when that is) so that the next item can be added to the device playlist.
                    As far as I can see ... it still does not allow the skill to proactively tell the device what to do.

                    Would need LMS plugin to tell the Skill (via an alternative route) the details of the next song including (part of) a URL that the Alexa device will have to access to get the contents of the song. NOTE: I think there is a good chance that this URL would have to be HTTPS with a certificate that can be verified.


                    I wonder if Spicefly Sugarcube with it's MusicIP auto queue would work in this case. (S-SC is the one LMS plugin that I could not live without.)

                    Comment

                    • NFLnut
                      Senior Member
                      • Sep 2007
                      • 386

                      #40
                      .. and I voted too.

                      Comment

                      • compoman
                        Junior Member
                        • Nov 2019
                        • 8

                        #41
                        I guess it depends on the skill

                        Hello all,

                        I was thinking along the same line and the only satisfactory solution I could come up with, was to develop a skill, that controls the Echo device playing the music from the LMS. Unfortunately as stated above, Apps like iPeng won't work, but I was thinking along a good skill to do the trick.

                        This skill is now ready for testing. You can find more information on how to set it up and on the voice commands at



                        or in German at



                        If you want to test it, register at



                        You will get a 4 week premium package immediately. If you send me an email to

                        [email protected]

                        and let me know, that you want to test the service, I will setup your account with 6 month premium and will add you to the list of testers, so you get access to the Alexa skill. Please send me feedback or a short info about your experiences also to

                        [email protected]

                        Have fun

                        Ingo

                        Comment

                        • castalla
                          Senior Member
                          • Feb 2008
                          • 6572

                          #42
                          Originally posted by compoman
                          Hello all,

                          I was thinking along the same line and the only satisfactory solution I could come up with, was to develop a skill, that controls the Echo device playing the music from the LMS. Unfortunately as stated above, Apps like iPeng won't work, but I was thinking along a good skill to do the trick.

                          This skill is now ready for testing. You can find more information on how to set it up and on the voice commands at



                          or in German at



                          If you want to test it, register at



                          You will get a 4 week premium package immediately. If you send me an email to

                          [email protected]

                          and let me know, that you want to test the service, I will setup your account with 6 month premium and will add you to the list of testers, so you get access to the Alexa skill. Please send me feedback or a short info about your experiences also to

                          [email protected]

                          Have fun

                          Ingo
                          Oh-oh ... requires opening ports on your router! Not for me, thanks.
                          ------------------------------------------------------------------------------------

                          Comment

                          • compoman
                            Junior Member
                            • Nov 2019
                            • 8

                            #43
                            Originally posted by castalla
                            Oh-oh ... requires opening ports on your router! Not for me, thanks.
                            Thank you for the answer,

                            I have one question - it requires opening one port and that only for triggering the plugin on the music server to fetch a new command from the Roomskills server using a secure protocol.

                            Mmh, I would be interested to understand where you see the problem?

                            Regards

                            Ingo

                            Comment

                            • castalla
                              Senior Member
                              • Feb 2008
                              • 6572

                              #44
                              Originally posted by compoman
                              Thank you for the answer,

                              I have one question - it requires opening one port and that only for triggering the plugin on the music server to fetch a new command from the Roomskills server using a secure protocol.

                              Mmh, I would be interested to understand where you see the problem?

                              Regards

                              Ingo
                              Much too complicated to setup and configure (compared to MyMedia skill)
                              ------------------------------------------------------------------------------------

                              Comment

                              • compoman
                                Junior Member
                                • Nov 2019
                                • 8

                                #45
                                Originally posted by castalla
                                Much too complicated to setup and configure (compared to MyMedia skill)
                                Good point - I will work on that.

                                Comment

                                Working...