Documentation ¶
Index ¶
- Variables
- type Speech
- func (s *Speech) AddPackTask(dataEntries map[string]string, ...) error
- func (s *Speech) AddPackTaskWithCustomOptions(dataEntries map[string]string, entriesOption map[string][]communicate.Option, ...) error
- func (s *Speech) AddSingleTask(text string, output io.Writer) error
- func (s *Speech) GetVoiceList() ([]Voice, error)
- func (s *Speech) StartTasks() error
- type Tasker
- type Voice
- type VoiceManager
Constants ¶
This section is empty.
Variables ¶
var (
NoPackTaskEntries = errors.New("no pack task entries")
)
Functions ¶
This section is empty.
Types ¶
type Speech ¶
type Speech struct {
// contains filtered or unexported fields
}
func NewSpeech ¶
func NewSpeech(options ...communicate.Option) (*Speech, error)
NewSpeech creates a new Speech instance. It takes a variadic parameter: - options: a slice of communicateOption.Option that will be used to configure the Speech instance. The function returns a pointer to the newly created Speech instance and an error if any occurs during the creation process.
func (*Speech) AddPackTask ¶
func (s *Speech) AddPackTask(dataEntries map[string]string, entryCreator func(name string) (io.Writer, error), output io.Writer, metaData ...map[string]any) error
AddPackTask adds a pack task to the speech. It takes four parameters: - dataEntries: a map where the key is the entry name and the value is the entry text to be synthesized. - entryCreator: a function that creates a writer for each entry. This can be a packer context related writer, such as a zip writer. - output: the output of the pack task, which will finally be written into a file. - metaData: optional parameter. It is the data which will be serialized into a json file. The name uses the key and value as the key-value pair. The function returns an error if there are no pack task entries.
func (*Speech) AddPackTaskWithCustomOptions ¶
func (s *Speech) AddPackTaskWithCustomOptions(dataEntries map[string]string, entriesOption map[string][]communicate.Option, entryCreator func(name string) (io.Writer, error), output io.Writer, metaData ...map[string]any) error
AddPackTaskWithCustomOptions adds a pack task with options to the speech. It takes four parameters: - dataEntries: a map where the key is the entry name and the value is the entry text to be synthesized. - entriesOption: a map where the key is the entry name and the value is the entry option to be used for the entry. - entryCreator: a function that creates a writer for each entry. This can be a packer context related writer, such as a zip writer. - output: the output of the pack task, which will finally be written into a file. - metaData: optional parameter. It is the data which will be serialized into a json file. The name uses the key and value as the key-value pair. The function returns an error if there are no pack task entries.
func (*Speech) AddSingleTask ¶
AddSingleTask adds a single task to the speech. It takes two parameters: - text: the text to be synthesized. - output: the output of the single task, which will finally be written into a file. The function returns an error if there is an issue with the communication.
func (*Speech) GetVoiceList ¶
GetVoiceList retrieves the list of voices available for the speech. It returns a slice of Voice objects and an error if any occurs during the retrieval process.
func (*Speech) StartTasks ¶
StartTasks starts all the tasks in the Speech instance. It creates a WaitGroup and adds the total number of tasks to it. Then it starts each task in a separate goroutine and waits for all of them to finish. The function returns an error if any occurs during the execution of the tasks.
type Voice ¶
type Voice struct { Name string `json:"Name"` DisplayName string `json:"DisplayName"` LocalName string `json:"LocalName"` ShortName string `json:"ShortName"` Gender string `json:"Gender"` Locale string `json:"Locale"` LocaleName string `json:"LocaleName"` SampleRateHertz string `json:"SampleRateHertz"` VoiceType string `json:"VoiceType"` Status string `json:"Status"` WordsPerMinute string `json:"WordsPerMinute"` }
type VoiceManager ¶
type VoiceManager struct { }
func NewVoiceManager ¶
func NewVoiceManager() *VoiceManager
func (*VoiceManager) ListVoices ¶
func (m *VoiceManager) ListVoices() ([]Voice, error)