This is a multi-part message in MIME format.
--------------030002010701030306040000
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit

hi group,

There have been a number of postings here showing how to use the
msAgent characters to get your script to talk. You can also use
Microsoft's Speech Application Programming Interface (SAPI).
SAPI comes as an actX object, and so is programmable using vbs.
There was only one small script for sapi that I could find here,
posted about two years ago (by mayayana). The demo included
below shows some additional methods and properties of sapi, plus
it will detect a couple of events (if all goes well).

You probably have SAPI already installed, but in case you don't
you may download it (for free) from microsoft (beware word-wrap):

http://www.microsoft.com/downloads/details.aspx?FamilyID=5e86ec97-40a7-453f-b0ee-6583171b4530&DisplayLang=en

That page offers a number of options. The one you need is labeled:

SpeechSDK51.exe

This works on all ms systems, inc win98. It will install the
complete package, including the help file.

The demo script will say some simple sentences, and also includes
the demo (xml file) that comes with SAPI, which demonstrates what
you can do by including xml tags in the text to enhance the spoken
text.

Note that in order to show the user interface feature (audio control),
I had to make use of an api call (to get the desktop window handle).
If you don't like using dynawrap to call api's then you can remove
that.

cheers, jw

--------------030002010701030306040000
Content-Type: text/plain;
name="wshSAPIText2SpeechDemo.wsf.txt"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline;
filename="wshSAPIText2SpeechDemo.wsf.txt"

<?XML version="1.0" standalone="yes" encoding="iso-8859-1" ?>
<job id="wshSAPIText2SpeechDemo">

<script language="VBScript">
<![CDATA[

' --- description block --------------------------
'
' Title: wsh Script to Demo Text to Speech, using SAPI v5.1
'
' Discussion: this demo requires Microsoft's Speech Application Programming
' Interface (SAPI) v5.1 (or later?), which may be downloaded (free)
' from microsoft, in case you don't already have it...
'
' --- Revision History ---------------------------
' 01Mar08: initial attempt, with code posted by mayayana in the vbs ng, 14July05
' 01Mar08: discarded mayayana's constants, used constants from sapi.dll typelib...
' 01Mar08: sorry about using a system api, but the displayUI method would NOT
' accept "0" as a valid handle for the desktop window (most api's do), and so
' used an api call to get the desktop window handle...
' 03Mar08: add bookmark event...
' --- end of revisions ---------------------------
'
'
Option Explicit

' instantiate ActX components here...
' Dim oATO : Set oATO = WScript.CreateObject("wshAPIToolkit.ucATO") ' (no events)
Dim oDW : Set oDW = CreateObject("DynamicWrapper") ' instantiate dynawrap...
'
' ------------------------------------------------
' --- API DECLARATIONS ---------------------------
' ------------------------------------------------
' Message Function Templates
' Dim GetDesktopWindow : Set GetDesktopWindow = oATO.DeclareAPI("USER32.DLL", "GetDesktopWindow")
oDW.Register "USER32.DLL", "GetDesktopWindow", "f=s", "r=l" ' no input
' ------------------------------------------------
' --- end of api declarations --------------------
' ------------------------------------------------

Dim oSpVoice, sText
Set oSpVoice = WScript.CreateObject("Sapi.SpVoice", "oSV_")
Dim oShell : Set oShell = WScript.CreateObject("WScript.Shell")
Dim m_bEndOfStream ' as boolean
Dim m_SVSF_Flags
m_SVSF_Flags = SVSF_PurgeBeforeSpeak Or SVSF_IsNotXML ' note: "Or" gets both

' Valeur pour SpeechVoiceSpeakFlags
' (appear to be correct, based on sapi.dll's typelib)...
Const SVSF_Default = 0
Const SVSF_Async = 1
Const SVSF_PurgeBeforeSpeak = 2
Const SVSF_IsFilename = 4
Const SVSF_IsXML = 8
Const SVSF_IsNotXML = 16
Const SVSF_PersistXML = 32
Const SVSF_NLPSpeakPunc = 64
Const SVSF_NLPMask = 64
Const SVSF_VoiceMask = 127
Const SVSF_UnusedFlags = -128
'
Const SPDUI_AddRemoveWord = "AddRemoveWord"
Const SPDUI_UserTraining = "UserTraining"
Const SPDUI_MicTraining = "MicTraining"
Const SPDUI_AudioProperties = "AudioProperties"
Const SPDUI_AudioVolume = "AudioVolume"
' --- end of declarations and constants ----------

