-
Notifications
You must be signed in to change notification settings - Fork 32
/
tts.go
65 lines (53 loc) · 1.62 KB
/
tts.go
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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
package chrome
import "github.com/gopherjs/gopherjs/js"
type Tts struct {
o *js.Object
}
/*
* Types
*/
type TtsEvent struct {
*js.Object
Type string `js:"type"`
CharIndex int64 `js:"charIndex"`
ErrorMessage string `js:"errorMessage"`
}
type TtsVoice struct {
*js.Object
VoiceName string `js:"voiceName"`
Lang string `js:"lang"`
Gender string `js:"gender"`
Remote bool `js:"remote"`
ExtensionId string `js:"extensionId"`
EventTypes []string `js:"eventTypes"`
}
/*
* Methods
*/
// Speak speaks text using a text-to-speech engine.
func (t *Tts) Speak(utterance string, options Object, callback func()) {
t.o.Call("speak", utterance, options, callback)
}
// Stop stops any current speech and flushes the queue of any pending utterances.
// In addition, if speech was paused, it will now be un-paused for the next call to speak.
func (t *Tts) Stop() {
t.o.Call("stop")
}
// Pause pauses speech synthesis, potentially in the middle of an utterance.
// A call to resume or stop will un-pause speech.
func (t *Tts) Pause() {
t.o.Call("pause")
}
// Resume if speech was paused, resumes speaking where it left off.
func (t *Tts) Resume() {
t.o.Call("resume")
}
// IsSpeaking checks whether the engine is currently speaking. On Mac OS X, the result
// is true whenever the system speech engine is speaking, even if the speech wasn't initiated by Chrome.
func (t *Tts) IsSpeaking(callback func(speaking bool)) {
t.o.Call("isSpeaking", callback)
}
// GetVoices gets an array of all available voices.
func (t *Tts) GetVoices(callback func(voices []TtsVoice)) {
t.o.Call("getVoices", callback)
}