Created
June 2, 2017 02:27
-
-
Save moutend/4ca1c09d041810c18377ce648f1825f3 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// +build windows | |
package main | |
import ( | |
"fmt" | |
"log" | |
"github.com/go-ole/go-ole" | |
"github.com/moutend/go-wss" | |
) | |
func main() { | |
var err error | |
if err = run(); err != nil { | |
log.Fatal(err) | |
} | |
return | |
} | |
func run() (err error) { | |
ole.RoInitialize(1) | |
//defer ole.RoUninitialize() | |
var ins *ole.IInspectable | |
str := "Windows.Media.SpeechSynthesis.SpeechSynthesizer" | |
if ins, err = ole.RoActivateInstance(str); err != nil { | |
return | |
} | |
var synth *wss.ISpeechSynthesizer | |
if err = ins.PutQueryInterface(wss.IID_ISpeechSynthesizer, &synth); err != nil { | |
return | |
} | |
var voice *wss.IVoiceInformation | |
if err = synth.GetVoice(&voice); err != nil { | |
return | |
} | |
var name ole.HString | |
if err = voice.GetDisplayName(&name); err != nil { | |
return | |
} | |
fmt.Printf("default voice: %v\n", name.String()) | |
return | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment