Skip to content

Instantly share code, notes, and snippets.

@moutend
Created June 2, 2017 02:27
Show Gist options
  • Save moutend/4ca1c09d041810c18377ce648f1825f3 to your computer and use it in GitHub Desktop.
Save moutend/4ca1c09d041810c18377ce648f1825f3 to your computer and use it in GitHub Desktop.
// +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