forked from coapp/jscript-toolkit
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Speech.js
34 lines (32 loc) · 1.05 KB
/
Speech.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
//-----------------------------------------------------------------------
// <copyright>
// Copyright (c) 2010 Garrett Serack. All rights reserved.
// </copyright>
//-----------------------------------------------------------------------
var Speech = {
IsSpeaking : false,
Started : false,
SVSFlagsAsync:1,
SVSFPurgeBeforeSpeak:2,
Voice : WScript.CreateObject("SAPI.SpVoice", "Speech_"),
Speak : function(text) {
text = FormatArguments(arguments);
this.Voice.Speak( text , this.SVSFPurgeBeforeSpeak );
},
SpeakAsync : function(text) {
text = FormatArguments(arguments);
Speech.Started = false;
this.Voice.Speak( text , this.SVSFlagsAsync );
while( !Speech.Started ) WScript.Sleep(1);
},
Stop : function () {
this.Voice.Speak("", this.SVSFPurgeBeforeSpeak);
},
_EndStream: function () {
Speech.IsSpeaking = false;
},
_StartStream: function () {
Speech.Started = Speech.IsSpeaking = true;
}
};
Speech;