CSC 115 | Sonoma State University | Spring, 2022 |
Imperative Problem Solving and Data Structures | ||
The eSpeakPackage implement a useful capability in which a program may speak text to the user. The eSpeakPackage.h provides a library for output as spoken text just as C provides the stdio.h library for input and output. Users are able to execute Scribbler testing with eSpeak by reference the MyroC library and eSpeak library.
The following is a list of eSpeak commands users can put in their scribbler program.
eSpeakConnect
establishes connection with the eSpeak library.
eSpeakTalk
takes a string as parameter and create audio through the computer speakers.
eSpeakSetGender
takes the string male or female to set the appropriate gender.
eSpeakDisconnect
disconnects from the the eSpeak library.
Details of these functions are given in the header file, eSpeakPackage.h
A simple example, eSpeakExample1.c, illustrates in the following program; steps for compiling and running the code follow the program listing. (Note that the make assumes the installation of a proper Makefile, as described in the lab on linux basics.)
/** This test demonstrate the basic text-to-speech capability of eSpeak * * Author: Jordan Yuan * Date created: 10-2-2013 * Date revised: 10-9-2013 */ /* Compile this program with the line * gcc -Wall -Wno-deprecated-declarations -std=gnu99 -leSpeakPackage eSpeakExample1.c -o eSpeakExample1 * or * make eSpeakExample1 */ #include "eSpeakPackage.h" int main () { eSpeakConnect ();//connect to eSpeakSpeak //voice set randomly to female or male eSpeakTalk( "setting up testing environment"); eSpeakTalk( "setting voice to male"); eSpeakSetGender ("male"); //set gender male eSpeakTalk("Once upon a time in a kingdom far far away"); eSpeakSetGender("female"); // set gender female eSpeakTalk("there was a little princess"); eSpeakTalk("who loves to stare into the stars"); eSpeakSetGender("male"); eSpeakTalk("one day a big dragon swooped down and they became the best of friends"); eSpeakSetGender("female"); eSpeakTalk("The end"); eSpeakDisconnect ();//disconnect from eSpeak } //end of main
Programming a Scribbler 2 robot presents challenges in testing, because regular testing requires the programmer to look at both the robot and code at the same time.
The eSpeak library provides a capability to resolve this problem of testing, because the eSpeakPackage allows you to look at the robot while the program speaks the intended robot action.
The following program, eSpeakExample2.c, demonstrates the full capability of eSpeak with MyroC.