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

  • From: "Lloyd Rasmussen" <lras@xxxxxxxxxxx>
  • To: <programmingblind@xxxxxxxxxxxxx>
  • Date: Tue, 11 Sep 2007 23:40:27 -0400

Actually, the calling conventions for SAPI 4 are somewhat different.  And a
change Microsoft made a few months ago which disables JavaScript's ability
to call SAPI 4 implies that there are some bugs in SAPI 4 which Microsoft
doesn't plan to fix.  Remember that SAPI 5 has been out for 5 or 6 years,
and SAPI 4 is older.  

I was going to paste into this message the code of a PowerBasic program
which uses the first available SAPI 4 engine to speak whatever is on the
command line.  It can be called from batch files or CMD files.  The
executable is on my web site.  I think this is one of the programs that got
Jamal started on Windows programming.  It is derived from another PB program
written by one of PowerBasic's staffers for the console version of their
compiler.  But the source is on a different machine, and this will have to
wait for another night.


Lloyd Rasmussen, Kensington, Maryland
Home:  http://lras.home.sprynet.com
Work:  http://www.loc.gov/nls
 
> -----Original Message-----
> From: programmingblind-bounce@xxxxxxxxxxxxx [mailto:programmingblind-
> bounce@xxxxxxxxxxxxx] On Behalf Of Littlefield, Tyler
> Sent: Tuesday, September 11, 2007 10:57 PM
> To: programmingblind@xxxxxxxxxxxxx
> Subject: Re: SAPI5 speech via COM in AutoIt, VBNET, & C#
> 
> what's so big about sapi 4? I'd venture to guess, it'd be the same.
> I don't see m$ changing their whole interface from one ver to the next...
> :)
> Thanks,
> Tyler Littlefield.
> Vertigo head coder
> "My programs don't have bugs, just randomly added features."
> msn: compgeek134@xxxxxxxxxxx
> email: compgeek13@xxxxxxxxx
> aim: st8amnd2005
> skype: st8amnd127
> ----- Original Message -----
> From: "Simon Jaeger" <simon4599@xxxxxxxxx>
> To: <programmingblind@xxxxxxxxxxxxx>
> Sent: Tuesday, September 11, 2007 8:10 PM
> 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

__________
View the list's information and change your settings at 
//www.freelists.org/list/programmingblind

Other related posts: