"FT" <[EMAIL PROTECTED]> wrote

Caveat: I know nothing about MS SAPI.

The following code illustrates how to speak a text file
in a specific voice in Visual Basic. This example assumes
a text file (ttstemp.txt) containing the text to be spoken
already exists. ISpeechVoice.SpeakStream is used here
to speak an SpFileStream that
has been bound to the file.

Notice this says nothing about writing to a file.

Dim FileName As String
Dim FileStream As New SpFileStream
Dim Voice As  SpVoice
'Create SAPI voice
Set Voice = New SpVoice
'Assume that ttstemp.txt exists
FileName = "c:\ttstemp.txt"
'Open the text file
FileStream.Open FileName, SSFMOpenForRead, True
'Select Microsoft Sam voice
Set Voice.voice = voice.GetVoices("Name=Microsoft Sam",
"Language=409").Item(0)
'Speak the file stream
Voice.SpeakStream FileStream
'Close the Stream
FileStream.Close
'Release the objects
Set FileStream = Nothing
Set Voice = Nothing

And the code nowhere writes to a file. The only file
mentioned is the one read.

So, in this example it assigns a file stream to the file opened then
connects to the SAPI Speak method to save it.

No, it calls the Speak method to speak it.
It never saves anything so far as I can see.

did above I get only the data spoken and the file with 0 bytes in it.

I'm not sure which file has zero bytes. I hope not the one being spoken!
But it sounds to me like your code is doing what the VB code does.

I have tried looking everywhere for the file stream connection and can
not seem to find the method to do so.

I have no idea what you mean by this.
Where are you looking? This is a COM object which is in the MS library.
You will need to access it via PythonWin or ctypes or a Python
wrapper of some sort. But the fact you are getting it to speak suggests
you have succeeded in that already.

I'm confused about why you think it should be saving anything?

--
Alan Gauld
Author of the Learn to Program web site
http://www.freenetpages.co.uk/hp/alan.gauld

_______________________________________________
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor

Reply via email to