Note

Hello, welcome to the SunFounder Raspberry Pi & Arduino & ESP32 Enthusiasts Community on Facebook! Dive deeper into Raspberry Pi, Arduino, and ESP32 with fellow enthusiasts.

Why Join?

  • Expert Support: Solve post-sale issues and technical challenges with help from our community and team.

  • Learn & Share: Exchange tips and tutorials to enhance your skills.

  • Exclusive Previews: Get early access to new product announcements and sneak peeks.

  • Special Discounts: Enjoy exclusive discounts on our newest products.

  • Festive Promotions and Giveaways: Take part in giveaways and holiday promotions.

πŸ‘‰ Ready to explore and create with us? Click [here] and join today!

3.3 Fusion HAT+ Speaker

Introduction

The Fusion HAT+ includes a built-in speaker, making it ideal for voice prompts, alarms, and other AI/IoT audio applications. This lesson shows you how to enable, test, and use the speaker with text-to-speech.

Note

This guide assumes Raspberry Pi OS is installed and the Fusion HAT+ drivers are properly set up.

../_images/fusionhat_speaker.png

What You’ll Need

COMPONENT

PURCHASE LINK

Fusion HAT+

-

Raspberry Pi

-


Check if the Speaker Is Recognized

Check whether the Fusion HAT+ audio device is detected by the system:

aplay -l

You should see an audio device similar to:

card 3: voicehat [Fusion HAT+ Audio], device 0: ...

If a device named voicehat (or similar) appears under any card number, the Fusion HAT+ audio hardware is successfully recognized.


Run the Example Program

The most reliable way to test the speaker is to run the text-to-speech example.

cd ~/ai-lab-kit/llm
sudo python3 tts_espeak.py

You should hear: β€œHello! I’m Espeak TTS.”

Try adjusting the TTS parameters in the script to hear different voice effects.


Example Code

from fusion_hat.tts import Espeak

tts = Espeak()
tts.set_amp(200)
tts.set_speed(150)
tts.set_gap(1)
tts.set_pitch(80)

tts.say("Hello! I’m Espeak TTS.")

Code Explanation

  • set_amp(0–200) β€” volume

  • set_speed(80–260) β€” speaking speed

  • set_gap(0–200) β€” pause between words

  • set_pitch(0–99) β€” pitch of the voice

  • say() β€” convert text to speech and play it

Tip

Increase speed + pitch to make the voice cheerful; lower both for a deeper, more serious tone.


Troubleshooting

  • No sound output

    • Make sure the Fusion HAT+ audio device is detected:

       aplay -l
    
    You should see an audio device named ``voicehat`` (or similar).
    If the device is not listed, power off the Raspberry Pi, reseat the
    Fusion HAT+, and reboot.
    
    • If the device is still not detected, reinstall the audio driver:

    sudo /opt/setup_fusion_hat_audio.sh
    
  • Text-to-speech sounds too fast or robotic

    • Adjust the speech parameters in the code:

      tts.set_speed(120)
      tts.set_pitch(60)
      
  • Permission denied error

    • Run the script with superuser privileges:

    sudo python3 tts_espeak.py
    

Summary

In this lesson, you learned how to:

  • Verify that the Fusion HAT+ speaker is recognized

  • Use Espeak TTS to generate speech on the Raspberry Pi

The Fusion HAT+ speaker provides a simple and powerful way to add audio to your Raspberry Pi projects.