Audio out API | Component APIs
Audio out API
The audio out API supports the following methods:
| Method Name | Description |
|---|---|
Play |
Play the given audio data. |
PlayStream |
Stream audio data in chunks for playback. |
GetProperties |
Get the audio device’s properties. |
GetGeometries |
Get all the geometries associated with the audio out component in its current configuration, in the frame of the audio out component. |
Reconfigure |
Reconfigure this resource. |
DoCommand |
Execute model-specific commands that are not otherwise defined by the component API. |
GetResourceName |
Get the ResourceName for this audio out component. |
Close |
Safely shut down the resource and prevent further use. |
API
Play
Play the given audio data.
Parameters:
data( bytes) (required): audio bytes to play.info(viam.components.audio_out.audio_out.AudioInfo) (optional): (optional) information about the audio data such as codec, sample rate, and channel count.extra(Mapping[ str, Any]) (optional): Extra options to pass to the underlying RPC call.timeout( float) (optional): An option to set how long to wait (in seconds) before calling a time-out and closing the underlying RPC call.
Returns:
- None.
Example:
Copy
For more information, see the Python SDK Docs.
Parameters:
ctx(Context): A Context carries a deadline, a cancellation signal, and other values across API boundaries.data(byte)info(utils.AudioInfo)extra(map[string]interface{}): Extra options to pass to the underlying RPC call.
Returns:
- (error): An error, if one occurred.
For more information, see the Go SDK Docs.
Parameters:
audioData(Uint8Array) (required): The audio data to play.audioInfo( AudioInfo) (optional): Information about the audio format (optional, required for raw pcm data).extra(None) (optional)callOptions(CallOptions) (optional)
Returns:
- (Promise)
Example:
Copy
For more information, see the TypeScript SDK Docs.
Parameters:
audioDataUint8List (optional)audioInfoAudioInfo (optional)extraMap < String, dynamic>? (optional)
Returns:
- Future < PlayResponse >
For more information, see the Flutter SDK Docs.
PlayStream
Stream audio data in chunks for playback.
Parameters:
chunks( AsyncIterator[ bytes]) (required): Async iterator of audio data chunks to play.info(viam.components.audio_out.audio_out.AudioInfo) (optional): Information about the audio data such as codec, sample rate, and channel count.extra(Mapping[ str, Any]) (optional): Extra options to pass to the underlying RPC call.timeout( float) (optional): An option to set how long to wait (in seconds) before calling a time-out and closing the underlying RPC call.
Returns:
- None.
Example:
Copy
For more information, see the Python SDK Docs.
Parameters:
ctx(Context): A Context carries a deadline, a cancellation signal, and other values across API boundaries.info(utils.AudioInfo): Information about the audio data such as codec, sample rate, and channel count.chunks(<-chan byte): A receive-only channel of audio data chunks. Close the channel to signal end of stream.extra(map[string]interface{}): Extra options to pass to the underlying RPC call.
Returns:
- (error): An error, if one occurred.
Example:
Copy
For more information, see the Go SDK Docs.
Parameters:
audioInfo( AudioInfo) (required): Information about the audio format (codec, sample rate, channels) that applies to every chunk.chunks(AsyncIterable) (required): Async iterable of audio byte chunks to play in order. extra(None) (optional)callOptions(CallOptions) (optional)
Returns:
- (Promise
)
Example:
Copy
For more information, see the TypeScript SDK Docs.
Parameters:
audioInfoAudioInfo (required): Information about the audio format (codec, sample rate, channels) that applies to every chunk.audioStreamStream < Uint8List > (required): A stream of raw audio byte chunks to play in order.extraMap < String, dynamic>? (optional)
Returns:
Example:
Copy
For more information, see the Flutter SDK Docs.
GetProperties
Get the audio device’s properties.
Parameters:
extra(Mapping[ str, Any]) (optional): Extra options to pass to the underlying RPC call.timeout( float) (optional): An option to set how long to wait (in seconds) before calling a time-out and closing the underlying RPC call.
Returns:
- ( viam.components.audio_out.audio_out.AudioOut.Properties): : The properties of the audio output device.
Example:
Copy
For more information, see the Python SDK Docs.
Parameters:
ctx(Context): A Context carries a deadline, a cancellation signal, and other values across API boundaries.extra(map[string]interface{}): Extra options to pass to the underlying RPC call.
Returns:
- (utils.Properties)
- (error): An error, if one occurred.
For more information, see the Go SDK Docs.
Parameters:
extra(None) (optional)callOptions(CallOptions) (optional)
Returns:
- (Promise< { numChannels: number; sampleRateHz: number; supportedCodecs: string[] }, >)
Example:
Copy
For more information, see the TypeScript SDK Docs.
Parameters:
Returns:
For more information, see the Flutter SDK Docs.
GetGeometries
Get all the geometries associated with the audio out component in its current configuration, in the frame of the audio out component. The motion and navigation services use the relative position of inherent geometries to configured geometries representing obstacles for collision detection and obstacle avoidance while motion planning.
Parameters:
Returns:
- ( List[viam.proto.common.Geometry]): : The geometries associated with the Component.
Example:
Copy
For more information, see the Python SDK Docs.
Reconfigure
Reconfigure this resource. Reconfigure must reconfigure the resource atomically and in place.
Parameters:
ctx(Context): A Context carries a deadline, a cancellation signal, and other values across API boundaries.deps(Dependencies): The resource dependencies.conf(Config): The resource configuration.
Returns:
- (error): An error, if one occurred.
For more information, see the Go SDK Docs.
DoCommand
Execute model-specific commands that are not otherwise defined by the component API.
Most models do not implement DoCommand.
Any available model-specific commands should be covered in the model’s documentation.
If you are implementing your own arm and want to add features that have no corresponding built-in API method, you can implement them with DoCommand.
Parameters:
command(Mapping[ str, ValueTypes]) (required): The command to execute.timeout( float) (optional): An option to set how long to wait (in seconds) before calling a time-out and closing the underlying RPC call.
Returns:
- (Mapping[ str, viam.utils.ValueTypes]): : Result of the executed command.
Raises:
- (NotImplementedError): Raised if the Resource does not support arbitrary commands.
Example:
Copy
For more information, see the Python SDK Docs.
Parameters:
ctx(Context): A Context carries a deadline, a cancellation signal, and other values across API boundaries.cmd(map[string]interface{}): The command to execute.
Returns:
- (map[string]interface{}): The command response.
- (error): An error, if one occurred.
Example:
Copy
For more information, see the Go SDK Docs.
Parameters:
command( Struct) (required): The command to execute. Accepts either a Struct or a plain object, which will be converted automatically.callOptions(CallOptions) (optional)
Returns:
- (Promise< JsonValue >)
Example:
Copy
For more information, see the TypeScript SDK Docs.
Parameters:
Returns:
Example:
Copy
For more information, see the Flutter SDK Docs.
GetResourceName
Get the ResourceName for this audio out component.
Parameters:
name( str) (required): The name of the Resource.
Returns:
- ( viam.proto.common.ResourceName): : The ResourceName of this Resource.
Example:
Copy
For more information, see the Python SDK Docs.
Parameters:
- None.
Returns:
Example:
Copy
For more information, see the Go SDK Docs.
Parameters:
- None.
Returns:
- (string): The name of the resource.
Example:
Copy
For more information, see the TypeScript SDK Docs.
Close
Safely shut down the resource and prevent further use.
Parameters:
- None.
Returns:
- None.
Example:
Copy
For more information, see the Python SDK Docs.
Parameters:
ctx(Context): A Context carries a deadline, a cancellation signal, and other values across API boundaries.
Returns:
- (error): An error, if one occurred.
Example:
Copy
For more information, see the Go SDK Docs.