ESPHome + Emic 2 Text-to-Speech = Stephen Hawking Notifications

I was recently digging through my old components and found an Emic 2 Text-to-Speech module from Parallax / Grand Idea Studio. They don’t make it any more, but they still have stock to sell (US $149, about three times what I paid for it a decade ago).

It’s a small component that implements DECtalk text-to-speech, just like the devices used by Stephen Hawking to speak. And, yes, it includes Perfect Paul, the voice you all recognize immediately.

I thought to myself: “Self? This thing just uses 9600bps,N,8,1 serial comms, surely ESPHome can handle that?”

Sure enough, after just a few minutes of exploring—and a few more minutes trying to remember how to get std::string cast as std::vector<uint8_t>, which is needed by uart.write if you’re using lambdas—I was up and running.

This ESPHome config includes a HomeAssistant button to test that it’s working, and a custom service that can be used to speak notifications aloud to a speaker connected to the Emic 2.

esphome:
  name: talkbox

# Other config snipped

uart:
  tx_pin: 17
  rx_pin: 16
  baud_rate: 9600

button:
  - platform: template
    name: Keep talking
    id: keep_talking
    on_press:
      # "S" prefix needed for Emic 2 for "speak" command
      # [/] with rising inflection; [\] with falling inflection
      uart.write: "SAll we need to do. is [/]keep. [\\]talking.\n"

api:
  password: !secret api_password
  # expose custom service; will be named "talkbox_notify" in this case
  services:
    - service: notify
      variables:
        message: string
      then:
        - uart.write:
            data: !lambda |-
                std::string str = "S" + message + "\n";
                std::vector<uint8_t> vec(str.begin(), str.end());
                return vec;

I’m using UART2 on my ESP32 board, so that it’s not mixed with the built-in logger (which uses UART0). Since I have amplified speakers plugged into the 1/8" line out on the Emic (not shown in diagram below), the board works perfectly fine powered off the ESP32’s 5V pin.

My science geek kids love that Stephen Hawking’s voice is still alive in our house, even if he has to tell them to take their clothes out of the washer. :nerd_face: :grinning_face_with_smiling_eyes:

2 Likes

How has now one commented on this cool project. Great work.