Documentation
¶
Index ¶
- Constants
- Variables
- func PCMDurationSecs(pcm []byte) float64
- func PCMLevel(pcm []byte) float64
- func PCMToWAV(pcm []byte) []byte
- func RegisterBackend(name Backend, factory Factory) error
- type Backend
- type Capturer
- type Config
- type DeviceInfo
- type Event
- type EventType
- type Factory
- type Player
- type Session
Constants ¶
const ( SampleRate = 16000 Channels = 1 BitsPerSample = 16 BytesPerSample = BitsPerSample / 8 )
Variables ¶
var ( ErrUnsupportedBackend = errors.New("unsupported audio backend") )
Functions ¶
func PCMDurationSecs ¶
PCMDurationSecs returns the duration of PCM audio in seconds.
func RegisterBackend ¶
Types ¶
type Capturer ¶
type Capturer = Session
Capturer is kept as an alias while the app migrates to the session terminology.
func NewCapturer ¶
func NewCapturerWithConfig ¶
type DeviceInfo ¶
type DeviceInfo struct {
ID string `json:"deviceId"`
Name string `json:"label"`
IsDefault bool `json:"isDefault"`
}
DeviceInfo describes a capture device that can be presented to the user.
func ListCaptureDevices ¶
func ListCaptureDevices(cfg Config) ([]DeviceInfo, error)
ListCaptureDevices returns the available microphone devices for the selected backend.
type Player ¶
type Player struct {
// contains filtered or unexported fields
}
Player plays audio through the system's default output device.
func NewPlayer ¶
NewPlayer creates an audio player for TTS output. Call once at app startup; reuse for all playback.
func (*Player) Close ¶
func (p *Player) Close()
Close releases audio resources. Call on app shutdown.
func (*Player) OnFinished ¶
func (p *Player) OnFinished(fn func())
OnFinished sets a callback that fires when playback completes naturally (not when stopped via Stop()).
func (*Player) PlayMP3 ¶
PlayMP3 decodes and plays MP3 audio data. Blocks until playback completes or Stop() is called.
func (*Player) PlayPCM ¶
PlayPCM plays raw PCM audio (16-bit signed int, little-endian, mono). IMPORTANT: The oto context is initialized at 24kHz. Audio with a different sample rate will play at the wrong pitch/speed. Callers must resample to 24kHz before calling this method, or use PlayMP3 which handles decoding.