SpFileStream Open Method

Microsoft Speech SDK

Intelligent Interface Technologies Home Page Microsoft Speech SDK

Speech Automation 5.1

Object: SpFileStream

Open Method


The Open method opens a filestream object for reading or writing.

SpFileStream.Open(
     FileName As String,
     [FileMode As SpeechStreamFileMode = SSFMOpenForRead],
     [DoEvents As Boolean = False]
)

Parameters

FileName
Specifies the FileName.
FileMode
[Optional] Specifies the FileMode. Default value is SSFMOpenForRead.
DoEvents
[Optional] When FileMode is SSFMCreateForWrite, DoEvents specifies whether playback of the resulting sound file will generate voice events. Default value is False.

Return Value

None.


Remarks

When the SpFileStream object is used with audio data, the FileMode parameter controls access strictly. That is, the FileMode parameter SFMOpenForRead prevents write access, and the FileMode parameter SSFMCreateForWrite prevents read access. When the SpFileStream object is used with text data, only the SFMOpenForRead FileMode parameter controls access strictly. The FileMode parameter SFMOpenForRead prevents write access, but the SSFMCreateForWrite parameter allows text data to be read as well as written.

When an SpVoice object creates an SPFileStream object, the engine may embed event data in the stream. In order to embed these events in the file stream, it must be opened for writing with the DoEvents parameter set to True. In order to receive these events when the stream is played back, it must be opened for reading with the DoEvents parameter set to True. Several other factors are involved. Please see SpVoice events for further details.

Example

The following code snippet demonstrates the use of an SpFileStream object to capture the output of a voice in a file.

The ISpeechPhraseElement code example demonstrates further use of the SpFileStream object. This example uses a text-to-speech voice to speak into an SpFileStream object, and uses the resulting file as the input for speech recognition.


Dim objVOICE As SpeechLib.SpVoice
Dim objFSTRM As SpeechLib.SpFileStream

Set objVOICE = New SpVoice
Set objFSTRM = New SpFileStream

'Open file path as a stream
Call objFSTRM.Open("c:\VoiceToFile.wav", SSFMCreateForWrite, False)

'Set voice output to the stream and speak
Set objVOICE.AudioOutputStream = objFSTRM
objVOICE.Speak "cee : \ voice to file dot wave", SVSFNLPSpeakPunc 

Call objFSTRM.Close