Speech synthesis: Difference between revisions
(→{{header|Tcl}}: Added C#) |
|||
Line 2: | Line 2: | ||
Render the text “<tt>This is an example of speech synthesis.</tt>” as speech. |
Render the text “<tt>This is an example of speech synthesis.</tt>” as speech. |
||
=={{header|C sharp|C#}}== |
|||
You need to 'Add Reference' to the COM "Microsoft Speech Object Library" in your Preferences. |
|||
<lang csharp>using SpeechLib; |
|||
namespace Speaking_Computer |
|||
{ |
|||
public class Program |
|||
{ |
|||
private static void Main() |
|||
{ |
|||
var voice = new SpVoice(); |
|||
voice.Speak("This is an example of speech synthesis."); |
|||
} |
|||
} |
|||
}</lang> |
|||
=={{header|Tcl}}== |
=={{header|Tcl}}== |
||
This just passes the string into the Festival system: |
This just passes the string into the Festival system: |
Revision as of 05:34, 25 April 2011
Render the text “This is an example of speech synthesis.” as speech.
C#
You need to 'Add Reference' to the COM "Microsoft Speech Object Library" in your Preferences. <lang csharp>using SpeechLib;
namespace Speaking_Computer {
public class Program { private static void Main() { var voice = new SpVoice(); voice.Speak("This is an example of speech synthesis."); } }
}</lang>
Tcl
This just passes the string into the Festival system:
<lang tcl>exec festival --tts << "This is an example of speech synthesis."</lang>
Alternatively, on MacOS X, you'd use the system say
program:
<lang tcl>exec say << "This is an example of speech synthesis."</lang>
Putting these together into a helper procedure, we get:
<lang tcl>proc speak {msg} {
global tcl_platform if {$tcl_platform(os) eq "Darwin"} { exec say << $msg } else { exec festival --tts << $msg }
} speak "This is an example of speech synthesis."</lang>
UNIX Shell
Here we use the open source espeak tool:
<lang sh>#!/bin/sh espeak "This is an example of speech synthesis." </lang>