예제 #1
0
파일: voices.go 프로젝트: happyalu/goflite
// Add a voice to list of available voices, given a name the voice
// will be known as, and the path to the flitevox file. Preferably use
// absolute voice paths.  If no voices are added, the "slt" voice is
// always supported
func (voices *voxbase) addVoice(name, path string) error {
	voices.mutex.Lock()
	defer voices.mutex.Unlock()
	_, present := voices.flitevox[name]
	if present {
		return errors.New("Voice with given name already present")
	}

	pathC := C.CString("file://" + path)
	defer C.free(unsafe.Pointer(pathC))

	v := C.flite_voice_select(pathC)
	if v == nil {
		return errors.New("Voice File could not be loaded")
	}

	voices.flitevox[name] = v
	return nil
}
예제 #2
0
파일: voices.go 프로젝트: happyalu/goflite
func newVoxBase() *voxbase {
	s := &voxbase{flitevox: make(map[string]flitevoice)}

	// Add Default Voice
	name := C.CString(defaultVoiceName)
	v := C.flite_voice_select(name)
	C.free(unsafe.Pointer(name))

	if v != nil {
		name := C.GoString(v.name)
		if name == defaultVoiceName {
			s.flitevox[defaultVoiceName] = v
		} else {
			C.delete_voice(v)
		}
	}

	return s
}