-
Notifications
You must be signed in to change notification settings - Fork 28
/
say.go
38 lines (34 loc) · 1.93 KB
/
say.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
/*
** Say
** Create a voice notification
*/
package mack
// Say triggers a voice notification that will read the text provided in a given voice.
// mack.Say("Hi in Bruce's voice!", "Bruce") // Have the "Bruce" voice read the text
// mack.Say("Hi in default voice!") // Have the system default voice read the text
//
// Parameters:
//
// text string // Required - What the system voice will say
// voice string // Optional - The name of the system voice, otherwise defaults to system preferences
// // Voice list located at: /System/Library/SpeechBase/Voices
// // ex. Agnes, Albert, Alex, Alice Compact, Alva Compact, Amelie Compact, Anna Compact, BadNews, Bahh, Bells, Boing, Bruce,
// // Bubbles, Carmit Compact, Cellos, Damayanti Compact, Daniel Compact, Deranged, Diego Compact, Ellen Compact,
// // Fiona Compact, Fred, GoodNews, Hysterical, Ioana Compact, Joana Compact, Junior, Kanya Compact, Karen Compact, Kathy,
// // Kyoko Compact, Laura Compact, Lekha Compact, Luciana Compact, Mariska Compact, Mei-Jia Compact, Melina Compact,
// // Milena Compact, Moira Compact, Monica Compact, Nora Compact, Organ, Paulina Compact, Princess, Ralph, Samantha Compact,
// // Sara Compact, Satu Compact, Sin-ji Compact, Tarik Compact, Tessa Compact, Thomas Compact, Ting-Ting Compact, Trinoids,
// // Veena Compact, Vicki, Victoria, Whisper, Xander Compact, Yelda Compact, Yuna Compact, Zarvox, Zosia Compact, Zuzana Compact
func Say(text string, options ...string) error {
_, err := run(buildSay(text, options))
return err
}
// Parse the say options and build the command
func buildSay(text string, options []string) string {
var voice string
if len(options) > 0 && options[0] != "" {
voice = "using " + wrapInQuotes(options[0])
}
text = wrapInQuotes(text)
return build("say", text, voice)
}