sText = "welcome to the sappy demo"
' the "async" flag was removed here, so as to finish speaking before continuing...
oSpVoice.speak sText, m_SVSF_Flags
WScript.Sleep 1000


If oSpVoice.IsUISupported(SPDUI_AudioVolume) = True Then
' Display Master Volume window
sText = "note, showing the Audio Volume user interface here"
oSpVoice.speak sText, m_SVSF_Flags
WScript.Sleep 1000

Dim hWnd
' hWnd = GetDesktopWindow() ' ato version
hWnd = oDW.GetDesktopWindow() ' dynawrap version
oSpVoice.DisplayUI CLng(hWnd), "", SPDUI_AudioVolume

Else
sText = "note, showing the Audio Volume user interface is not supported"
oSpVoice.speak sText, m_SVSF_Flags
WScript.Sleep 1000
End If


Dim sXMLRes : sXMLRes = GetResource("sXML_Test")
oSpVoice.Speak sXMLRes, SVSF_PurgeBeforeSpeak Or SVSF_IsXML Or SVSF_Async

' ok, so the async flag was used here to allow the script to continue,
' while sapi is playing out the xml text. We are not waiting for the
' stream to complete here, so that the Bookmark event will popup at
' the correct time. In addition, the the end-of-stream event is being
' used to terminate the script...
m_bEndOfStream = False

Do
WScript.Sleep 100
Loop Until m_bEndOfStream
WScript.Sleep 1000

sText = "this demo brought to you by mister unreliable (all rights reserved)"
oSpVoice.speak sText, m_SVSF_Flags
WScript.Sleep 1000

sText = "this script will now terminate"
oSpVoice.speak sText, m_SVSF_Flags

Set oSpVoice = Nothing
' Set oATO = nothing
Set oDW = nothing
WScript.Quit


' Event Bookmark(StreamNumber As Long, StreamPosition, Bookmark As String, BookmarkId As Long) -- from typelib
Sub oSV_Bookmark(nrStream, posStream, sBookmark, idBookmark)
Const tPopupDelay = 3

oSpVoice.Pause ' pause the voice stream...
' use a time-out popup for notification here,
' (show for 3 secs, may be increased for slow readers)...
oShell.Popup "spVoice Bookmark event detected: " & vbCrLf _
& "Stream Number: " & CStr(nrStream) & vbCrLf _
& "Stream Position: " & CStr(posStream) & vbCrLf _
& "Bookmark (Name): " & sBookmark & vbCrLf _
& "Bookmark ID: " & CStr(idBookmark), tPopupDelay, _
"SAPI Demo - Bookmark Event Notification", vbInformation

oSpVoice.Resume ' continue
End Sub


' Event EndStream(StreamNumber As Long, StreamPosition)
Sub oSV_EndStream(nrStream, posStream)
m_bEndOfStream = True ' set flag
End Sub


]]>
</script>

