Documentation
¶
Overview ¶
Package capture provides microphone capture using CoreAudio on macOS.
Index ¶
Constants ¶
const ( SampleRate44100 = 44100 // CD quality, used for WAV recording SampleRate24000 = 24000 // Required by OpenAI Realtime API )
Common sample rates.
Variables ¶
var ErrNotSupported = errors.New("audio capture is only supported on macOS")
ErrNotSupported is returned when audio capture is unavailable on the current platform.
Functions ¶
This section is empty.
Types ¶
type AudioHandler ¶
type AudioHandler func(data []byte)
AudioHandler receives mono, 16-bit signed PCM (little-endian) audio chunks.
type Capturer ¶
type Capturer struct {
// contains filtered or unexported fields
}
Capturer configures independent microphone capture runs.
func NewCapturer ¶
NewCapturer creates a capturer with the specified sample rate.
func (*Capturer) Run ¶ added in v1.152.0
func (c *Capturer) Run(ctx context.Context, filePath string, handler AudioHandler, ready func()) (err error)
Run captures until ctx is canceled. A non-empty filePath also records a WAV file. Each invocation is independent. The optional ready callback runs after capture starts. Handlers run synchronously; Run waits for them before returning, so they must not wait for Run. Canceling ctx normally returns nil. Native capture and cleanup failures return an error.