Speech synthesis: Difference between revisions

→‎{{header|REXX}}: simplified the REXX prorgram by using a different keyword for the NIRCMD program (used text instead of a file).
m (added a related task.)
(→‎{{header|REXX}}: simplified the REXX prorgram by using a different keyword for the NIRCMD program (used text instead of a file).)
Line 376:
{{works with|Windowx/XP or later}}
Programming note:   This REXX program uses a freeware program   NIRCMD   to interface with the Microsoft Windows speech synthesizer program   '''SAM''',   a text to speech using a male voice.   SAM can possibly be configured to use other voices with later releases of Windows.   More recent Microsoft Windows have another speech synthesizer program:   ANNA.
<lang rexx>/*REXX program uses a C.L. command line interface to invoke Windows SAM for speech synthesis.*/
parse arg t; t=space(t) /*get the (optional) text from the C.L.*/
if t=='' then signalexit done /*Nothing to say? Then exit program.*/
dquote= '"'
 
rate= 1 /*codetalk: could be added-10 (slow) here to get a ···10 (fast). */
homedrive=value('HOMEDRIVE',,'SYSTEM') /*get HOMEDRIVE location of \TEMP */
tmp =value('TEMP',,'SYSTEM') /* " TEMP directory name. /* [↓] where the rubber meets the road*/
'NIRCMD' "speak filetext" tFID dquote t dquote rate /*NIRCMD invokes Microsoft's Sam voice*/
if homedrive=='' then homedrive='C:' /*use the default if none was found. */
if tmp=='' then tmp=homedrive'\TEMP' /* " " " " " " " /*stick a fork in it, we're all done. */</lang>
/*code could be added here to get a ···*/
/* ··· unique name for the TEMP file.*/
tFN='SPEAK_IT'; tFT='$$$' /*use this name for the TEMP's fileID.*/
tFID=homedrive||'\TEMP\' || tFN"."tFT /*create temporary name for the output.*/
call lineout tFID,t /*write text ──► temporary output file.*/
call lineout tFID /*close the output file just to be neat*/
'NIRCMD' "speak file" tFID /*NIRCMD invokes Microsoft's Sam voice*/
'ERASE' tFID /*clean up (delete) the TEMP file.*/
 
done: /*stick a fork in it, we're all done. */</lang>
Note: &nbsp; The name of the above REXX program is &nbsp; '''speak.rex'''<br>
'''usage''' &nbsp; using the command: