5

I have found various instructions on making the 3.5mm audio jack on the Pi work with some sort of text to speech.

I tried quite a few instructions that were online, but very few spefied the Pi, which is important given the different architecture and what many people run Debian flavors of Linux on.

I was able to find that Google Translate has a way that not only can I make the Pi 'speak' through the headphone jack, but it can also do simple translation.

I have included the answer to my question below.

Quick Note: This is NOT a general Hardware/Software question. It has to do with specifically making text to speech play through CLI on the Raspberry Pi using Raspbian, with the added ability to perform simple language translations.

4

I found some information that I think will do what you are looking for. I have tried and had success with the following here. Please try it and see what you think.

If you want your Raspberry Pi to be able to speak to you, in multiple languages, do the following.

In a terminal window type the following (each on a separate line)

sudo apt-get install alsa-utils

sudo apt-get install mplayer

Then lets look at the modules by typing this in a terminal

sudo nano /etc/modules

After typing the above command check the file that opens to see if it shows the following:

snd_bcm2835

if it does exit. If it DOES NOT add it.

Then add a line to the mlayer configuration by typing this in a terminal:

sudo nano /etc/mplayer/mplayer.conf

Add the following. If you aren't sure where to put it, the bottom works fine

nolirc=yes

*Be sure to save your changes. It should be CTRL+X to exit and will prompt you to save your changes in nano

Then for the test do the following

nano speech.sh

Then put the following in a new file called speech.sh and save it.

#!/bin/bash
say() { local IFS=+;/usr/bin/mplayer -ao alsa -really-quiet -noconsolecontrols "http://translate.google.com/translate_tts?tl=en&q=$*"; }
say $*

Helpful tip, be sure to remember to change the permissions to read from the file

chmod u+x speech.sh

Then type the following as an example to hear audio on your pi.

./speech.sh what do you think your doing, dave

While I know this has the ability to translate as well, you can find more about that on the Google Translate help pages.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.