コード例 #1
0
ファイル: mactts.go プロジェクト: jkl1337/mactts
// SetExtAudioFile sets the channel's output destination to an extended audio file, or back to the speakers, if eaf is nil.
func (c *Channel) SetExtAudioFile(eaf *ExtAudioFile) error {
	var cref unsafe.Pointer
	if eaf != nil {
		cref = unsafe.Pointer(eaf.ceaf)
	}
	return osError(C.mactts_set_property_ptr(c.csc, C.kSpeechOutputToExtAudioFileProperty, cref))
}
コード例 #2
0
ファイル: mactts.go プロジェクト: jkl1337/mactts
// SetDone sets a synthesis completion callback function for the speech channel.
func (c *Channel) SetDone(done func()) error {
	cbp := C.go_speechdone_cb
	oserr := C.mactts_set_property_ptr(c.csc, C.kSpeechSpeechDoneCallBack, cbp)
	if oserr != 0 {
		return osError(oserr)
	}
	c.done = done
	return nil
}
コード例 #3
0
ファイル: mactts.go プロジェクト: jkl1337/mactts
// SetPhonemeCb sets a callback function invoked before each phoneme is synthesized.
func (c *Channel) SetPhonemeCb(phonemeCb func(PhonemeCode)) error {
	cbp := C.go_speechphoneme_cb
	oserr := C.mactts_set_property_ptr(c.csc, C.kSpeechPhonemeCallBack, cbp)
	if oserr != 0 {
		return osError(oserr)
	}
	c.phonemeCb = phonemeCb
	return nil
}
コード例 #4
0
ファイル: mactts.go プロジェクト: jkl1337/mactts
// NewChannel creates a speech synthesizer speech channel with option voice specification. If no voice is provided, the system voice is used.
func NewChannel(voice *VoiceSpec) (*Channel, error) {
	var c Channel

	oserr := C.NewSpeechChannel((*C.VoiceSpec)(voice), &c.csc)
	if oserr != 0 {
		return nil, osError(oserr)
	}

	refCon := unsafe.Pointer(&c)
	oserr = C.mactts_set_property_ptr(c.csc, C.kSpeechRefConProperty, refCon)
	if oserr != 0 {
		disposeSpeechChannel(&c)
		return nil, osError(oserr)
	}

	runtime.SetFinalizer(&c, disposeSpeechChannel)
	return &c, nil
}