sapi

package module
v0.0.0-...-5f813a9 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 8, 2024 License: Apache-2.0 Imports: 2 Imported by: 0

README

sapi-go

A simple Go Windows SAPI TTS wrapper

Main library gotten from https://github.com/DeepHorizons/tts, so thank you as it was the base for this.

Only supports SAPI.

Usage

After initializing your module, get the library with:

go get github.com/Edw590/sapi-go@latest

Check the example on the examples folder.

Documentation

Overview

Package sapi has its documentation on: https://learn.microsoft.com/en-us/previous-versions/windows/desktop/ee125640(v=vs.85)

Index

Constants

View Source
const (
	SVSFDefault          = 0
	SVSFlagsAsync        = 1
	SVSFPurgeBeforeSpeak = 2
	SVSFIsFilename       = 4
	SVSFIsXML            = 8
	SVSFIsNotXML         = 16
	SVSFPersistXML       = 32

	// Normalizer Flags
	SVSFNLPSpeakPunc = 64

	// Masks
	SVSFNLPMask     = 64
	SVSFVoiceMask   = 127
	SVSFUnusedFlags = -128
)
View Source
const (
	SVPNormal = 0
	SVPAlert  = 1
	SVPOver   = 2
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Sapi

type Sapi struct {
	// contains filtered or unexported fields
}

Sapi is a structure that wraps the SAPI COM object

func NewSapi

func NewSapi() (*Sapi, error)

NewSapi creates the SAPI TTS object. Call ole.CoInitialize() or ole.CoInitializeEx() before calling this function.

func (*Sapi) GetPriority

func (s *Sapi) GetPriority() (int, error)

GetPriority gets the priority level of the voice.

func (*Sapi) GetRate

func (s *Sapi) GetRate() (int, error)

GetRate gets the speaking rate of the voice.

func (*Sapi) GetVolume

func (s *Sapi) GetVolume() (int, error)

GetVolume gets the base volume (loudness) level of the voice.

func (*Sapi) Pause

func (s *Sapi) Pause() error

Pause pauses the voice at the nearest alert boundary and closes the output device, allowing it to be used by other voices.

func (*Sapi) Resume

func (s *Sapi) Resume() error

Resume causes the voice to resume speaking when paused.

func (*Sapi) SetPriority

func (s *Sapi) SetPriority(priority int) error

SetPriority sets the priority level of the voice.

func (*Sapi) SetRate

func (s *Sapi) SetRate(rate int) error

SetRate sets the speaking rate of the voice.

func (*Sapi) SetVolume

func (s *Sapi) SetVolume(volume int) error

SetVolume sets the base volume (loudness) level of the voice.

func (*Sapi) Skip

func (s *Sapi) Skip(num_items int) (int, error)

Skip skips the voice forward or backward by the specified number of "Sentence" items within the current input text stream.

func (*Sapi) Speak

func (s *Sapi) Speak(message string, flags int) (int, error)

Speak initiates the speaking of a text string, a text file, an XML file, or a wave file by the voice.

func (*Sapi) WaitUntilDone

func (s *Sapi) WaitUntilDone(ms_timeout int) (bool, error)

WaitUntilDone blocks the caller until either the voice has finished speaking or the specified time interval has elapsed.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL