Hackster is hosting Hackster Holidays, Ep. 6: Livestream & Giveaway Drawing. Watch previous episodes or stream live on Monday!Stream Hackster Holidays, Ep. 6 on Monday!
Roman Sydorenko
Published © MIT

Bluplayer

Alexa-powered player that allows to control your Bluesound Hi-Fi system with the voice.

AdvancedProtipOver 3 days2,180
Bluplayer

Things used in this project

Hardware components

Bluesound Pulse
×1
Raspberry Pi 2 Model B
Raspberry Pi 2 Model B
×1

Software apps and online services

bluplayer.net

Story

Read more

Code

EchoListener

C#
The main part of the BluPlayer that is responsible for interaction with voice commands is EchoListener. Here is simplified version of that class.
    public class EchoListener : IDisposable
    {
        private string _amazonUserId;
        private Uri _serviceUri;
        private HttpClient _client;
        private JavaScriptSerializer _serializer;
        private Guid _prevIntentId;

        public event Action<string> IntentReceived; 

        public EchoListener(Uri serviceUri, string amazonUserId)
        {
            _amazonUserId = amazonUserId;
            _serviceUri = serviceUri;
            _serializer = new JavaScriptSerializer();
        }

        public void StartListen()
        {
            //...
        }

        public void StopListen()
        {
          //...
        }

        private void Pool()
        {
            var task = _client.PostAsync(_serviceUri, new StringContent(_amazonUserId));
            //...
        }
        
        //...
   }

Credits

Roman Sydorenko

Roman Sydorenko

1 project • 1 follower

Comments