Previous
Arm
The audio in API supports the following methods:
| Method Name | Description |
|---|---|
GetAudio | Get a stream of audio from the device. |
GetProperties | Get the audio device’s properties. |
GetGeometries | Get all the geometries associated with the audio in component in its current configuration, in the frame of the audio in 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 in component. |
Close | Safely shut down the resource and prevent further use. |
Get a stream of audio from the device.
Parameters:
codec (str) (required): The desired codec of the returned audio data.duration_seconds (float) (required): duration of the stream. 0 = indefinite stream.previous_timestamp_ns (int) (required): starting timestamp in nanoseconds for recording continuity.extra (Mapping[str, Any]) (optional): Extra options to pass to the underlying RPC call.Returns:
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.codec (string)durationSeconds (float32)previousTimestampNs (int64)extra (map[string]interface{}): Extra options to pass to the underlying RPC call.Returns:
chan (*AudioChunk)For more information, see the Go SDK Docs.
Parameters:
codec (string) (required)durationSeconds (number) (required)previousTimestamp (bigint) (optional)extra (None) (optional)callOptions (CallOptions) (optional)Returns:
Example:
const audioIn = new VIAM.AudioInClient(machine, "my_audio_in");
const stream = audioIn.getAudio(VIAM.AudioCodec.PCM16, 3, 0n, {});
For more information, see the TypeScript SDK Docs.
Get the audio device’s properties.
Parameters:
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:
For more information, see the Python SDK Docs.
Parameters:
callOptions (CallOptions) (optional)Returns:
Example:
const audioIn = new VIAM.AudioInClient(machine, "my_audio_in");
const properties = await audioIn.getProperties();
For more information, see the TypeScript SDK Docs.
Get all the geometries associated with the audio in component in its current configuration, in the frame of the audio in 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:
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:
Example:
my_audio_in = AudioIn.from_robot(robot=machine, name="my_audio_in")
geometries = await my_audio_in.get_geometries()
if geometries:
# Get the center of the first geometry
print(f"Pose of the first geometry's centerpoint: {geometries[0].center}")
For more information, see the Python SDK Docs.
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:
For more information, see the Go SDK Docs.
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:
Raises:
Example:
my_audio_in = AudioIn.from_robot(robot=machine, name="my_audio_in")
command = {"cmd": "test", "data1": 500}
result = await my_audio_in.do_command(command)
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:
Example:
myAudioIn, err := audio_in.FromProvider(machine, "my_audio_in")
command := map[string]interface{}{"cmd": "test", "data1": 500}
result, err := myAudioIn.DoCommand(context.Background(), command)
For more information, see the Go SDK Docs.
Parameters:
command (Struct) (required): The command to execute.callOptions (CallOptions) (optional)Returns:
Example:
import { Struct } from "@viamrobotics/sdk";
const result = await resource.doCommand(
Struct.fromJson({
myCommand: { key: "value" },
}),
);
For more information, see the TypeScript SDK Docs.
Get the ResourceName for this audio in component.
Parameters:
name (str) (required): The name of the Resource.Returns:
Example:
my_audio_in_name = AudioIn.get_resource_name("my_audio_in")
For more information, see the Python SDK Docs.
Parameters:
Returns:
Example:
myAudioIn, err := audioin.FromProvider(machine, "my_audio_in")
err = myAudioIn.Name()
For more information, see the Go SDK Docs.
Parameters:
Returns:
Example:
audio_in.name;
For more information, see the TypeScript SDK Docs.
Safely shut down the resource and prevent further use.
Parameters:
Returns:
Example:
my_audio_in = AudioIn.from_robot(robot=machine, name="my_audio_in")
await my_audio_in.close()
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:
Example:
myAudioIn, err := audioin.FromProvider(machine, "my_audio_in")
err = myAudioIn.Close(context.Background())
For more information, see the Go SDK Docs.
Was this page helpful?
Glad to hear it! If you have any other feedback please let us know:
We're sorry about that. To help us improve, please tell us what we can do better:
Thank you!