speechrequest

package
v0.3.2 Latest Latest
Warning

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

Go to latest
Published: Dec 23, 2023 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BytesToIntVAD

func BytesToIntVAD(stream opus.OggStream, data []byte, die bool, isOpus bool) [][]byte

func BytesToSamples

func BytesToSamples(buf []byte) []int16

func SplitVAD

func SplitVAD(buf []byte) [][]byte

Types

type SpeechRequest

type SpeechRequest struct {
	Device         string
	Session        string
	FirstReq       []byte
	Stream         interface{}
	IsKG           bool
	IsIG           bool
	MicData        []byte
	DecodedMicData []byte
	PrevLen        int
	PrevLenRaw     int
	InactiveFrames int
	ActiveFrames   int
	VADInst        *webrtcvad.VAD
	LastAudioChunk []byte
	IsOpus         bool
	OpusStream     *opus.OggStream
}

func ReqToSpeechRequest

func ReqToSpeechRequest(req interface{}) SpeechRequest

Converts a vtt.*Request to a SpeechRequest, which allows functions like DetectEndOfSpeech to work

func (*SpeechRequest) DetectEndOfSpeech

func (req *SpeechRequest) DetectEndOfSpeech() bool

Uses VAD to detect when the user stops speaking

func (*SpeechRequest) GetNextStreamChunk

func (req *SpeechRequest) GetNextStreamChunk() ([]byte, error)

Returns the next chunk in the stream as 16000 Hz PCM

func (*SpeechRequest) GetNextStreamChunkOpus

func (req *SpeechRequest) GetNextStreamChunkOpus() ([]byte, error)

Returns next chunk in the stream as whatever the original format is (OPUS 99% of the time)

func (*SpeechRequest) OpusDecode

func (req *SpeechRequest) OpusDecode(chunk []byte) []byte

func (*SpeechRequest) OpusDetect

func (req *SpeechRequest) OpusDetect() bool

Jump to

Keyboard shortcuts

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