I’ve been doing some experiments with the C++ API of the festival text to speech library. The documentation describes gives a code snippet to use this API. So far I’ve successfully manged to compile a C++ snippet like the one below
#include<stdio.h>
#include<festival.h>
int main(int argc,char **argv)
{
int heap_size=210000;
int load_init_files=1;
festival_initialize(load_init_files,heap_size);
festival_say_text("it is lunch time");
festival_wait_for_spooler();
return 0;
}
I compiled it with the following line which is highly specific to Ubuntu Lucid Lynx
sudo g++ main.cc -l Festival -I/usr/include/festival -I/usr/lib/speech_tools/include -leststring -lestools -lestbase -o nat.out
23 November 2011 at 8:56 am
Hello, When i use this code on code blocks ubuntu
it pops up some error that undefined reference to ‘ETS_Chunk::~EST_Chunk()’
please help me how to fix it?
23 November 2011 at 9:15 am
I’ll give it a try in a more up to date version of ubuntu and let you know how I get on.
23 November 2011 at 11:51 am
hmm seems to work for me on Ubuntu 11.04. Do you have package festival-dev installed? EST stands for edinburgh speech tools as I remember and is a separate library with a lot of the festival functionality in it. If you want to build the speech tools from source they are the last download on this page http://www.cstr.ed.ac.uk/downloads/festival/2.1/ .
23 November 2011 at 12:01 pm
Thank you for replied. I am using ubunbu 11.10.
what is this:
sudo g++ main.cc -l Festival -I/usr/include/festival -I/usr/lib/speech_tools/include -leststring -lestools -lestbase -o nat.out
on your post?
23 November 2011 at 12:08 pm
By the way do know how to use CMU sphinx with c++. When I use your suggessted festival/2.1/ it says creating cache ./config.cache
checking host system type… i686-pc-linux-gnu
checking target system type… i686-pc-linux-gnu
checking build system type… i686-pc-linux-gnu
checking for gcc… gcc
checking whether the C compiler (gcc ) works… yes
checking whether the C compiler (gcc ) is a cross-compiler… no
checking whether we are using GNU C… yes
checking whether gcc accepts -g… yes
configure: error: Cannot locate Edinburgh Speech Tools. please specify ESTDIR explicitly.
I just extracted and typed ./configure command on terminal.
23 November 2011 at 12:10 pm
and there is not also include folder
24 November 2011 at 9:42 am
If you are wanting to build festival from source rather than use the ubuntu deb package then the best guide is actually this shell script http://www.speech.cs.cmu.edu/15-492/homework/hw1/packed2009/build_them . As you will see it exports ESTDIR variable.
The code on this page is for compiling a small C ++ script which uses the festival C++ API to say some text. I was doing this as a precursor to building a PHP extension to interact directly with festival.
26 November 2011 at 4:08 am
I got these errors:
/usr/lib/libFestival.a(EST_TargetCost.o): In function `EST_TargetCost::stress_cost() const’:v
/usr/lib/libFestival.a(EST_TargetCost.o): In function `EST_TargetCost::stress_cost() const’:v
Do you have an idea?
26 November 2011 at 4:11 am
(.text+0x17b6): undefined reference to `est_val(EST_Item const*)’
also this..
26 November 2011 at 4:13 am
full code is here
#include
#include
using namespace std;
int main(int argc, char **argv)
{
EST_Wave wave;
int heap_size = 210000; // default scheme heap size
int load_init_files = 1; // we want the festival init files loaded
festival_initialize(load_init_files,heap_size);
// Say simple file
//festival_say_file(“Home/hello.txt”);
festival_eval_command(“(voice_ked_diphone)”);
// Say some text;
festival_say_text(“hello world”);
//Convert to a waveform
festival_text_to_wave(“hello world”,wave);
wave.save(“Home/../wave.wav”,”riff”);
// festival_say_file puts the system in async mode so we better
// wait for the spooler to reach the last waveform before exiting
// This isn’t necessary if only festival_say_text is being used (and
// your own wave playing stuff)
festival_wait_for_spooler();
// cout << "hello ";
return 0;
}
28 November 2011 at 11:12 am
ok so I managed to get the code you sent to compile and produce a wav etc.
Here’s what I did from a completely clean version of Ubuntu 11.04
This will install a whole load of other packages too including festival
Then I editied the code you posted adding
at the top where where there was just #include (I assume these were stripped out as html tags when you posted). I also eddited the ” marks as these had been replaced with fancy ones probably by wordpress.
I then set the path for the wave file to be in /tmp. And I removed this line
As I didn’t have that voice and hence that variable.
I saved the file as test.c
then
I then ran test.out and it spoke! It also created a wav file in /tmp.
1 December 2011 at 3:11 am
Thank you for your reply. I followed your post in ubuntu 11.04
I get these errors.
~/Desktop/fest$ sudo g++ test.c -l Festival -I/usr/include/festival -I/usr/lib/speech_tools/include -leststring -lestools -lestbase -o test.out
test.c:12:1: error: stray ‘\342’ in program
test.c:12:1: error: stray ‘\200’ in program
test.c:12:1: error: stray ‘\234’ in program
test.c:12:1: error: stray ‘\342’ in program
test.c:12:1: error: stray ‘\200’ in program
test.c:12:1: error: stray ‘\235’ in program
test.c:14:1: error: stray ‘\342’ in program
test.c:14:1: error: stray ‘\200’ in program
test.c:14:1: error: stray ‘\234’ in program
test.c:14:1: error: stray ‘\342’ in program
test.c:14:1: error: stray ‘\200’ in program
test.c:14:1: error: stray ‘\235’ in program
test.c:15:1: error: stray ‘\342’ in program
test.c:15:1: error: stray ‘\200’ in program
test.c:15:1: error: stray ‘\234’ in program
test.c:15:1: error: stray ‘\342’ in program
test.c:15:1: error: stray ‘\200’ in program
test.c:15:1: error: stray ‘\235’ in program
test.c:15:1: error: stray ‘\342’ in program
test.c:15:1: error: stray ‘\200’ in program
test.c:15:1: error: stray ‘\235’ in program
test.c:15:1: error: stray ‘\342’ in program
test.c:15:1: error: stray ‘\200’ in program
test.c:15:1: error: stray ‘\235’ in program
test.c: In function ‘int main(int, char**)’:
test.c:12:22: error: ‘hello’ was not declared in this scope
test.c:14:32: error: expected ‘)’ before ‘world’
test.c:15:14: error: expected primary-expression before ‘/’ token
test.c:15:15: error: ‘tmp’ was not declared in this scope
test.c:15:24: error: ‘class EST_Wave’ has no member named ‘wav’
test.c:15:34: error: ‘riff’ was not declared in this scope
6 December 2011 at 3:11 pm
This is probably the shaped quotation marks see here http://www.giannistsakiris.com/index.php/2008/04/17/gcc-error-stray-%E2%80%98342%E2%80%99-in-program/