MCP
MCP robot

MCP Audio Components

Contents:

1. MCP Talk

In order to understand what the MCP's sensors are reading or what branches of execution it may be in, print statements can be sent to console. However the monitor can not be connected to the MCP when it is in motion, so print statements are not helpful. To address this problem, the SayText function was written.

When SayText is called with a string parameter, it will print the string to stdout and then write out a temporary file with the string in it along with commands specific to the festival program. The function then issues a system call to create a festival process that reads in the temporary file. This will cause the festival program to render the string as speech that can be heard through the MCP's speakers.

Code listing 1.1: Function Implementation



void SayText(char* text){
  int child = fork();


  if(child){
    printf("%s\n", text);
    return;


  }else{
    char tempfilename[256] = "/tmp/saytext.XXXXXX";
    mkstemp(tempfilename);
    //printf("%s\n", tempfilename);
    QFile file(tempfilename);
    if(file.open(IO_ReadWrite)){
      QTextStream ts(&file);
      ts << "(SayText \"" << text << "\")" << endl;
      ts << "(quit)" << endl;
      QString command = "festival ";
      command = command + tempfilename;
      //printf("%s\n",command.ascii());
      file.close();
      system(command.ascii());
      command = "rm ";
      command = command + tempfilename;
      //printf("%s\n", command.ascii());
      system(command.ascii());
    }
    //printf("child dead\n");
    exit(1);
  }

}



2. Playing Media

The MCP can play audio files by running mpg123 for mp3 files and ogg123 for ogg files.



line
Updated 2005-05-22
line
Yan Tran
Author

line
Summary:  The MCP is capable of talking or playing audio files.
line
Developed by students of the Engaging Computing Group in the Department of Computer Science at the University of Massachusetts Lowell