Can I use Google Translate to make my raspberry Pi speak different languages ​​on request?

I have a Raspberry Pi B +, working with the latest Raspbian headless, and forcibly outputs a 3.5 mm audio jack, so I can connect speakers and β€œspeak” on demand (remotely via SSH will be fantastic).

Google translate has a service call that will read the text to you in many languages. Does anyone know how I can use this to make my Raspberry Pi multilingual on demand?

Even just how to get Google Translate to say some English words from the command line will be fantastic. It is preferable to use a bash script.

+5
source share
1 answer

I found some information that I think will do what you are looking for. I tried and succeeded in the following. Try it and see what you think.

If you want your raspberry Pi to be able to speak several languages, follow these steps.

  • In the terminal window, enter the following (each on a separate line)

sudo apt-get install alsa-utils

sudo apt-get install mplayer

  1. Then consider the modules by typing this in the terminal

sudo nano / etc / modules

  1. After entering the specified command, check the file that opens to see if it shows the following:

snd_bcm2835

  1. if it shuts down. If he does NOT add it.

  2. Then add the line to the mlayer configuration by typing it in the terminal:

sudo nano / etc / mplayer / mplayer.conf

  1. Add the following. If you are not sure where to put it, the lower part works fine

nolirc = yes

* Be sure to save the changes. It must be CTRL + X to exit and prompts you to save the changes to nano


Then for the test do the following

nano speech.sh

Then add the following to 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 $* 
  • Useful advice, be sure to remember the permission changes for reading from the file chmod u + x speech.sh

T7 buy as an example to hear the sound on your pi.

./speech.sh Look Dave, I see that you are really upset about it

+4
source

Source: https://habr.com/ru/post/1208936/


All Articles