<resource id="sXML_Test">
<![CDATA[<xml version="1.0">

This is a basic functionality test for SAPI5 XML markup within the TTS Engine. If you haven't done so already, please choose Microsoft Mary for your voice and check the box labeled "IsXML" before clicking on "Speak" in order to begin the tutorial.

<SAPI>

<VOICE REQUIRED="NAME=Microsoft mike">Hello, my name is Microsoft Mike. </VOICE><VOICE REQUIRED="NAME=Microsoft Mary">Hello, my name is Microsoft Mary. </VOICE><VOICE REQUIRED="NAME=Microsoft Sam">Hello, my name is Microsoft Sam. </VOICE>Together we make up Microsoft's SAPI5 Text-to-Speech engine. With the use of XML tags, we can avoid the normal, default way that we read words and speak in general.

First of all, <VOICE REQUIRED="NAME=Microsoft Sam">you can</VOICE><VOICE REQUIRED="NAME=Microsoft mike">choose</VOICE><VOICE REQUIRED="NAME=Microsoft Mary">which voice</VOICE><VOICE REQUIRED="NAME=Microsoft Sam">you wish to hear</VOICE> through the use of a voice tag.<VOICE REQUIRED="NAME=Microsoft mike">Either Sam, Mary or myself can spell out words for you too.</VOICE>For example, the company "Microsoft" is spelled<SPELL>Microsoft</SPELL><VOICE REQUIRED="NAME=Microsoft Sam">and the word "Windows" is spelled <SPELL>windows</SPELL></VOICE>.

<VOICE REQUIRED="NAME=Microsoft mike">We can also change the rate at which we speak.</VOICE><RATE SPEED="10">I am currently speaking at three times my normal rate.</RATE><VOICE REQUIRED="NAME=Microsoft Sam"><RATE SPEED="-10">and I am currently speaking at one third my normal rate.</RATE></VOICE>Our pitch can be easily manipulated as well.<VOICE REQUIRED="NAME=Microsoft mike"><PITCH MIDDLE="10">This is an example of a high pitch</PITCH></VOICE><PITCH middle="-10">and this is an example of a low pitch</PITCH>

<VOICE REQUIRED="NAME=Microsoft Sam">Another way to adjust the prosody of our speech is through the use of a silence tag.</VOICE><VOICE REQUIRED="NAME=Microsoft mike">With a silence tag, an end user can make one of us pause for up to 65,536 milliseconds.</VOICE>For example, I<SILENCE MSEC="500"/>am<SILENCE MSEC="500"/>pausing<SILENCE MSEC="500"/>500<SILENCE MSEC="500"/>milliseconds<SILENCE MSEC ="500"/>between<SILENCE MSEC ="500"/>each<SILENCE MSEC ="500"/>word<SILENCE MSEC ="500"/>of<SILENCE MSEC ="500"/>this<SILENCE MSEC ="500"/>sentence.

<VOICE REQUIRED="NAME=Microsoft Sam">The volume of our individual voices can also be raised and lowered through the use of XML tags. <VOLUME LEVEL="101">This is the loudest I can speak</VOLUME><VOLUME LEVEL="-101">and this is the softest I can speak.</VOLUME></VOICE>

In order to make our voices sound more natural, an emphasis tag can be used to allow us to place emphasis on certain words in a sentence. <VOICE REQUIRED="NAME=Microsoft mike">Compare the following two phrases: The movie will be this friday. <SILENCE MSEC="750"/> The <EMPH>movie</EMPH> will be <EMPH>this friday.</EMPH> Pretty neat, don't you think?</VOICE>

Don't worry, that isn't all that we can do through the proper use of XML tags. <VOICE REQUIRED="NAME=Microsoft Sam">An end user can also decide which part of speech to use for each word in a sentence. Using the part of speech tag, we can force a certain pronunciation of a word without relying on the context around it</VOICE>. <VOICE REQUIRED="NAME=Microsoft mike">For example, the nominal pronunciation of the word "compact" is <SILENCE MSEC="250"/><PARTOFSP PART="noun">compact</PARTOFSP> and the verbal pronunciation of the word "compact" is <SILENCE MSEC="250"/> <PARTOFSP PART="verb">compact.</PARTOFSP> We can also force certain pronunciations for modifiers, functions , interjections and abbreviations.

Another great use of XML tags within the TTS Engine is the creation of your own words.</VOICE> Perhaps you want the computer to say a word that is not in the lexicon, such as "extracalifragilisticexpiallidocious." As you just heard, we do not recognize this word and have to use letter to sound rules in order to try and guess at a proper pronunciation. The pronunciation tag may be used to force the correct pronunciation of the word, <PRON SYM="eh 1 k s - t r ax 2 - k ae 1 l - ih 2 - f r ae 1 - jh ax 2 - l ih 1 - s t ih 2 k - eh 1 k s - p iy 2 - ae 1 l - ih 2 - d ow 1 - sh ax 2 s"/>. Wow, now tell me, doesn't that sound better?

Now let's insert a bookmark here<BOOKMARK MARK="8"/>. Your application should have received a bookmark event with a bookmark id of 8 when speech synthesis has passed this element in the input stream. Bookmark event is an easy way for an application to take action at a given point in the stream.

</SAPI>


Thanks for participating in this tutorial. I hope you have a better understanding of the basic functionality of XML tag usage within the TTS Engine. Enjoy!

</xml>

]]>
</resource>

