Speech Synthesizers

by . (updated

My friend Matt and I just discovered that Android's (default) text-messaging app can now send voice messages.

Voice messaging (on WeChat) was everywhere when I lived in China, and I've missed it as an option for texting in the States. I suppose the demand for voice messaging is filled here by Snapchat, whatever Facebook does, and voice iMessages for the Apple ecosystem. I don't use those, so I have been a text-only plebeian -- until now!

I think I'll be using voice messages a lot, especially during the coronavirus pandemic. My words, in my voice, represent me more closely than writing can. I'm glad to find a way to move some of my normal communication away from pure text.

~

As Matt and I sent each other sounds, I remembered an amusement from computer classes in my teenage years: the Mac's say command, which performs text-to-speech. All I had to do to send a dumb message in a machine's voice was to type say -v Alex "One. Alpha. Peter. Turbo. Peter again."

With that command in hand, I was able to make an "useful" addition to my normal Emacs script for launching Firefox. From now on, the program will remind remind me that it's launching Firefox, then read off some pointless numbers. [2020-09-22: updated the script to offer both Chinese and English ;^) 2020-10-15: slight refactor.]

(defun mj/run-firefox (in-english)
  (interactive "P")
  "Run Firefox, and turn on Wifi if necessary. Speaks Chinese; with prefix arg, speak English instead."
  ;; if Wifi is already on, trying to turn it on again does nothing
  (mj/toggle-wifi t)
  (let ((between-1-10 (+ 1 (random 10)))
        (speed-wpm (if in-english 250 200))) ;; Chinese voice isn't as good at fast speed
    (start-process "say-process" nil
                   "say"
                   "-r" (format "%s" speed-wpm)
                   "-v" (if in-english "Alex" "Ting-Ting")
                   (if in-english (format
                                   "Launching Firefox. Random number: %d."
                                   between-1-10)
                     "浏览器已启动。"))
    (start-process "firefox-process" nil "open" "/Applications/Firefox.app/")))

It's only a matter of time before I find a use for this that's amusing and practical. How about a script that opens subscription-feed items and reads them aloud? Or a long-running background job for Linguary which generates robotic-but-acceptable audio from scraps of Chinese text? Even the dumb idea of announcing running programs can be made useful, to provide feedback from programs in cases where I'm paying attention to something else. Soothing meditation timer, anyone? Receiving -- on the hour, every hour -- words of encouragement from your silicon friend?

If you have any ideas for scripting with text-to-speech (or speech-to-text!), leave a comment.