Let Yun speak (Text-to-Speech)

  1. USB sound install.

opkg update
opkg install kmod-sound-core 
opkg install kmod-usb-audio 
opkg install madplay

Install mp3 player and connect speaker to headphone jack.

  1. Text-to-Speech
opkg update
opkg install python-curl
nano /mnt/sda1/mp3.py
#!/usr/bin/python
import urllib
import pycurl
import os
import sys
from subprocess import call
import  string
#print sys.argv
url='http://tts-api.com/tts.mp3?q='+urllib.quote(sys.argv[1])
filename='/mnt/sda1/test.mp3'
#print "==> Downloading File: ",filename," URL: ",url
fp = open(filename, "wb")
curl = pycurl.Curl()
curl.setopt(pycurl.FOLLOWLOCATION, 1)
curl.setopt(pycurl.URL, url)
curl.setopt(pycurl.WRITEDATA, fp)
curl.perform()
curl.close()
fp.close()
call(["/usr/bin/madplay", "/mnt/sda1/test.mp3"])
chmod 755  /mnt/sda1/mp3.py
/mnt/sda1/mp3.py  "hello world"
  1. ATmega32u4 side.

http://arduino.cc/en/Tutorial/Process

Code:

void insertdb() {
  Process p;            
  p.begin("/mnt/sda1/mp3.py");      
  p.addParameter("hello world"); 
  p.run();

Awesome!

Thanks for sharing!

I try /mnt/sda1/mp3.py "hello world" and is ok try /mnt/sda1/mp3.py "hello italy" or something else and goes wrong, actually http://tts-api.com/tts.mp3?q=hello%20italy doesn't respond. Were is the problem? Thanks

I test it, The "hello world" is cache. Server is down. I send request to ask repair.

Server is back online.

Very interesting thread.

Is possible record wav/mp3 from usb soundcard ?

Yes, load sox.

SoX is a command line utility that can convert various formats of computer audio files in to other formats. It can also apply various effects to these sound files during the conversion. As an added bonus, SoX can play and record audio files on several unix-style platforms.

http://wiki.openwrt.org/doc/howto/usb.audio

Sox has very long list of dependance:

libgsm.
kmod-sound-core.
alsa-lib.
libao.
libogg.
libvorbisidec.
libflac.
libvorbis.
libmagic.
libpng.
libsndfile.
lame-lib.
libmad.
libid3tag.
libbz2.
libffmpeg-full.
ffmpeg.

After Sox installed, 11 Mb space is gone. This might be the reason Yun team decide exclude Sox. You could compile it yourself.

I´m install new alsa-utils package from Luci advanced config and testing aplay and arecord.

Both working but crackle in sound - is possible setting buffer and latency sound card ?

Audio noise issues, but solved those with ALSA configurations

http://forum.arduino.cc/index.php?topic=216637.msg1584474#msg1584474

USB audio adapter behind the Self Powered USB Hub

http://forum.arduino.cc/index.php?topic=216637.msg1585679#msg1585679

Many thanks workings better than before :-)

Yun is great platform !

Kamil

Reviving an old thread...

First of all thank you. I spent a few hours on this and eventually got it working. The problem is that the file seems to be written to the root not the sd. (running the script from SSH kept on coming back with "file not found" until I found them in the root. Had to change the path to the file at the end of the script to make it work)

Due to arduino's warning that "You're discouraged from using the Yún's built-in non-volatile memory, because it has a limited number of writes," I thought I should make sure the file is saved to the SD card.

My python skills are non-existent. How do I make the file go to the sd? i tried adding the full path in "filename" but it didn't like that. Any thoughts?

Change

...
filename='test.mp3'
...

To

...
filename='/mnt/sda1/test.mp3'
...

Thank you. I tried that, but got an error. File not found or something like that.

thedovid: Thank you. I tried that, but got an error. File not found or something like that.

output of

ls /mnt/

Just tried replacing filename with the path again. Worked this time. Sorry for wasting your time. I don't know what changed. I strongly dislike python.

The thing that's still puzzling to me is why the mismatched path originally worked for you?

Anyways. Thank you.

"filename='test.mp3'" is relative path.

"filename='/mnt/sda1/test.mp3'" is absolute path.

The absolute path is more safe way to use.

HI sir,i am working TTS for converting text to speech with out using any shield.i am using TTS.h library but iam unable get the output .please help me

I use the same usb sound but I have some problems...

when I"opkg install kmod-sound-core " , I have following error

Any help appreciated!!!

Downloading http://download.linino.org/linino_distro/lininoIO/latest/packages/Pa ckages.gz. Updated list of available packages in /var/opkg-lists/attitude_adjustment. Downloading http://download.linino.org/linino_distro/lininoIO/latest/packages/Pa ckages.sig. Signature check passed. root@arduino:~# opkg install kmod-sound-core Installing kmod-sound-core (3.3.8-1) to root... Downloading http://download.linino.org/linino_distro/lininoIO/latest/packages/km od-sound-core_3.3.8-1_ar71xx.ipk. Collected errors: * satisfy_dependencies_for: Cannot satisfy the following dependencies for kmod- sound-core: * kernel (= 3.3.8-1-04487771b2235794a056b9dddb5c434a) * kernel (= 3.3.8- 1-04487771b2235794a056b9dddb5c434a) * * opkg_install_cmd: Cannot install package kmod-sound-core.