Esempio n. 1
0
// 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))
}
Esempio n. 2
0
// 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
}
Esempio n. 3
0
// 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
}
Esempio n. 4
0
// 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
}