javaguy Posted April 29, 2007 Report Share Posted April 29, 2007 I think Festival just became my new favorite toy. It's easy to pipe stuff to: echo "The sixth sheik's sixth sheep's sick" | festival --tts or echo "rrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrr" | festival --tts To test out the tts function I saved a long news story to a text file and ran it. My wife suggested I try it with a copy-paste of a long entry from an online rhyming dictionary. I tried this, and as it read more rhymes, the voice got slower and deeper, and finally started to sputter, then fell silent. My wife said, "My God, you've killed him." Festival cannot pronounce my wife's name correctly but comes closer to getting it right than any telemarketer ever has. Does anybody know an easy way to generate a .wav or .mp3 using Festival? [moved from Software by spinynorman] Quote Link to comment Share on other sites More sharing options...
Greg2 Posted April 29, 2007 Report Share Posted April 29, 2007 (edited) Here's one to try date '+%A, %B %e, %Y' | festival --tts Festival has a package built in called text2wave. So do date '+%A, %B %e, %Y' | text2wave -scale 50 -o date.wav and you have todays date in a .wav file. :) Edited April 29, 2007 by Greg2 Quote Link to comment Share on other sites More sharing options...
javaguy Posted April 29, 2007 Author Report Share Posted April 29, 2007 Woo hoo! That is way cool. Now I can have a cron job that sends an actual voice message to my phone to notify me when...uh, I'll think of something I want to be notified of. One thing, the resulting .wav was a little scratchy, although it sounds fine when I run festival by itself. Does this have something to do with my system? Quote Link to comment Share on other sites More sharing options...
Greg2 Posted April 29, 2007 Report Share Posted April 29, 2007 One thing, the resulting .wav was a little scratchy, although it sounds fine when I run festival by itself.Mine sounds the same. You can also install lame and do lame date.wav date.mp3 try that, maybe it sounds better? Quote Link to comment Share on other sites More sharing options...
Greg2 Posted April 29, 2007 Report Share Posted April 29, 2007 I should have said, both the .wav and festival sounds the same on my system. Anyway, if you install, or have installed lame... I have found a toy for you (I know you like php),: <?php // define the temporary directory // and where audio files will be written to after conversion $tmpdir = "/tmp"; $audiodir = "/change/to/your/path"; // if the Text-To-Speech button was click, process the data if (isset($_POST["make_audio"])) { $speech = stripslashes(trim($_POST["speech"])); $speech = substr($speech, 0, 1024); $volume_scale = intval($_POST["volume_scale"]); if ($volume_scale <= 0) { $volume_scale = 1; } if ($volume_scale > 100) { $volume_scale = 100; } if (intval($_POST["save_mp3"]) == 1) { $save_mp3 = true; } // continue only if some text was entered for conversion if ($speech != "") { // current date (year, month, day, hours, mins, secs) $currentdate = date("ymdhis",time()); // get micro seconds (discard seconds) list($usecs,$secs) = microtime(); // unique file name $filename = "{$currentdate}{$usecs}"; // other file names $speech_file = "{$tmpdir}/{$filename}"; $wave_file = "{$audiodir}/{$filename}.wav"; $mp3_file = "{$audiodir}/{$filename}.mp3"; // open the temp file for writing $fh = fopen($speech_file, "w+"); if ($fh) { fwrite($fh, $speech); fclose($fh); } // if the speech file exists, use text2wave if (file_exists($speech_file)) { // create the text2wave command and execute it $text2wave_cmd = sprintf("text2wave -o %s -scale %d %s",$wave_file,$volume_scale,$speech_file); exec($text2wave_cmd); // create an MP3 version? if ($save_mp3) { // create the lame command and execute it $lame_cmd = sprintf("lame %s %s",$wave_file,$mp3_file); exec($lame_cmd); // delete the WAV file to conserve space unlink($wave_file); } // delete the temp speech file unlink($speech_file); // which file name and type to use? WAV or MP3 $listen_file = (($save_mp3 == true) ? basename($mp3_file) : basename($wave_file)); $file_type = (($save_mp3 == true) ? "MP3" : "WAV"); // show audio file link $show_audio = true; } } } else { // default values $speech = "Hello there!"; $volume_scale = 50; $save_mp3 = true; } ?> <html> <head> <title>Festival: Linux Text-To-Speech Demo</title> <style type="text/css"> <!-- body { background-color:#ffffff; font-family:Arial, Helvetica, sans-serif; font-size:10pt; color: #000000; } h1 { font-family:Arial, Helvetica, sans-serif; font-size:18pt; color: #000000; } .tblfont { font-family:Arial, Helvetica, sans-serif; font-size:10pt; color: #000000; } --> </style> </head> <body> <h1>Linux Festival Text-To-Speech Demo</h1> <form method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>"> <table width="400" border="0" cellspacing="5" cellpadding="0" class="tblfont"> <tr> <td colspan="2"><textarea name="speech" wrap="VIRTUAL" style="width:350px;height:100px;"><?php echo $speech; ?></textarea></td> </tr> <tr> <td width="135">Volume Scale <input name="volume_scale" type="text" size="3" maxlength="3" value="<?php echo $volume_scale; ?>"> </td> <td width="265">Save as MP3 <input name="save_mp3" type="checkbox" value="1"<?php if ($save_mp3 == 1) { echo " checked"; } ?>> </td> </tr> <tr> <td><input name="make_audio" type="submit" value="Text-To-Speech"></td> <td> <?php if ($show_audio) { ?> <a href="audio/<?php echo $listen_file; ?>">Listen to the <?php echo $file_type; ?> file</a> <?php } ?> </td> </tr> </table> </form> </body> </html> please note that I did not write this... but it works. :) Quote Link to comment Share on other sites More sharing options...
iphitus Posted April 30, 2007 Report Share Posted April 30, 2007 got the command 'flite'? it's a smaller festival and supports writing out to a wav. James Quote Link to comment Share on other sites More sharing options...
neddie Posted May 5, 2007 Report Share Posted May 5, 2007 Nice tips, guys! Lots of fun! Try "I'm sorry Dave, I can't do that". Not surprisingly it can't do a very good job of foreign words, when I installed it it seemed to only offer me male English speaker or Finnish. I wonder if other speakers are available for other languages. There's also KMouth which can be hooked up as a frontend, lets you conveniently say phrases like "Today my pain is quite strong" and "I really feel bad today" to save you typing those commonly-used phrases over and over again... Just for completeness, the wavs sound fine here, just like running from festival. Maybe you're boosting the amplitude too much (with the scale) and it's clipping? Try without the scale. Just an idea. Oh, and I don't have flite, that must come separately. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.