</job>



--------------030002010701030306040000--

Re: [code] getting your script to talk to you by Paul

Paul
Tue Mar 04 14:24:56 CST 2008


"mr_unreliable" <kindlyReplyToNewsgroup@notmail.com> wrote in message
news:%23WyDqJYfIHA.5904@TK2MSFTNGP06.phx.gbl...
> hi group,
>
> There have been a number of postings here showing how to use the
> msAgent characters to get your script to talk. You can also use
> Microsoft's Speech Application Programming Interface (SAPI).
> SAPI comes as an actX object, and so is programmable using vbs.
> There was only one small script for sapi that I could find here,
> posted about two years ago (by mayayana). The demo included
> below shows some additional methods and properties of sapi, plus
> it will detect a couple of events (if all goes well).
>
> You probably have SAPI already installed, but in case you don't
> you may download it (for free) from microsoft (beware word-wrap):
>
> http://www.microsoft.com/downloads/details.aspx?FamilyID=5e86ec97-40a7-453f-b0ee-6583171b4530&DisplayLang=en
>
> That page offers a number of options. The one you need is labeled:
>
> SpeechSDK51.exe
>
> This works on all ms systems, inc win98. It will install the
> complete package, including the help file.
>
> The demo script will say some simple sentences, and also includes
> the demo (xml file) that comes with SAPI, which demonstrates what
> you can do by including xml tags in the text to enhance the spoken
> text.
>
> Note that in order to show the user interface feature (audio
> control),
> I had to make use of an api call (to get the desktop window handle).
> If you don't like using dynawrap to call api's then you can remove
> that.


I tried the script 'out of the box', from your attachment, with
whatever default installation of Sapi that my OEM WXP SP2 installation
did. I get two spoken phrases, and then an error message about the
time the volumen control appears. My sapi.dll is version 5.1.4111.0

Script: C:\Documents and Settings\Paul\My
Documents\vbScript\wshSAPIText2SpeechDemo.wsf
Line: 94
Char: 2
Error: 0x80045043
Code: 80045043
Source: (null)

Line 94 is:
oSpVoice.Speak sXMLRes, SVSF_PurgeBeforeSpeak Or SVSF_IsXML Or
SVSF_Async

There are three references to this error at MSDN.microsoft.com, two of
which were unique:
SPERR_XML_RESOURCE_NOT_FOUND
0x80045043 (-2147200957)
The XML parser failed to load a required resource (for example, a
voice or phone converter).

SPERR_XML_RESOURCE_NOT_FOUND 0x80045043 -2147200957
The xml parser failed to load a required resource (e.g., voice,
phoneconverter, etc.).

Do you have any ideas on how to diagnose or fix the problem?

-Paul Randall



Re: [code] getting your script to talk to you by mr_unreliable

mr_unreliable
Wed Mar 05 11:31:45 CST 2008

Paul Randall wrote:
> Do you have any ideas on how to diagnose or fix the problem?
>

Paul, as you can probably tell from the script, the xml file
in question is included as a "resource" in the "wsf" file.

I don't happen to have an XPsp2 system handy for testing, but
I can imagine two possible problems.

For one, it may be that the xml file I used somehow got
"discombobulated" when uploaded to the ng. I suggest you
discard the xml file that came with the uploaded script,
and instead get the ORIGINAL xml file, which comes with
the download. If you placed the download in the default
place, you should be able to find the xml file here:

C:\Program Files\Microsoft Speech SDK 5.1\Samples\Common\TTSXmlDemo.xml

The only other thing I can imagine is that the "getResource"
function is not returning the xml intact. You can test this
by taking a look at what you get from "getResource" (for
example by printing it out). Or, you could forget about
using a "resource", and just test that bit by reading the
xml file in directly:

sFileSpec = (see above)
Set oXMLFile = fso.OpenTextFile(sFileSpec, ForReading)
sXML = oXMLFile.ReadAll
oSpVoice.Speak sXML, SVSF_PurgeBeforeSpeak Or SVSF_IsXML Or SVSF_Async

If neither of those suggestions works, then I've run out of
ideas as to how to explain the error.

cheers, jw

Re: [code] getting your script to talk to you by mayayana

mayayana
Wed Mar 05 13:00:51 CST 2008

