diff --git a/src/anam/_streaming.py b/src/anam/_streaming.py index 7db9990..f582818 100644 --- a/src/anam/_streaming.py +++ b/src/anam/_streaming.py @@ -669,20 +669,7 @@ def send_user_audio( sample_rate: int, num_channels: int, ) -> None: - """Send raw user audio samples to Anam for processing. - - This method accepts 16-bit PCM samples and adds them to the audio buffer for transmission via WebRTC. - The audio track is created lazily when first audio arrives. - Audio is only added to the buffer after the connection is established, to avoid accumulating stale audio. - - Args: - audio_bytes: Raw audio data (16-bit PCM). - sample_rate: Sample rate of the input audio (Hz). - num_channels: Number of channels in the input audio (1=mono, 2=stereo). - - Raises: - RuntimeError: If peer connection is not initialized. - """ + """Send raw user audio samples to Anam for processing.""" if not self._peer_connection: raise RuntimeError("Peer connection not initialized. Call connect() first.") if num_channels != 1 and num_channels != 2: diff --git a/src/anam/client.py b/src/anam/client.py index 73075d3..235aba3 100644 --- a/src/anam/client.py +++ b/src/anam/client.py @@ -587,6 +587,35 @@ def create_agent_audio_input_stream( raise SessionError("Not connected") return self._client._streaming_client.create_agent_audio_input_stream(config) + def send_user_audio( + self, + audio_bytes: bytes, + sample_rate: int, + num_channels: int, + ) -> None: + """Send raw user audio samples to Anam for processing. + + This method accepts 16-bit PCM samples and adds them to the audio buffer + for transmission via WebRTC. The audio track is created lazily when first + audio arrives. Audio is only added to the buffer after the connection is + established, to avoid accumulating stale audio. + + Args: + audio_bytes: Raw audio data (16-bit PCM). + sample_rate: Sample rate of the input audio (Hz). + num_channels: Number of channels in the input audio (1=mono, 2=stereo). + + Raises: + SessionError: If not connected. + """ + if not self._client._streaming_client: + raise SessionError("Not connected") + self._client._streaming_client.send_user_audio( + audio_bytes=audio_bytes, + sample_rate=sample_rate, + num_channels=num_channels, + ) + def video_frames(self) -> AsyncIterator[VideoFrame]: """Get video frames as an async iterator.