Intro: Voice Controlled Glasses With Magnifying Lens
Many professionals work for many hours looking at very small areas, such as surgeons, watchmakers, jewellery designers and so on. Most of the time theses professionals use some kind of magnification glasses that helps them to see better the area they are working with and other tiny items used on the job. There are many magnifiers that allow the professionals see better and the most common ones are the magnification glasses.
The devices that had magnifications lens on a form factor of a glass usually allow the professional to move the lens out of their eye sight, i.e. put aside the lens. However, in some scenarios touching the lens or the glass rim to move away the lens can contaminate the fingers. Also, it is cumbersome and can break the concentration of the professional.
Therefore, the goal of instructable is to automatically move the lens of a magnification glass using voice commands. We can do that using a raspberry pi, a servo, and the IBM's Watson Speech to Text to create a werable that help professionals keep their hands on the business while working.
Step 1: Components
The list of components for this instructable is:
1x Magnification lens glasses
1x Raspberry Pi Zero W Kit (Board, memory card, case, pins bar, OTG cable)
1x Power Pro 9g servo (SG90)
1x USB Microfone
1x Power Bank (5v 1A)
Also we need some extra supplies and tools: jumper cables, hot glue gun, power drill with a small bit, a piece of plastic bread bag tie, a small servo screw, an ice cream wooden stick and a nail file.
Step 2: Modifying the Glasse's Rim
The first task we got to do is remove the support of the lens. This support is on top of each "bar" that allows it to spin and move the lens. Take extra care to not break the plastic parts that connect the two supports.
Next we need to use the nail file to sand a little bit the two tubular supports ("bars"). This sanding is needed because there some very small plastic slots that prevent the lens' support to be completely free, i.e. move without any obstacle. Check the images that shows how the tubular supports should be after the sanding.
After the sanding choose one of the two tubular supports (I choose the left one) and create a small hole with the power drill and the small bit. Make sure that the hole can accommodate the screw that will latter be used to fix the servo.
Connect the two lens supports on the tubular support to their original spot. After that check if the support move the lens back and forth freely without any resistance. The next step is to use the ice scream stick to make the two lens move together. Use the hot glue to connect the lens taking care of NOT drip hot glue on the area where you turn the lens to remove them. There is just enough space to do that but without any margin for mistakes. Again, avoid gluing the lens to the support, since this mistake will prevent the user to change the focal lens that came with the glasses (I guess they have 5x, 15x and 25x magnification factors).
Now we must pin the servo. Use the screws and the two small plastic screws nuts so that you have the screw, one screw nut, the servo hole, another screw nut and the screw head. Check the images for a reference of the sequence. Finally attach the servo on the glasses bu fixing the screw on the hole drilled with the power drill.
Finally, use one of the bread bag wires to tie the tip of the plastic pinned to the servo with the center of the ice scream stick. Make sure the wire is stretched out, just like the last figure of this step shows.
Step 3: Setting Up the Raspberry Pi
In this step we need to setup the Raspberry Pi Zero. This is very strait forward and I recommend the following guide that uses the NOOBS software to write the Raspbian Operating System on the SD Card:
After setting up the Raspian make sure you can access it via WiFi using the remote terminal and the SSH software. You need to configure the WiFi networking by changing the /etc/wpa_supplicant/wpa_supplicant.conf file manually to insert the network's name (SSID) and the password.
Connect the OTG cable on the Raspberry Pi port and connect the USB microphone on the other end. You need to setup the ALSA software to make sure you can use the microphone. Watch the following video to see how to setup the mic. on the RPI:
After making sure you Raspberry Pi is ready its is time to connect the wires from the computer's GPIO pins to the servo. Connect a red cable to the 5V pin (the second one of the firs column) of the RPI to the middle connection of the servo. Connect a black cable to ground pin on the Raspberry (the second of on the third column) to the most dark wire of the servo (usually a dark brown). Finally, connect a yellow cable in the pin number 4 of the raspberry to the yellowish/orangle port of the servo. Check the image of this setup for the pinout setup.
Step 4: Getting the Watson Speech to Text Scredentials
In this step we are going to get an access key to the Waton Speech to Text service. This service allow us to give the voice commands "up" to lift the lens and "down" to make them go back to the original position. The following link has more information about this service, including the languages it supports:
To request a key to use the STT (Speech To Text) I recommend follow this video:
Make sure that after you setup the account and created a STT service you have a password and username, since we are going to use those on the next steps.
Step 5: Coding the Servo in Python and Then STT in NodeJS
The last step of this instructable is the software we need to write. We will divide it in two programs: a python script that make the servo go up and go down and a nodejs script that will capture the audio, send it to the STT service and check for the command ("up" or "dow") to call the respective python scritp.
The Raspian operating system already has a Python version. So we just need to instal the GIOP dependency:
$ pip install gpio
Next we code two script files, one to make the servo go up (s_sobe.py) and another to make the servo go down (s_desce.py). The files areavalable to download in this step. Make sure to test the correct servo movement based on the position of the servo and the size of the wire that connect the tip of the servo with the stick glued into the len's support.
The next step is the nodejs script that connects to the Watson STT service. First, install nodejs using the follwing command:
$ sudo apt install nodejs
This link lead to a nice tutorial about instaling NodeJS in the Raspberry Pi:
Next insert your STT credentials (username and password) in the config.js. The next step is to install all the application's depencies listed on the package.json file using the following commando:
$ npm install
Finally, run the app.js program:
$ sudo node app.js
To simplify the STT use we employ a dependecy called TJBot, which is from a robot with the same name. Check the following link to get more information about this dependecy: