From Sound To Action: Build A DIY Sound-Activated Device With Google Teachable Machine

Liked this post? Share with others!

In this article, we delve into the integration of Google’s Teachable Machine AI model with spectrograms to recognize sounds and trigger specific actions using the IndusBoard. The AI model, running on a phone or laptop, identifies particular sounds and communicates with the IndusBoard, which then executes predefined tasks based on the recognized sound.

For instance, when the AI model recognizes a command like “hello, turn on the light,” it sends a signal to the IndusBoard, which can activate an LED on pin 33. This LED can be connected to a relay module to control home lighting. Such a system can be applied in various fields, including detecting the presence of animals in forests, identifying bird species, or diagnosing faults in engines and motors through sound analysis.

Understanding the Spectrogram

To utilize this system effectively, it’s crucial to understand what a spectrogram is and how it facilitates sound recognition.

What is a Spectrogram?

A spectrogram is a visual representation that shows how the spectrum of frequencies in a sound signal varies over time. The x-axis represents time, the y-axis represents frequency, and the color intensity indicates the amplitude (or power) of the frequencies at each time point.

How Does a Spectrogram Recognize Sound?

  1. Sound Wave Capture:
    • Sound waves are captured using a microphone, which converts the acoustic signal into an electrical signal.
  2. Digitization:
    • The electrical signal is digitized by an analog-to-digital converter (ADC), creating a digital representation of the sound wave.
  3. Short-Time Fourier Transform (STFT):
    • The digitized signal is divided into overlapping segments, each of which is transformed from the time domain to the frequency domain using STFT. This produces a series of frequency spectra, one for each segment.
  4. Spectrogram Generation:
    • The frequency spectra are arranged sequentially to form the spectrogram. The intensity or color of each point indicates the amplitude of a specific frequency at a particular time.
  5. Feature Extraction:
    • Features, such as Mel-Frequency Cepstral Coefficients (MFCCs), are extracted from the spectrogram. These features represent the sound’s power spectrum and provide a compact, manageable representation for analysis.
  6. Pattern Recognition:
    • Machine learning algorithms or neural networks are trained on these features to recognize and classify different sounds. The model is trained using labeled datasets where the sound type is known. After training, the model can analyze new spectrograms and recognize corresponding sounds by comparing the extracted features to learned patterns.

Applications

This sound recognition system can automate tasks and enhance projects through AI-driven sound analysis. For example:

  • Environmental Monitoring: Detect animal presence in forests for conservation efforts.
  • Wildlife Research: Identify different bird species by their calls.
  • Industrial Diagnostics: Diagnose faults in engines or motors by analyzing sound patterns.

By following these steps, you can integrate sound recognition into your projects, using AI to automate tasks based on audio cues, offering significant potential for innovation in various fields.

Learn how we helped 100 top brands gain success