Hardware Reference
In-Depth Information
Solution
Just install the flite text-to-speech program:
bone# apt-get install flite
Then add the code from Example 3-8 in a file called speak.js and run.
Example 3-8. A program that talks (speak.js)
#!/usr/bin/env node
var exec = require ( 'child_process' ). exec ;
function speakForSelf ( phrase ) {
{
exec ( 'flite -t "' + phrase + '"' , function ( error , stdout ,
stderr ) {
console . log ( stdout );
if ( error ) {
console . log ( 'error: ' + error );
}
if ( stderr ) {
console . log ( 'stderr: ' + stderr );
}
});
}
speakForSelf ( "Hello, My name is Borris. " +
"I am a BeagleBone Black, " +
"a true open hardware, " +
"community-supported embedded computer for developers and hobbyists.
" +
"I am powered by a 1 Giga Hertz Sitara™ ARM® Cortex-A8 processor. " +
"I boot Linux in under 10 seconds. " +
"You can get started on development in " +
"less than 5 minutes with just a single USB cable." +
"Bark, bark!"
);
See Recipe 2.12 to see how to use a USB audio dongle and set your default audio out.
Search WWH ::




Custom Search