Input
AudioInput
dataclass
Static audio to be used as input for the VoicePipeline.
Source code in src/cai/sdk/agents/voice/input.py
40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 |
|
buffer
instance-attribute
buffer: NDArray[int16 | float32]
A buffer containing the audio data for the agent. Must be a numpy array of int16 or float32.
frame_rate
class-attribute
instance-attribute
frame_rate: int = DEFAULT_SAMPLE_RATE
The sample rate of the audio data. Defaults to 24000.
sample_width
class-attribute
instance-attribute
sample_width: int = 2
The sample width of the audio data. Defaults to 2.
channels
class-attribute
instance-attribute
channels: int = 1
The number of channels in the audio data. Defaults to 1.
to_audio_file
to_audio_file() -> tuple[str, BytesIO, str]
Returns a tuple of (filename, bytes, content_type)
Source code in src/cai/sdk/agents/voice/input.py
58 59 60 |
|
to_base64
to_base64() -> str
Returns the audio data as a base64 encoded string.
Source code in src/cai/sdk/agents/voice/input.py
62 63 64 65 66 67 68 69 70 71 |
|
StreamedAudioInput
Audio input represented as a stream of audio data. You can pass this to the VoicePipeline
and then push audio data into the queue using the add_audio
method.
Source code in src/cai/sdk/agents/voice/input.py
74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 |
|
add_audio
async
add_audio(audio: NDArray[int16 | float32])
Adds more audio data to the stream.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
audio
|
NDArray[int16 | float32]
|
The audio data to add. Must be a numpy array of int16 or float32. |
required |
Source code in src/cai/sdk/agents/voice/input.py
82 83 84 85 86 87 88 |
|