# Audio in API

The audio in API supports the following methods:

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

## API

### GetAudio

Get a stream of audio from the device.

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

**Parameters:**

- `codec` ( [str](https://docs.python.org/3/library/stdtypes.html#text-sequence-type-str)) (required): The desired codec of the returned audio data.
- `duration_seconds` ( [float](https://docs.python.org/3/library/stdtypes.html#numeric-types-int-float-complex)) (required): duration of the stream. 0 = indefinite stream.
- `previous_timestamp_ns` ( [int](https://docs.python.org/3/library/stdtypes.html#numeric-types-int-float-complex)) (required): starting timestamp in nanoseconds for recording continuity.
- `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.

**Returns:**

- None.

**Example:**

```python

```

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

**Parameters:**

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

**Returns:**

- `chan` [(*AudioChunk)](https://pkg.go.dev/go.viam.com/rdk/components/audioin#AudioChunk)
- [(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/audioin#AudioIn).

**Parameters:**

- `codec` (string) (required)
- `durationSeconds` (number) (required)
- `previousTimestamp` (bigint) (optional)
- `extra` (None) (optional)
- `callOptions` (CallOptions) (optional)

**Returns:**

- (AsyncIterable< [AudioChunk](https://ts.viam.dev/interfaces/AudioChunk.html) >)

**Example:**

```ts

```

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

**Parameters:**

- `codec` [String](https://api.flutter.dev/flutter/dart-core/String-class.html) (optional)
- `durationSeconds` [double](https://api.flutter.dev/flutter/dart-core/double-class.html)? (optional)
- `previousTimestampNanoseconds` [Int64](https://pub.dev/documentation/fixnum/1.1.1/fixnum/Int64-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:**

- [Stream](https://api.flutter.dev/flutter/dart-async/Stream-class.html) < [GetAudioResponse](https://flutter.viam.dev/viam_protos.component.audioin/GetAudioResponse-class.html) >

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

### GetProperties

Get the audio device’s properties.

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

**Parameters:**

- `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_in.audio_in.AudioIn.Properties](https://python.viam.dev/autoapi/viam/components/audio_in/audio_in/index.html#viam.components.audio_in.audio_in.AudioIn.Properties)): : The properties of the audio in device.

**Example:**

```python

```

For more information, see the [Python SDK Docs](https://python.viam.dev/autoapi/viam/components/audio_in/client/index.html#viam.components.audio_in.client.AudioInClient.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/audioin#AudioIn).

**Parameters:**

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

**Returns:**

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

**Example:**

```ts

```

For more information, see the [TypeScript SDK Docs](https://ts.viam.dev/classes/AudioInClient.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/AudioInClient/getProperties.html).

### GetGeometries

Get all the geometries associated with the audio in component in its current configuration, in the [frame](https://docs.viam.com/reference/services/frame-system/) of the audio in 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-in/#tabset-referenceapiscomponentsaudio-in-3-0)

**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:**

- ( [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

```

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

### Reconfigure

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

- [Go](https://docs.viam.com/reference/apis/components/audio-in/#tabset-referenceapiscomponentsaudio-in-4-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-in/#tabset-referenceapiscomponentsaudio-in-5-0)
- [Go](https://docs.viam.com/reference/apis/components/audio-in/#tabset-referenceapiscomponentsaudio-in-5-1)
- [TypeScript](https://docs.viam.com/reference/apis/components/audio-in/#tabset-referenceapiscomponentsaudio-in-5-2)
- [Flutter](https://docs.viam.com/reference/apis/components/audio-in/#tabset-referenceapiscomponentsaudio-in-5-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

```

For more information, see the [Python SDK Docs](https://python.viam.dev/autoapi/viam/components/audio_in/client/index.html#viam.components.audio_in.client.AudioInClient.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

```

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

```

For more information, see the [TypeScript SDK Docs](https://ts.viam.dev/classes/AudioInClient.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

```

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

### GetResourceName

Get the `ResourceName` for this audio in component.

- [Python](https://docs.viam.com/reference/apis/components/audio-in/#tabset-referenceapiscomponentsaudio-in-6-0)
- [Go](https://docs.viam.com/reference/apis/components/audio-in/#tabset-referenceapiscomponentsaudio-in-6-1)
- [TypeScript](https://docs.viam.com/reference/apis/components/audio-in/#tabset-referenceapiscomponentsaudio-in-6-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

```

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

**Parameters:**

- None.

**Returns:**

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

**Example:**

```go

```

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

```

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

### Close

Safely shut down the resource and prevent further use.

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

**Parameters:**

- None.

**Returns:**

- None.

**Example:**

```python

```

For more information, see the [Python SDK Docs](https://python.viam.dev/autoapi/viam/components/audio_in/client/index.html#viam.components.audio_in.client.AudioInClient.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.
