This project demonstrates how to create a voice–controlled smart plug using natural language processing (NLP), speech recognition, and a relay.
Text Classifier in PictoBlox
We will use the PictoBlox Machine Learning environment for creating the text classifier.
Follow the steps to create the model:
- Open PictoBlox and the Machine Learning Environment.
- Click on Open Project and add import the following project file: Alexa
- Find the Alexa project in the list and open it to get the workspace of the text classifier.
- There will be 2 classes – Lights On and Lights Off. Each class has some phases added corresponding to the action. You can add a few phases yourself.
- Click on Train Model to train the model.
- Once trained, you can check the model in the Testing tab. Add a phase and check if it provides the right sentiment.
Note: If the model is not giving the desired results, then add more phases until the model is good.
- Click on the Export Model to create the blocks for the project.
- Test the block with some input text.
The bulb is connected to the smart plug which is controlled with a relay.
If the relay is ON, the smart switch gets ON, turning on the light. The relay has the following connections:
- GND Pin connected to GND of the Quarky Expansion Board.
- VCC Pin connected to VCC of the Quarky Expansion Board.
- Signal Pin connected to Servo 4 of the Quarky Expansion Board.
The logic is the following – The Speech Recognition extension converts speech to text, which is then fed into the text classifier block. The text classifier block provides sentiment information, which is used to control the light via the relay.