It doesn't work for me, either, and I'm a fellow
98er. It seems like an awfully complex script
to use as a sample for SAPI. It will work with
just this:

Dim Voice, s
Set Voice = CreateObject("Sapi.SpVoice")
s = "This is a sample."
Voice.Speak s, 2
Set Voice = Nothing

And even the "2" is not needed. There are
some options, though. For instance, spVoice
has a Volume property that can be adjusted.
(I think it goes to 100, but I'm not sure offhand.)

I don't use Dynawrap, so I commented out
that part. But even then I just get the script
hanging in memory, slowing my system doing
who-knows-what until I kill it via Taskmon.
I wonder if it might be a .wsf issue. I've never
used those files, and I have IE 5.00 installed.
(Default Win98SE version.) Maybe that's too old
for .wsf? (Frankly, I wouldn't mind that. As far
as I'm concerned, life's too short for XML. :)


> Paul Randall wrote:
> > Do you have any ideas on how to diagnose or fix the problem?
> >
>
> Paul, as you can probably tell from the script, the xml file
> in question is included as a "resource" in the "wsf" file.
>
> I don't happen to have an XPsp2 system handy for testing, but
> I can imagine two possible problems.
>
> For one, it may be that the xml file I used somehow got
> "discombobulated" when uploaded to the ng. I suggest you
> discard the xml file that came with the uploaded script,
> and instead get the ORIGINAL xml file, which comes with
> the download. If you placed the download in the default
> place, you should be able to find the xml file here:
>
> C:\Program Files\Microsoft Speech SDK 5.1\Samples\Common\TTSXmlDemo.xml
>
> The only other thing I can imagine is that the "getResource"
> function is not returning the xml intact. You can test this
> by taking a look at what you get from "getResource" (for
> example by printing it out). Or, you could forget about
> using a "resource", and just test that bit by reading the
> xml file in directly:
>
> sFileSpec = (see above)
> Set oXMLFile = fso.OpenTextFile(sFileSpec, ForReading)
> sXML = oXMLFile.ReadAll
> oSpVoice.Speak sXML, SVSF_PurgeBeforeSpeak Or SVSF_IsXML Or SVSF_Async
>
> If neither of those suggestions works, then I've run out of
> ideas as to how to explain the error.
>
> cheers, jw



Re: [code] getting your script to talk to you by Paul

Paul
Wed Mar 05 17:20:11 CST 2008


"mr_unreliable" <kindlyReplyToNewsgroup@notmail.com> wrote in message
news:uU4JcXufIHA.5900@TK2MSFTNGP02.phx.gbl...
> Paul Randall wrote:
> > Do you have any ideas on how to diagnose or fix the problem?
>>
>
> Paul, as you can probably tell from the script, the xml file
> in question is included as a "resource" in the "wsf" file.
>
> I don't happen to have an XPsp2 system handy for testing, but
> I can imagine two possible problems.
>
> For one, it may be that the xml file I used somehow got
> "discombobulated" when uploaded to the ng. I suggest you
> discard the xml file that came with the uploaded script,
> and instead get the ORIGINAL xml file, which comes with
> the download. If you placed the download in the default
> place, you should be able to find the xml file here:
>
> C:\Program Files\Microsoft Speech SDK
> 5.1\Samples\Common\TTSXmlDemo.xml
>
> The only other thing I can imagine is that the "getResource"
> function is not returning the xml intact. You can test this
> by taking a look at what you get from "getResource" (for
> example by printing it out). Or, you could forget about
> using a "resource", and just test that bit by reading the
> xml file in directly:
>
> sFileSpec = (see above)
> Set oXMLFile = fso.OpenTextFile(sFileSpec, ForReading)
> sXML = oXMLFile.ReadAll
> oSpVoice.Speak sXML, SVSF_PurgeBeforeSpeak Or SVSF_IsXML Or
> SVSF_Async
>
> If neither of those suggestions works, then I've run out of
> ideas as to how to explain the error.

Thanks for the hints. I looked and the XML resource and figured out
the problem. In Control Panel, the Speech tool showed that I have
only two voices installed: Microsoft Annie and Microsoft Sam. The
Demo requires Microsoft Mary and Microsoft Mike. Doing replaces of
the voice names everywhere in the .WSF solved my problem.

Nice demo.

-Paul Randall