Re: SAPI5 speech via COM in AutoIt, VBNET, & C#

  • From: Jamal Mazrui <empower@xxxxxxxxx>
  • To: programmingblind@xxxxxxxxxxxxx
  • Date: Wed, 12 Sep 2007 12:07:34 -0400 (EDT)

Below is the SAPI4 code from Lloyd ported to AutoIt.
Jamal

Func Say($sText)
Local $oSapi = ObjCreate("Speech.VoiceText")
Local $sCaller = "AutoIt"
Local $iCommand = 4
$oSapi.Register("", $sCaller)
$oSapi.Speak($sText, $iCommand)
While $oSapi.IsSpeaking()
Sleep(50)
WEnd
$oSapi = 0
EndFunc

Local $sText = "Testing  1 2 3"
Say($sText)

On Tue, 11 Sep 2007,
Simon Jaeger wrote:

> Date: Tue, 11 Sep 2007 22:10:02 -0400
> From: Simon Jaeger <simon4599@xxxxxxxxx>
> Reply-To: programmingblind@xxxxxxxxxxxxx
> To: programmingblind@xxxxxxxxxxxxx
> Subject: Re: SAPI5 speech via COM in AutoIt, VBNET, & C#
>
> could you do at least autoit for sapi4? I have no idea how to use sapi4,
> altyough have used sapi5 quite a lot.
>
>
> Simon Jaeger
>
>
>
> Contact information
> MSN and E-Mail: Simon4599@xxxxxxxxx
> Alternatively, you can e-mail me at
> Simon@xxxxxxxxxxxxxxxxxxxxxxx
> Skype Username: Simon4599
> Webpage: Http://Simon.X-Sight-Interactive.NET
> Live Journal: http://simon4599.livejournal.com
>
> ----- Original Message -----
> From: "Jamal Mazrui" <empower@xxxxxxxxx>
> To: <programmingblind@xxxxxxxxxxxxx>
> Sent: Monday, September 10, 2007 11:06 PM
> Subject: SAPI5 speech via COM in AutoIt, VBNET, & C#
>
>
> > Below are example programs in three languages:  AutoIt, Visual Basic .NET,
> > and C#.  Each contains a Say routine to speak a string via COM automation
> > with SAPI5, as well as code to test that routine.  Initial comments give
> > command-line syntax for compiling and running the program -- assuming
> > relevant tools have been included on the Windows search path.
> >
> > Hope this helps,
> > Jamal
> > ----------
> >
> > ; AutoIt
> > ; Run sapi.au3 with the following command line:
> > ; start sapi.au3
> > ; or compile it with the following command line:
> > ; aut2exe /in sapi.au3
> > ; Then run sapi.exe
> >
> > Func Say($sText)
> > Local $oSapi = ObjCreate("SAPI.SpVoice")
> > $oSapi.Speak($sText)
> > $oSapi = 0
> > EndFunc
> >
> > Local $sText = "Testing 1 2 3"
> > Say($sText)
> >
> > ----------
> >
> > ' Visual Basic .NET
> > ' Compile sapi.vb with the following command line:
> > ' vbc.exe sapi.vb
> > ' Then run sapi.exe
> >
> > Module Program
> >
> > Sub Say(sText As String)
> > Dim sProgID As String = "SAPI.SPVoice"
> > Dim oSapi As Object = Microsoft.VisualBasic.CreateObject("SAPI.SPVoice")
> > oSapi.Speak(sText)
> > System.Runtime.InteropServices.Marshal.ReleaseComObject(oSapi)
> > End Sub
> >
> > Sub Main()
> > Dim sText As String = "Testing 1 2 3"
> > Say(sText)
> > End Sub
> >
> > End Module
> >
> > ----------
> >
> > // C#
> > // Compile sapi.cs with the following command line:
> > // csc.exe sapi.cs
> > // Then run sapi.exe
> >
> > class Program {
> >
> > static void Say(string sText) {
> > string sProgID = "SAPI.SPVoice";
> > System.Type tSapi = System.Type.GetTypeFromProgID(sProgID);
> > object oSapi = System.Activator.CreateInstance(tSapi);
> > string sMethod = "Speak";
> > object[] oArgs = {sText};
> > tSapi.InvokeMember(sMethod, System.Reflection.BindingFlags.InvokeMethod,
> > null, oSapi, oArgs);
> > System.Runtime.InteropServices.Marshal.ReleaseComObject(oSapi);
> > } // Say method
> >
> > static void Main() {
> > string sText = "Testing 1 2 3";
> > Say(sText);
> > } // Main method
> >
> > } // Program class
> >
> > ----------
> > End of Document
> >
> > __________
> > View the list's information and change your settings at
> > //www.freelists.org/list/programmingblind
> >
>
> __________
> View the list's information and change your settings at
> //www.freelists.org/list/programmingblind
>
__________
View the list's information and change your settings at 
//www.freelists.org/list/programmingblind

Other related posts: