nickpourazima / rotary-phone-audio-guestbook

Audio guestbook using an old rotary phone and a raspberry pi zero
MIT License
57 stars 15 forks source link

Rotary Phone Audio Guestbook

This project transforms a rotary phone into a voice recorder for use at special events (i.e. wedding audio guestbook, etc.).

image

Background

Inspired by my own upcoming wedding, I created a DIY solution for an audio guestbook using a rotary phone. With most online rentals charging exorbitant fees without offering custom voicemail options, I sought a more affordable and customizable solution. Here, I've detailed a guide on creating your own audio guestbook. If you have questions, don't hesitate to reach out.

Materials

Parts List | Part | Notes | Quantity | Cost | | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -------- | ------------ | | [rotary phone](https://www.ebay.com/b/Rotary-Dial-Telephone/38038/bn_55192308) | Estate/garage/yard sales are probably the best places to find once of these. Ideally one with a phone jack since we will be using these four wires extensively. | 1 | $0.00-$60.00 | | [raspberry pi zero](https://www.raspberrypi.com/products/raspberry-pi-zero/) | I didn't realize how hard these are to find these days. You can use any rpi or arduino style single-board computer but be aware of size constraints (i.e. must fit inside the rotary phone enclosure) | 1 | $9.99 | | [raspberry pi zero case](https://www.adafruit.com/product/3252) | Optional: added for protection. One of the cases on Amazon has a heat-sink cutout which might be nice for better heat dissapation since it will all be enclosed in the end. | 1 | $4.95 | | [micro SD card](https://a.co/d/1gb2zhC) | Any high capacity/throughput micro SD card that is rpi compatible | 1 | $8.99 | | [USB Audio Adapter](https://www.adafruit.com/product/1475) | Note: I removed the external plastic shell and directly soldered the wires instead of using the female 3.5mm receptacle. | 1 | $4.95 | | [USB OTG Host Cable - MicroB OTG male to A female](https://www.adafruit.com/product/1099) | | 1 | $2.50 | | --- | **--- If you don't want to solder anything ---** | --- | --- | | [3.5mm Male to Screw Terminal Connector](https://www.parts-express.com/3.5mm-Male-to-Screw-Terminal-Connector-090-110?quantity=1&utm_source=google&utm_medium=cpc&utm_campaign=18395892906&utm_content=145242146127&gadid=623430178298&gclid=CjwKCAiAioifBhAXEiwApzCztl7aVb18WP4hDxnlQUCHsb62oIcnduFCSCbn9LFkZovYTQdr6omb3RoCD_gQAvD_BwE) | Optional: can connect the handset cables directly to the USB audio interface via these screw terminals | 2 | $1.37 | | --- | **--- If running off a battery ---** | --- | --- | | [LiPo Battery](https://www.adafruit.com/product/2011) | Optional: maximize capacity based on what will fit within your rotary enclosure. | 1 | $12.50 | | [LiPo Shim](https://www.adafruit.com/product/3196) | Optional: if you plan to run this off a LiPo I would recommend something like this to interface with the rpi zero. | 1 | $9.95 | | [LiPo Charger](https://www.adafruit.com/product/1904) | Optional: for re-charging the LiPo. | 1 | $6.95 | | --- | **--- If replacing the built-it microphone ---** | --- | --- | | [LavMic](https://www.amazon.com/dp/B01N6P80OQ?ref=nb_sb_ss_w_as-reorder-t1_ypp_rep_k3_1_9&=&crid=15WZEWMZ17EM9&=&sprefix=saramonic) | Optional: if you'd like to replace the carbon microphone. This is an omnidirectional lavalier mic and outputs via a 3.5mm TRS | 1 | $24.95 |

Setup

Prepare Your Rotary Phone

Note: This is a crucial first step before using the software.

Download and Install the Custom Image

With your hardware ready, download the custom Raspberry Pi image provided, which has all necessary software pre-installed and pre-configured.

Configuration and Customization

Once your system is up and running, you will want to make adjustments to suit your specific setup, especially if your hardware differs or you have personal preferences for how the guestbook operates.

To ensure your settings are correctly applied, you can test audio playback and recording after making changes. For playback, you can use a sample WAV file and the aplay command. For recording, arecord can be used followed by aplay to play back the recorded audio.

This service ensures smooth operation without manual intervention every time your Raspberry Pi boots up. The service file is sym linked to the /etc/systemd/system directory. Manual control of the service is possible as it operates as any other .service entity. You can quickly check the status with journalctl -u audioGuestBook.service

Hardware

Wiring

Hook

Understanding Hook Types: Depending on your rotary phone model, the hook switch may be Normally Closed (NC) or Normally Open (NO). When the phone is on the hook:

To accommodate either type, you'll need to update the config.yaml with the appropriate hook type setting.

On-hook --> Open circuit (Value == 1) Off-hook --> Current flowing
image image
Rotary Phone Block Terminal Top-down view
image image

Phone Cord

image

Optional: Microphone Replacement

For improved sound quality, consider replacing the built-in carbon microphone.

I found the sound quality of the built-in mic on the rotary phone to be quite lacking in terms of amplitude, dynamic range and overall vocal quality. I tried boosting the gain from the digital (ALSA driver) side but this introduced an incredible amount of noise as expected. I then approached this from the analog domain and tried alternative circuitry to boost the sound quality based off this carbon-to-dynamic converter.

Might be worth a further investigation in the future since it retains the integrity of the original rotary phone.

My final attempt involved the introduction of some post-proceesing (see dev branch) to bandpass some of the freqs outside the speech domain and add some normalization. The processing was costly in terms of processing and power consumption/rendering time and I ultimately decided it was worth acquiring something that yielded a better capture right out the gate. Crap in, crap out - as they say in the sound recording industry.

To replace:

image

image

image

Software

audioInterface

audioGuestBook

Web Server

UPDATE:

As of release v1.0.2 the webserver has been updated with a modern interface using Tailwind CSS to ensure responsiveness and better visual clarity.

New features include:

Contributing

Development Setup

For contributors interested in working on the project and testing new features before cutting a release, here’s a brief guide:

Tailwind CSS Setup

Tailwind CSS is used for styling the web interface. To play around with the source code and style changes, you can use the following commands:

# Build Tailwind CSS
npx tailwindcss build -i static/css/tailwind.css -o static/css/output.css

To further optimize the CSS output for production:

# Minify CSS
npx postcss static/css/output.css > static/css/output.min.css
Syncing Files with Raspberry Pi

To upload changes from your local dev machine to the Raspberry Pi (Pi Zero or similar), you can use the following rsync command:

# Sync files with Pi
rsync -av --exclude-from='./rsync-exclude.txt' ${CWD}/rotary-phone-audio-guestbook admin@192.168.x.x:/home/admin
# Replace 192.168.x.x with the actual IP address of your Raspberry Pi.
Starting the Web Server in Development Mode

For testing the Flask-based web server on the Raspberry Pi:

# Start webserver on Raspberry Pi
flask --app webserver/server.py run -h 192.168.x.x -p 8080
Python dependencies

I've been using uv by @astral-sh, and love it! Would highly recommend as it is extremely fast and much more robust relative to pip.

pip3 install uv
uv pip install -r requirements.txt
#OR
uv pip install -r pyproject.toml

Alternatively, to directly run the main audioGuestBook script (this will pull necessary dependencies from pyproject.toml):

# Directly run audioGuestBook
uv run src/audioGuestBook.py

Generating an img for a release

I use RonR-RPi-image-utils, thank you to @scruss & @seamusdemora!

If you would like to create a full image for ease f deployment there's a deploy.sh script that I created which will run through this process. Edit the ENV VARS inside to point to your own local dev environment.

Alternatively, a manual run would look something like this:

sudo image-backup -i /mnt/rpizero_rotary_phone_audio_guestbook_v<insert_incremental_version_number_here>_imagebackup.img
md5sum /mnt/rpizero_rotary_phone_audio_guestbook_v<version number>_imagebackup.img

Note: for incremental backups (much faster) point to the existing img and run:

sudo image-backup /mnt/rpizero_rotary_phone_audio_guestbook_v<prior_version_number>_imagebackup.img

Debugging

To help with debugging the audioGuestBook service and the webserver, use these commands:

# Monitor the audioGuestBook service logs
journalctl -fu audioGuestBook.service
# OR
journalctl -fu audioGuestBookWebServer.service

Support

It's great to see this project growing, special thanks to @svartis, @jmdevita, and @Mevel!

If this code helped you or if you have some feedback, I'd be happy to hear about it! Feel like saying thanks? You can buy me a coffee☕.

Star History

Star History Chart