# Audio out API

The audio out API supports the following methods:

| Method Name | Description |
| --- | --- |
| [`Play`](https://docs.viam.com/reference/apis/components/audio-out/#play) | Play the given audio data. |
| [`PlayStream`](https://docs.viam.com/reference/apis/components/audio-out/#playstream) | Stream audio data in chunks for playback. |
| [`GetProperties`](https://docs.viam.com/reference/apis/components/audio-out/#getproperties) | Get the audio device’s properties. |
| [`GetGeometries`](https://docs.viam.com/reference/apis/components/audio-out/#getgeometries) | Get all the geometries associated with the audio out component in its current configuration, in the frame of the audio out component. |
| [`Reconfigure`](https://docs.viam.com/reference/apis/components/audio-out/#reconfigure) | Reconfigure this resource. |
| [`DoCommand`](https://docs.viam.com/reference/apis/components/audio-out/#docommand) | Execute model-specific commands that are not otherwise defined by the component API. |
| [`GetResourceName`](https://docs.viam.com/reference/apis/components/audio-out/#getresourcename) | Get the `ResourceName` for this audio out component. |
| [`Close`](https://docs.viam.com/reference/apis/components/audio-out/#close) | Safely shut down the resource and prevent further use. |

## API

### Play

Play the given audio data.

- [Python](https://docs.viam.com/reference/apis/components/audio-out/#tabset-referenceapiscomponentsaudio-out-1-0)
- [Go](https://docs.viam.com/reference/apis/components/audio-out/#tabset-referenceapiscomponentsaudio-out-1-1)
- [TypeScript](https://docs.viam.com/reference/apis/components/audio-out/#tabset-referenceapiscomponentsaudio-out-1-2)
- [Flutter](https://docs.viam.com/reference/apis/components/audio-out/#tabset-referenceapiscomponentsaudio-out-1-3)

**Parameters:**

- `data` ( [bytes](https://docs.python.org/3/library/stdtypes.html#bytes-objects)) (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](https://docs.python.org/3/library/stdtypes.html#text-sequence-type-str), Any]) (optional): Extra options to pass to the underlying RPC call.
- `timeout` ( [float](https://docs.python.org/3/library/stdtypes.html#numeric-types-int-float-complex)) (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:**

```python

```

Copy

For more information, see the [Python SDK Docs](https://python.viam.dev/autoapi/viam/components/audio_out/client/index.html#viam.components.audio_out.client.AudioOutClient.play).

**Parameters:**

- `ctx` [(Context)](https://pkg.go.dev/context#Context): A Context carries a deadline, a cancellation signal, and other values across API boundaries.
- `data` [(byte)](https://pkg.go.dev/builtin#byte)
- `info` [(utils.AudioInfo)](https://pkg.go.dev/go.viam.com/rdk/utils#AudioInfo)
- `extra` [(map[string]interface{})](https://go.dev/blog/maps): Extra options to pass to the underlying RPC call.

**Returns:**

- [(error)](https://pkg.go.dev/builtin#error): An error, if one occurred.

For more information, see the [Go SDK Docs](https://pkg.go.dev/go.viam.com/rdk/components/audioout#AudioOut).

**Parameters:**

- `audioData` (Uint8Array) (required): The audio data to play.
- `audioInfo` ( [AudioInfo](https://ts.viam.dev/classes/commonApi.AudioInfo.html)) (optional): Information about the audio format (optional, required for raw pcm data).
- `extra` (None) (optional)
- `callOptions` (CallOptions) (optional)

**Returns:**

- (Promise)

**Example:**

```ts

```

Copy

For more information, see the [TypeScript SDK Docs](https://ts.viam.dev/classes/AudioOutClient.html#play).

**Parameters:**

- `audioData` [Uint8List](https://api.flutter.dev/flutter/dart-typed_data/Uint8List-class.html) (optional)
- `audioInfo` [AudioInfo](https://flutter.viam.dev/viam_protos.common.common/AudioInfo-class.html) (optional)
- `extra` [Map](https://api.flutter.dev/flutter/dart-core/Map-class.html) < [String](https://api.flutter.dev/flutter/dart-core/String-class.html), dynamic>? (optional)

**Returns:**

- [Future](https://api.flutter.dev/flutter/dart-async/Future-class.html) < [PlayResponse](https://flutter.viam.dev/viam_protos.component.audioout/PlayResponse-class.html) >

For more information, see the [Flutter SDK Docs](https://flutter.viam.dev/viam_sdk/AudioOutClient/play.html).

### PlayStream

Stream audio data in chunks for playback.

- [Python](https://docs.viam.com/reference/apis/components/audio-out/#tabset-referenceapiscomponentsaudio-out-2-0)
- [Go](https://docs.viam.com/reference/apis/components/audio-out/#tabset-referenceapiscomponentsaudio-out-2-1)
- [TypeScript](https://docs.viam.com/reference/apis/components/audio-out/#tabset-referenceapiscomponentsaudio-out-2-2)
- [Flutter](https://docs.viam.com/reference/apis/components/audio-out/#tabset-referenceapiscomponentsaudio-out-2-3)

**Parameters:**

- `chunks` ( [AsyncIterator](https://docs.python.org/3/library/collections.abc.html#collections.abc.AsyncIterator)[ [bytes](https://docs.python.org/3/library/stdtypes.html#bytes-objects)]) (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](https://docs.python.org/3/library/stdtypes.html#text-sequence-type-str), Any]) (optional): Extra options to pass to the underlying RPC call.
- `timeout` ( [float](https://docs.python.org/3/library/stdtypes.html#numeric-types-int-float-complex)) (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:**

```python

```

Copy

For more information, see the [Python SDK Docs](https://python.viam.dev/autoapi/viam/components/audio_out/client/index.html#viam.components.audio_out.client.AudioOutClient.play_stream).

**Parameters:**

- `ctx` [(Context)](https://pkg.go.dev/context#Context): A Context carries a deadline, a cancellation signal, and other values across API boundaries.
- `info` [(utils.AudioInfo)](https://pkg.go.dev/go.viam.com/rdk/utils#AudioInfo): Information about the audio data such as codec, sample rate, and channel count.
- `chunks` [(<-chan byte)](https://pkg.go.dev/builtin#byte): A receive-only channel of audio data chunks. Close the channel to signal end of stream.
- `extra` [(map[string]interface{})](https://go.dev/blog/maps): Extra options to pass to the underlying RPC call.

**Returns:**

- [(error)](https://pkg.go.dev/builtin#error): An error, if one occurred.

**Example:**

```go

```

Copy

For more information, see the [Go SDK Docs](https://pkg.go.dev/go.viam.com/rdk/components/audioout#AudioOut).

**Parameters:**

- `audioInfo` ( [AudioInfo](https://ts.viam.dev/classes/commonApi.AudioInfo.html)) (required): Information about the audio format (codec, sample rate, channels) that applies to every chunk.
- `chunks` (AsyncIterable<Uint8Array>) (required): Async iterable of audio byte chunks to play in order.
- `extra` (None) (optional)
- `callOptions` (CallOptions) (optional)

**Returns:**

- (Promise<void>)

**Example:**

```ts

```

Copy

For more information, see the [TypeScript SDK Docs](https://ts.viam.dev/classes/AudioOutClient.html#playstream).

**Parameters:**

- `audioInfo` [AudioInfo](https://flutter.viam.dev/viam_protos.common.common/AudioInfo-class.html) (required): Information about the audio format (codec, sample rate, channels) that applies to every chunk.
- `audioStream` [Stream](https://api.flutter.dev/flutter/dart-async/Stream-class.html) < [Uint8List](https://api.flutter.dev/flutter/dart-typed_data/Uint8List-class.html) > (required): A stream of raw audio byte chunks to play in order.
- `extra` [Map](https://api.flutter.dev/flutter/dart-core/Map-class.html) < [String](https://api.flutter.dev/flutter/dart-core/String-class.html), dynamic>? (optional)

**Returns:**

- [Future](https://api.flutter.dev/flutter/dart-async/Future-class.html) < [PlayStreamResponse](https://flutter.viam.dev/viam_protos.component.audioout/PlayStreamResponse-class.html) >

**Example:**

```dart

```

Copy

For more information, see the [Flutter SDK Docs](https://flutter.viam.dev/viam_sdk/AudioOutClient/playStream.html).

### GetProperties

Get the audio device’s properties.

- [Python](https://docs.viam.com/reference/apis/components/audio-out/#tabset-referenceapiscomponentsaudio-out-3-0)
- [Go](https://docs.viam.com/reference/apis/components/audio-out/#tabset-referenceapiscomponentsaudio-out-3-1)
- [TypeScript](https://docs.viam.com/reference/apis/components/audio-out/#tabset-referenceapiscomponentsaudio-out-3-2)
- [Flutter](https://docs.viam.com/reference/apis/components/audio-out/#tabset-referenceapiscomponentsaudio-out-3-3)

**Parameters:**

- `extra` (Mapping[ [str](https://docs.python.org/3/library/stdtypes.html#text-sequence-type-str), Any]) (optional): Extra options to pass to the underlying RPC call.
- `timeout` ( [float](https://docs.python.org/3/library/stdtypes.html#numeric-types-int-float-complex)) (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](https://python.viam.dev/autoapi/viam/components/audio_out/audio_out/index.html#viam.components.audio_out.audio_out.AudioOut.Properties)): : The properties of the audio output device.

**Example:**

```python

```

Copy

For more information, see the [Python SDK Docs](https://python.viam.dev/autoapi/viam/components/audio_out/client/index.html#viam.components.audio_out.client.AudioOutClient.get_properties).

**Parameters:**

- `ctx` [(Context)](https://pkg.go.dev/context#Context): A Context carries a deadline, a cancellation signal, and other values across API boundaries.
- `extra` [(map[string]interface{})](https://go.dev/blog/maps): Extra options to pass to the underlying RPC call.

**Returns:**

- [(utils.Properties)](https://pkg.go.dev/go.viam.com/rdk/utils#Properties)
- [(error)](https://pkg.go.dev/builtin#error): An error, if one occurred.

For more information, see the [Go SDK Docs](https://pkg.go.dev/go.viam.com/rdk/components/audioout#AudioOut).

**Parameters:**

- `extra` (None) (optional)
- `callOptions` (CallOptions) (optional)

**Returns:**

- (Promise< { numChannels: number; sampleRateHz: number; supportedCodecs: string[] }, >)

**Example:**

```ts

```

Copy

For more information, see the [TypeScript SDK Docs](https://ts.viam.dev/classes/AudioOutClient.html#getproperties).

**Parameters:**

- `extra` [Map](https://api.flutter.dev/flutter/dart-core/Map-class.html) < [String](https://api.flutter.dev/flutter/dart-core/String-class.html), dynamic>? (optional)

**Returns:**

- [Future](https://api.flutter.dev/flutter/dart-async/Future-class.html) < [GetPropertiesResponse](https://flutter.viam.dev/viam_protos.common.common/GetPropertiesResponse-class.html) >

For more information, see the [Flutter SDK Docs](https://flutter.viam.dev/viam_sdk/AudioOutClient/getProperties.html).

### GetGeometries

Get all the geometries associated with the audio out component in its current configuration, in the [frame](https://docs.viam.com/reference/services/frame-system/) of the audio out component.
The [motion](https://docs.viam.com/reference/services/motion/) and [navigation](https://docs.viam.com/reference/services/navigation/) services use the relative position of inherent geometries to configured geometries representing obstacles for collision detection and obstacle avoidance while motion planning.

- [Python](https://docs.viam.com/reference/apis/components/audio-out/#tabset-referenceapiscomponentsaudio-out-4-0)

**Parameters:**

**Returns:**

- ( [List[viam.proto.common.Geometry]](https://python.viam.dev/autoapi/viam/proto/common/index.html#viam.proto.common.Geometry)): : The geometries associated with the Component.

**Example:**

```python

```

Copy

For more information, see the [Python SDK Docs](https://python.viam.dev/autoapi/viam/components/audio_out/client/index.html#viam.components.audio_out.client.AudioOutClient.get_geometries).

### Reconfigure

Reconfigure this resource.
Reconfigure must reconfigure the resource atomically and in place.

- [Go](https://docs.viam.com/reference/apis/components/audio-out/#tabset-referenceapiscomponentsaudio-out-5-0)

**Parameters:**

- `ctx` [(Context)](https://pkg.go.dev/context#Context): A Context carries a deadline, a cancellation signal, and other values across API boundaries.
- `deps` [(Dependencies)](https://pkg.go.dev/go.viam.com/rdk/resource#Dependencies): The resource dependencies.
- `conf` [(Config)](https://pkg.go.dev/go.viam.com/rdk/resource#Config): The resource configuration.

**Returns:**

- [(error)](https://pkg.go.dev/builtin#error): An error, if one occurred.

For more information, see the [Go SDK Docs](https://pkg.go.dev/go.viam.com/rdk/resource#Resource).

### 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`](https://docs.viam.com/reference/sdks/docommand/).

- [Python](https://docs.viam.com/reference/apis/components/audio-out/#tabset-referenceapiscomponentsaudio-out-6-0)
- [Go](https://docs.viam.com/reference/apis/components/audio-out/#tabset-referenceapiscomponentsaudio-out-6-1)
- [TypeScript](https://docs.viam.com/reference/apis/components/audio-out/#tabset-referenceapiscomponentsaudio-out-6-2)
- [Flutter](https://docs.viam.com/reference/apis/components/audio-out/#tabset-referenceapiscomponentsaudio-out-6-3)

**Parameters:**

- `command` (Mapping[ [str](https://docs.python.org/3/library/stdtypes.html#text-sequence-type-str), ValueTypes]) (required): The command to execute.
- `timeout` ( [float](https://docs.python.org/3/library/stdtypes.html#numeric-types-int-float-complex)) (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](https://docs.python.org/3/library/stdtypes.html#text-sequence-type-str), viam.utils.ValueTypes]): : Result of the executed command.

**Raises:**

- (NotImplementedError): Raised if the Resource does not support arbitrary commands.

**Example:**

```python

```

Copy

For more information, see the [Python SDK Docs](https://python.viam.dev/autoapi/viam/components/audio_out/client/index.html#viam.components.audio_out.client.AudioOutClient.do_command).

**Parameters:**

- `ctx` [(Context)](https://pkg.go.dev/context#Context): A Context carries a deadline, a cancellation signal, and other values across API boundaries.
- `cmd` [(map[string]interface{})](https://go.dev/blog/maps): The command to execute.

**Returns:**

- [(map[string]interface{})](https://pkg.go.dev/builtin#string): The command response.
- [(error)](https://pkg.go.dev/builtin#error): An error, if one occurred.

**Example:**

```go

```

Copy

For more information, see the [Go SDK Docs](https://pkg.go.dev/go.viam.com/rdk/resource#Resource).

**Parameters:**

- `command` ( [Struct](https://ts.viam.dev/classes/Struct.html)) (required): The command to execute. Accepts either a [Struct](https://ts.viam.dev/classes/Struct.html) or a plain object, which will be converted automatically.
- `callOptions` (CallOptions) (optional)

**Returns:**

- (Promise< [JsonValue](https://ts.viam.dev/types/JsonValue.html) >)

**Example:**

```ts

```

Copy

For more information, see the [TypeScript SDK Docs](https://ts.viam.dev/classes/AudioOutClient.html#docommand).

**Parameters:**

- `command` [Map](https://api.flutter.dev/flutter/dart-core/Map-class.html) < [String](https://api.flutter.dev/flutter/dart-core/String-class.html), dynamic> (required)

**Returns:**

- [Future](https://api.flutter.dev/flutter/dart-async/Future-class.html) < [Map](https://api.flutter.dev/flutter/dart-core/Map-class.html) < [String](https://api.flutter.dev/flutter/dart-core/String-class.html), dynamic>>

**Example:**

```dart

```

Copy

For more information, see the [Flutter SDK Docs](https://flutter.viam.dev/viam_sdk/AudioOutClient/doCommand.html).

### GetResourceName

Get the `ResourceName` for this audio out component.

- [Python](https://docs.viam.com/reference/apis/components/audio-out/#tabset-referenceapiscomponentsaudio-out-7-0)
- [Go](https://docs.viam.com/reference/apis/components/audio-out/#tabset-referenceapiscomponentsaudio-out-7-1)
- [TypeScript](https://docs.viam.com/reference/apis/components/audio-out/#tabset-referenceapiscomponentsaudio-out-7-2)

**Parameters:**

- `name` ( [str](https://docs.python.org/3/library/stdtypes.html#text-sequence-type-str)) (required): The name of the Resource.

**Returns:**

- ( [viam.proto.common.ResourceName](https://python.viam.dev/autoapi/viam/proto/common/index.html#viam.proto.common.ResourceName)): : The ResourceName of this Resource.

**Example:**

```python

```

Copy

For more information, see the [Python SDK Docs](https://python.viam.dev/autoapi/viam/components/audio_out/client/index.html#viam.components.audio_out.client.AudioOutClient.get_resource_name).

**Parameters:**

- None.

**Returns:**

- [(Name)](https://pkg.go.dev/go.viam.com/rdk@v0.89.0/resource#Name)

**Example:**

```go

```

Copy

For more information, see the [Go SDK Docs](https://pkg.go.dev/go.viam.com/rdk/resource#Resource).

**Parameters:**

- None.

**Returns:**

- (string): The name of the resource.

**Example:**

```ts

```

Copy

For more information, see the [TypeScript SDK Docs](https://ts.viam.dev/classes/AudioOutClient.html#name).

### Close

Safely shut down the resource and prevent further use.

- [Python](https://docs.viam.com/reference/apis/components/audio-out/#tabset-referenceapiscomponentsaudio-out-8-0)
- [Go](https://docs.viam.com/reference/apis/components/audio-out/#tabset-referenceapiscomponentsaudio-out-8-1)

**Parameters:**

- None.

**Returns:**

- None.

**Example:**

```python

```

Copy

For more information, see the [Python SDK Docs](https://python.viam.dev/autoapi/viam/components/audio_out/client/index.html#viam.components.audio_out.client.AudioOutClient.close).

**Parameters:**

- `ctx` [(Context)](https://pkg.go.dev/context#Context): A Context carries a deadline, a cancellation signal, and other values across API boundaries.

**Returns:**

- [(error)](https://pkg.go.dev/builtin#error): An error, if one occurred.

**Example:**

```go

```

Copy

For more information, see the [Go SDK Docs](https://pkg.go.dev/go.viam.com/rdk/resource#Resource).
