Another Toaster that no longer makes toast
Some times an antique toaster shows up at your place and it is necessary to find a new use for the appliance. Since the subject is a toaster, the obvious solution is to make an audio playing web accessible thingy. :)
For this build, 3 different audio function were planned:
- using the toaster as a bluetooth speaker
- web accessible Text-to-Speech
- another Muttonchop audio player
First things first though, slap together some hardware.
Although I never actually plugged in this toaster to test it, I was told that it no longer worked. excellent! :)
The basic circuitry
It would probably be better to keep all the cabling "stereo" and mix all audio to mono in software, but that would require dealing with audio in Linux. brutal.
TAKE IT APART!
Back when things were built to last, they were built to be taken apart. We, as sentient beings, owe it to the creators to take apart their devices and see how they were built, so that we might continue the improvement of the creation long after the original creator is gone.
Hot Glue is hella sweet
Since I wanted to minimize the possibility of an electrical short when attaching circuitry to the metal frame, a bit of *manual* 3D printing adhered the amp to a plastic sheet with some hot glue stand-offs.
Stuff it all in
The original power cord was little more than copper wrapped with cloth fiber. As much as I would have liked to reuse that fire-hazard, a custom made extension cord brought power to the guts of the toaster. The CHIP, speaker, and amp were glued to the inside of the frame.
Toaster Lever Up
The wire for the speaker was attached to the toasters heating element switch that is activated when the toaster lever is pushed down.
Toaster Lever Down
Pressing the lever down lowers a metal plate which closes the contacts for the speaker. The tactile feedback from the switch is absolutely delightful. If I ever want to make the toaster be quiet, I simply need to lift the toast lever.
The original speaker for this project wasn't working well with the amp and a suitable replacement soon arrived. At the same time, I purchased filter to hopefully eliminate random static and noise caused by using the same power supply for the amp and audio source. For some reason, the filter cut out all audio. Oh well, on the bright side, random artifacts are the personality of a computer.
Mostly put back together
With the exception of a pile of screws, almost all of the toaster was returned to its reflective glory.
Playing AudioFor some reason, all 3 of my audio playing goals were met. crazy!
Bluetooth SpeakerConfiguring a C.H.I.P. to be a bluetooth speaker takes a lot of patients, or one can use a script to automate configuring a CHIP to be a bluetooth speaker.
Unfortunately, the script requires PulseAudio, and it was necessary to soil the CHIP in order to accomplish this audio task. On the bright side: Bluetooth Toaster!
For the most part, installing Muttonchop was a straight forward process of:
- installing the vala compiler
- copying the muttonchop source code
- compiling the source code for running headless
- editing the config file
Once Muttonchop was set up, I loaded the Conan Soundtrack onto the toaster. When the toaster is connected to my home network, I can use the browser on any of my devices to play Riders of Doom/Riddle of Steel. Booyah!
Internetty Thingy Text-to-Speech
The CHIP isn't the most powerful computer, but it is more than capable of running espeak TTS. Combine this with a bit of pub/sub communication using the Paho MQTT library for Python, and in a few lines of code, an MQTT message can be escaped and converted to text.
Enter the Python
import sys, subprocess, pipes
import paho.mqtt.client as mqtt
def on_message(client, userdata, message):
#get the payload as a string
payload = str(message.payload)
#quote the words of the payload
words = pipes.quote(payload)
cmd = "espeak "+words
mclient = mqtt.Client()
mclient.on_message = on_message
mclient.connect("test.mosquitto.org", 1883, 60)
Under normal circumstances, I would have used a broker local to my network to handle the sup/pub for this toaster, but in a epic display of self loathing, I have decided to allow others to send messages to the toaster. :)