Author Topic: Giving Your Programs A Voice  (Read 221 times)

SteveDee

  • Newbie
  • *
  • Posts: 33
Giving Your Programs A Voice
« on: February 05, 2012, 04:07:01 AM »
I've found it very helpful in a few cases to add audible alarms to monitoring functions. For example, if you work in a network support environment and a server goes down, you need know about it a.s.a.p.
By using text-to-speech you can monitor several aspects of your working environment without having to continually view screens.

I recommend eSpeak which is a compact open source software speech synthesiser. Once installed, you can test it by typing something in a terminal:-
Code: [Select]
espeak hello
...or...
Code: [Select]
espeak "hello steve"

You can change the default voice by using the voice switch, so:-
Code: [Select]
espeak -ven+f4 "hello steve"
...should give you an English female voice.

Having different voices can be useful. For example, you could use a female voice when a server goes down, and a male voice when a new job request arrives on you Help Desk. With the monitoring system that we use, I've created 10 voices which are simply selected at random.

Using eSpeak With Gambas.
This is really easy:-

Code: [Select]
strMessage="hello steve"
EXEC ["espeak", strMessage]

...or with more control:-

Code: [Select]
strMessage="Hello, My name is Monica"
's=rate, p=pitch, v=voice, f=female, k=emphasis on capitals
EXEC ["espeak", "-s130", "-p70", "-ven+f4", "-g5", "-k5", strMessage]

So here is a simple Gambas speech alarm routine:-
Code: [Select]
PUBLIC SUB Alarm(strMessage AS String,strVoice AS String)

  SELECT CASE strVoice
    CASE "monica"
    strVoice="-ven+f4"
    CASE "bill"
    strVoice="-ven+m4"
    ...
    {more voices}
    ...
    CASE ELSE
    strVoice="-ven+m1"
  END SELECT

  's=rate, p=pitch, v=voice, f=female, k=emphasis on capitals
  EXEC ["espeak", "-s130", "-p70", strVoice, "-g5", "-k5", strMessage]
  WAIT 2 {you may need a delay depending upon repeat period & length of text}
END


Have Fun!

Linux Basic

Giving Your Programs A Voice
« on: February 05, 2012, 04:07:01 AM »

Technopeasant

  • Newbie
  • *
  • Posts: 17
    • Homepage
Re: Giving Your Programs A Voice
« Reply #1 on: March 21, 2012, 07:27:11 PM »
I just saw this thread today and am intrigued, I tried to cook something up like this with Festival before but had no luck.

Just one question, is there a way to get eSpeak to read from a text file? Rather than just a short excerpt?
Technical director,
Piga Software
http://icculus.org/piga/

Gambas (1.0.19, 2.23 & 3.0.0) coding since April 2007, focusing on game logic, graphics and artificial intelligence.
Running Fedora 15 (GNOME 3 Fallback, XFCE, LXDE) on a Dell Latitude D600 and Fedora 15 LXDE spin on a Lenovo 3000 N200.

SteveDee

  • Newbie
  • *
  • Posts: 33
Re: Giving Your Programs A Voice
« Reply #2 on: March 31, 2012, 05:37:48 AM »
Sorry for the late reply (I don't check this forum very often, as its pretty dead).

Yes, if you have a text file called: GoodMorning in your home directory, you can use something like:-

espeak -f /home/steve/GoodMorning

If you have already installed espeak, just go to a terminal and type:-

man espeak

...for a list of command line options.

Technopeasant

  • Newbie
  • *
  • Posts: 17
    • Homepage
Re: Giving Your Programs A Voice
« Reply #3 on: April 08, 2012, 08:06:36 PM »
Alright thanks, though I already came up with a solution involving a front-end I am working on.

Anyhow, that is why I simply subscribed to the relevant forums here, in case of the occasional reply. Sadly, this must have sifted through somehow...
Technical director,
Piga Software
http://icculus.org/piga/

Gambas (1.0.19, 2.23 & 3.0.0) coding since April 2007, focusing on game logic, graphics and artificial intelligence.
Running Fedora 15 (GNOME 3 Fallback, XFCE, LXDE) on a Dell Latitude D600 and Fedora 15 LXDE spin on a Lenovo 3000 N200.