Documentation
¶
Overview ¶
Package audio provides microphone capture and speaker playback for the voice-interview example. It is a thin adapter over the shared pure-Go runtime/audio Session (purego/dlopen PortAudio — no CGO), preserving the capture/playback API the interview controller depends on.
Index ¶
Constants ¶
const ( // InputSampleRate is the sample rate for microphone input (16kHz for speech) InputSampleRate = 16000 // OutputSampleRate is the sample rate for speaker output (24kHz for TTS) OutputSampleRate = 24000 // Channels is mono audio Channels = 1 // InputFramesPerBuffer is 100ms of audio at 16kHz InputFramesPerBuffer = 1600 // OutputFramesPerBuffer is 40ms of audio at 24kHz OutputFramesPerBuffer = 960 // EnergyThreshold for voice activity detection EnergyThreshold = 500 )
Variables ¶
This section is empty.
Functions ¶
func BytesToInt16 ¶
BytesToInt16 converts bytes to int16 audio samples (little-endian PCM16)
func HasVoiceActivity ¶
HasVoiceActivity checks if audio has significant energy
Types ¶
type AudioCapture ¶
type AudioCapture struct {
// contains filtered or unexported fields
}
AudioCapture handles microphone input
func (*AudioCapture) AudioChunks ¶
func (ac *AudioCapture) AudioChunks() <-chan []byte
AudioChunks returns the channel for receiving audio data
func (*AudioCapture) EnergyLevels ¶
func (ac *AudioCapture) EnergyLevels() <-chan float64
EnergyLevels returns the channel for receiving audio energy levels
type AudioPlayback ¶
type AudioPlayback struct {
// contains filtered or unexported fields
}
AudioPlayback handles speaker output
func (*AudioPlayback) AudioInput ¶
func (ap *AudioPlayback) AudioInput() chan<- []byte
AudioInput returns the channel for sending audio data to play
func (*AudioPlayback) Start ¶
func (ap *AudioPlayback) Start(ctx context.Context) error
Start begins audio playback
func (*AudioPlayback) Write ¶
func (ap *AudioPlayback) Write(data []byte) error
Write sends audio data for playback
type AudioSystem ¶
type AudioSystem struct {
// contains filtered or unexported fields
}
AudioSystem manages both capture and playback over one shared audio session.
func NewAudioSystem ¶
func NewAudioSystem() (*AudioSystem, error)
NewAudioSystem creates a new audio system backed by the shared runtime/audio Session (16kHz capture, 24kHz playback).
func (*AudioSystem) Capture ¶
func (as *AudioSystem) Capture() *AudioCapture
Capture returns the audio capture component
func (*AudioSystem) Playback ¶
func (as *AudioSystem) Playback() *AudioPlayback
Playback returns the audio playback component