Documentation ¶
Index ¶
- Constants
- Variables
- func PtimeDuration(ptime int) time.Duration
- type Buffer
- func (f *Buffer) Alloc() []int16
- func (f *Buffer) Close() error
- func (b *Buffer) Elapsed() time.Duration
- func (f *Buffer) FrameSize() int
- func (f *Buffer) Ptime() time.Duration
- func (f *Buffer) ReadFrame() ([]int16, error)
- func (f *Buffer) Release(b []int16)
- func (f *Buffer) SampleRate() int
- func (f *Buffer) UnblockWriter() bool
- func (f *Buffer) Write(p []int16) error
- func (f *Buffer) WriteBlocking(p []int16) error
- func (f *Buffer) WriteFinal() error
- type BufferPool
- type Pool
- type RawReader
- type Reader
- type ReplayReader
- func (r *ReplayReader) Alloc() []int16
- func (r *ReplayReader) Close() error
- func (w *ReplayReader) Elapsed() time.Duration
- func (r *ReplayReader) FrameSize() int
- func (r *ReplayReader) Ptime() time.Duration
- func (r *ReplayReader) ReadFrame() ([]int16, error)
- func (r *ReplayReader) Release(p []int16)
- func (r *ReplayReader) Replay(limit int, fn func(p []int16)) (n int)
- func (r *ReplayReader) SampleRate() int
- type SeekReader
- type WavReader
- func (w *WavReader) Alloc() []int16
- func (w *WavReader) Close() error
- func (w *WavReader) Elapsed() time.Duration
- func (f *WavReader) FrameSize() int
- func (w *WavReader) IsClosed() bool
- func (w *WavReader) Ptime() time.Duration
- func (w *WavReader) Read(buffer []int16) (n int, err error)
- func (w *WavReader) ReadFrame() ([]int16, error)
- func (w *WavReader) Release(p []int16)
- func (f *WavReader) SampleRate() int
Constants ¶
const ( Ptime10ms = time.Millisecond * 10 Ptime20ms = time.Millisecond * 20 Ptime30ms = time.Millisecond * 30 Ptime10 = 10 Ptime20 = 20 Ptime30 = 30 )
const (
DefaultLimit = 0
)
Variables ¶
Functions ¶
func PtimeDuration ¶
Types ¶
type Buffer ¶
type Buffer struct {
// contains filtered or unexported fields
}
Buffer between Reader and Writer. Once internal frame buffer is full, it blocks until either the Reader or Writer processes the next frame.
func (*Buffer) SampleRate ¶
func (*Buffer) UnblockWriter ¶
func (*Buffer) WriteBlocking ¶
func (*Buffer) WriteFinal ¶
type BufferPool ¶
type Pool ¶
type Pool struct {
// contains filtered or unexported fields
}
Pool contains logic of reusing byte slices of various size.
func NewBufferPool ¶
func NewBufferPool() *Pool
type Reader ¶
type Reader interface { io.Closer Elapsed() time.Duration // Clock speed in hertz. (i.e. 16000 for 16Khz) SampleRate() int // Number of 16bit integers per frame. FrameSize() int // Frame duration. Ptime() time.Duration // Release buffer to allow it to be recycled. Release(p []int16) // Allocate a new Frame. Alloc() []int16 // ReadFrame the next Frame. ReadFrame() ([]int16, error) }
16bit PCM reader.
type ReplayReader ¶
type ReplayReader struct {
// contains filtered or unexported fields
}
Rewind reader keeps a buffer of recently read frames. This comes in handy for using Voice-Activity Detection (VAD) to determine utterance windows. Being able to look back "x" number of frames to catch the true beginning of the utterance.
Wraps the backing reader which it utilizes for Buffer management. Buffers are released internally once the buffer is removed from the internal history buffer. When "Close" is called, the entire history buffer is released to the backing reader.
func NewReplayReader ¶
func NewReplayReader(reader Reader, duration time.Duration) *ReplayReader
func (*ReplayReader) Close ¶
func (r *ReplayReader) Close() error
func (*ReplayReader) Elapsed ¶
func (w *ReplayReader) Elapsed() time.Duration
func (*ReplayReader) FrameSize ¶
func (r *ReplayReader) FrameSize() int
Number of 16bit integers per frame.
func (*ReplayReader) ReadFrame ¶
func (r *ReplayReader) ReadFrame() ([]int16, error)
ReadFrame the next Frame.
func (*ReplayReader) Release ¶
func (r *ReplayReader) Release(p []int16)
Release buffer to allow it to be recycled.
func (*ReplayReader) SampleRate ¶
func (r *ReplayReader) SampleRate() int
Clock speed in hertz. (i.e. 16000 for 16Khz)
type SeekReader ¶
type SeekReader struct { io.ReadSeeker io.Closer // contains filtered or unexported fields }
func NewSeekReader ¶
func NewSeekReader(reader io.ReadCloser) *SeekReader
func (*SeekReader) Close ¶
func (s *SeekReader) Close() error
type WavReader ¶
type WavReader struct {
// contains filtered or unexported fields
}