Documentation
¶
Index ¶
- Constants
- Variables
- func ClearDenoiseModelCache()
- func ClearVADDetectorCache()
- func ValidateDenoiseConfig(cfg DenoiseConfig) error
- func ValidateVADConfig(cfg VADConfig) error
- type CodecConfig
- type DenoiseConfig
- type Denoiser
- type FrameDecoder
- type ProcessingConfig
- type ProcessingFinishResult
- type ProcessingFrameResult
- type ProcessingSession
- func (s *ProcessingSession) AudioLevel() SignalStats
- func (s *ProcessingSession) Close() error
- func (s *ProcessingSession) Codec() string
- func (s *ProcessingSession) DecodeOpusFrame(payload []byte) error
- func (s *ProcessingSession) Finish() (VADResult, error)
- func (s *ProcessingSession) FinishWithOutput() (result ProcessingFinishResult, err error)
- func (s *ProcessingSession) MaxPCMSamples() int
- func (s *ProcessingSession) ProcessFrame(payload []byte) (ProcessingFrameResult, error)
- func (s *ProcessingSession) ProcessOpusFrame(payload []byte) (ProcessingFrameResult, error)
- func (s *ProcessingSession) SampleRate() int
- type SignalStats
- type SilenceGap
- type SpeechSegment
- type VADConfig
- type VADEvent
- type VADEventType
- type VADResult
- type VADRunner
Constants ¶
View Source
const ( CodecOpus = "opus" CodecSpeex = "speex" CodecLC3 = "lc3" )
View Source
const ( DefaultSampleRate = 16000 DefaultVADModelVersion = "v5" DefaultVADThreshold = 0.35 DefaultVADMinSilenceDurationMS = 500 DefaultVADSoftSilenceDurationMS = 64 DefaultVADMaxSpeechDurationMS = 30000 DefaultVADSpeechPadMS = 30 DefaultVADMaxBufferedSeconds = 600 DenoiseProviderNone = "none" DenoiseProviderDPDFNet = "dpdfnet" DenoiseProviderGTCRN = "gtcrn" DefaultDenoiseProvider = DenoiseProviderDPDFNet DefaultDenoiseWindowSamples = 320 DefaultDenoiseFrameSamples = 160 DefaultDenoiseInputName = "spec" DefaultDenoiseStateInputName = "state_in" DefaultDenoiseOutputName = "spec_e" DefaultDenoiseStateOutputName = "state_out" DefaultGTCRNWindowSamples = 512 DefaultGTCRNFrameSamples = 160 DefaultGTCRNInputName = "mix" DefaultGTCRNOutputName = "enh" )
Variables ¶
View Source
var ( ErrOpusDecoderInit = errors.New("opus decoder init failed") ErrOpusDecode = errors.New("opus decode failed") ErrSpeexDecoderInit = errors.New("speex decoder init failed") ErrSpeexDecode = errors.New("speex decode failed") ErrSpeexClose = errors.New("speex close failed") ErrLC3DecoderInit = errors.New("lc3 decoder init failed") ErrLC3Decode = errors.New("lc3 decode failed") ErrLC3Close = errors.New("lc3 close failed") ErrAudioDecode = errors.New("audio decode failed") ErrAudioCodecInvalid = errors.New("audio codec invalid") )
View Source
var ( ErrAudioPCMBufferLimit = errors.New("audio pcm buffer limit exceeded") ErrAudioVADDetect = errors.New("audio vad detect failed") ErrAudioVADClose = errors.New("audio vad close failed") ErrAudioVADInvalidConfig = errors.New("audio vad config invalid") ErrAudioDenoiseInit = errors.New("audio denoise init failed") ErrAudioDenoiseProcess = errors.New("audio denoise process failed") ErrAudioDenoiseClose = errors.New("audio denoise close failed") ErrAudioDenoiseConfig = errors.New("audio denoise config invalid") ErrAudioProcessingClosed = errors.New("audio processing session closed") )
Functions ¶
func ClearDenoiseModelCache ¶
func ClearDenoiseModelCache()
func ClearVADDetectorCache ¶
func ClearVADDetectorCache()
func ValidateDenoiseConfig ¶
func ValidateDenoiseConfig(cfg DenoiseConfig) error
func ValidateVADConfig ¶
Types ¶
type CodecConfig ¶
type DenoiseConfig ¶
type DenoiseConfig struct {
Provider string
ModelPath string
InputName string
StateInputName string
OutputName string
StateOutputName string
SampleRate int
WindowSamples int
FrameSamples int
Enabled bool
}
func NormalizeDenoiseConfig ¶
func NormalizeDenoiseConfig(cfg DenoiseConfig) DenoiseConfig
type Denoiser ¶
type Denoiser interface {
Enabled() bool
Process(samples []float32) ([]float32, error)
Flush() ([]float32, error)
Close() error
}
func NewDenoiser ¶
func NewDenoiser(cfg DenoiseConfig) (Denoiser, error)
type FrameDecoder ¶
type FrameDecoder interface {
Decode(payload []byte, buffer []float32) ([]float32, error)
Close() error
}
func NewFrameDecoder ¶
func NewFrameDecoder(cfg CodecConfig) (FrameDecoder, []float32, error)
type ProcessingConfig ¶
type ProcessingConfig struct {
Denoise DenoiseConfig
Codec CodecConfig
VAD VADConfig
}
type ProcessingFinishResult ¶ added in v1.0.1
type ProcessingFrameResult ¶
type ProcessingSession ¶
type ProcessingSession struct {
// contains filtered or unexported fields
}
func NewProcessingSession ¶
func NewProcessingSession(logger zerolog.Logger, cfg ProcessingConfig) (*ProcessingSession, error)
func (*ProcessingSession) AudioLevel ¶
func (s *ProcessingSession) AudioLevel() SignalStats
func (*ProcessingSession) Close ¶
func (s *ProcessingSession) Close() error
func (*ProcessingSession) Codec ¶
func (s *ProcessingSession) Codec() string
func (*ProcessingSession) DecodeOpusFrame ¶
func (s *ProcessingSession) DecodeOpusFrame(payload []byte) error
func (*ProcessingSession) Finish ¶
func (s *ProcessingSession) Finish() (VADResult, error)
func (*ProcessingSession) FinishWithOutput ¶ added in v1.0.1
func (s *ProcessingSession) FinishWithOutput() (result ProcessingFinishResult, err error)
func (*ProcessingSession) MaxPCMSamples ¶
func (s *ProcessingSession) MaxPCMSamples() int
func (*ProcessingSession) ProcessFrame ¶
func (s *ProcessingSession) ProcessFrame(payload []byte) (ProcessingFrameResult, error)
func (*ProcessingSession) ProcessOpusFrame ¶
func (s *ProcessingSession) ProcessOpusFrame(payload []byte) (ProcessingFrameResult, error)
func (*ProcessingSession) SampleRate ¶
func (s *ProcessingSession) SampleRate() int
type SignalStats ¶
type SignalStats struct {
RMS float64 `json:"rms"`
DBFS float64 `json:"dbfs"`
Peak float32 `json:"peak"`
Silent bool `json:"silent"`
}
func AnalyzeSignal ¶
func AnalyzeSignal(samples []float32) SignalStats
type SilenceGap ¶
type SpeechSegment ¶
type VADEvent ¶
type VADEvent struct {
Type VADEventType `json:"type"`
Segment SpeechSegment `json:"segment"`
Gap SilenceGap `json:"gap"`
HasGap bool `json:"has_gap"`
}
type VADEventType ¶
type VADEventType string
const ( VADEventSpeechStart VADEventType = "speech_start" VADEventSpeechEnd VADEventType = "speech_end" VADEventSoftBoundary VADEventType = "speech_soft_boundary" )
type VADResult ¶
type VADResult struct {
Segments []SpeechSegment `json:"segments"`
Gaps []SilenceGap `json:"gaps"`
AudioLevel SignalStats `json:"audio_level"`
AudioDuration float64 `json:"audio_duration"`
VADLastProb float32 `json:"vad_last_probability"`
VADMaxProb float32 `json:"vad_max_probability"`
SampleRate int `json:"sample_rate"`
SampleCount int `json:"sample_count"`
SegmentCount int `json:"segment_count"`
VADWindows int `json:"vad_windows"`
VADEnabled bool `json:"vad_enabled"`
}
Click to show internal directories.
Click to hide internal directories.