How-to use festival

From Wiki for iCub and Friends
Jump to: navigation, search

Using Festival in Windows

and using it with YARP

Download the CSLU Toolkit(RAD). You need to fill out a registration form and then a link for the download file will send by email. During the installation dialog you can decide to also download and install Festival (you will also need to tic Tcl). Festival and Tcl will be then downloaded and installed automatically.

Copy the .dll files from the RAD directory (/Tcl80/bin) to the Festival directory (Festival/1.4.2/bin). Try a first execution of Festival. Open a command window, change to the Festival/1.4.2/bin directory and type:

festival

If Festival is installed correctly then something like this should appear

 Festival Speech Synthesis System 1.4.2:release July 2001
 Copyright (C) University of Edinburgh, 1996-2001. All rights reserved.
 For details type `(festival_warranty)'
 festival>

You can now test if the speech output works with (type help for help):

(SayText "Hello")

You should hear "hello". Now festival works on your Windows machine.

Using festival with YARP

You could start with the following code of talk.cpp.

/*
Talk.cpp
Waits for keyboard input and then converts this text to speech via festival.
another command window has to be opened by the user with
yarp read /voice | festival 
Get all OS and signal processing YARP classes 
*/
#include <stdio.h>
#include <iostream>
#include <yarp/os/all.h>
#include <string>
using namespace yarp;
using namespace yarp::os;
using namespace std;

int main() {
  Network yarp;                                // initialize network
  Port textPort;
  textPort.open("/text/write");                //name port
  // connect output of prog to other port
  Network::connect("/text/write", "/voice");   //voice has to be opened before;
  //text to be send to the port
  while(1){ //read in keyboard input forever
  char command[1000];				//initialize command
  cin.getline(command, 1000);			// read in from keyboard but ignore separation by space
  cout << "command is " << command << endl;	// print out what was typed in
  // send to festival (SayText "TEXT")
  string festival;
  festival = "(SayText \"";
  festival = festival + command;
  festival = festival + "\")";
  Bottle b;		                //create bottle
  b.addInt(0);		                // yarp read prints bottle exactly, similar to verbatim
  b.addString(festival.c_str());	//write string to the bottle and convert
  cout<< b.toString().c_str() <<endl;	//control send command
  textPort.write(b);			// write the input to the port
    } 
  return 0;
}

Make a cmake list with typing

yarp cmake

in the directory where you saved the .cpp file. Then CMake the file and compile the file. Now do the usual YARP preparations: create a namespace with

yarp namespace /myspace 

and start a yarp server with

yarp server

Open a new command window and change to the festival directory. Type there

yarp read /voice | festival 

This opens a voice port to receive the output of the talk program. Be sure that already 2 command windows are open (yarp server and the voice port piping into festival). Now execute the talk program. A new command window opens which should display something like:

yarp: Port /text/write active at tcp://127.0.0.1:10002
yarp: Sending output from /text/write to /voice using tcp

Now type hello into this window and you should hear "hello" and see the following:

yarp: Port /text/write active at tcp://127.0.0.1:10002
yarp: Sending output from /text/write to /voice using tcp
hello
command is hello
0 "(SayText \"hello\")"

On the command window with piping the output to festival you should see something like this:

Port /voice listening at tcp://127.0.0.1:10022
yarp: Receiving input from /text/write to /voice using tcp

The Festival documentation can be found here.

Done.