// Voices stored in voxbase are C structures that should be freed func (voices *voxbase) free() { voices.mutex.Lock() defer voices.mutex.Unlock() for name, voice := range voices.flitevox { if name != defaultVoiceName { // Default voice is linked in, don't remove it C.delete_voice(voice) } } }
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 }