Interface AudioIn

Represents a device that takes audio input.

interface AudioIn {
    getProperties: () => Promise<AudioProperties>;
    name: string;
    doCommand(command: Struct): Promise<JsonValue>;
    getAudio(
        codec: string,
        durationSeconds: number,
        previousTimestamp?: bigint,
        extra?: Struct,
    ): AsyncIterable<AudioChunk>;
}

Hierarchy (View Summary)

Implemented by

Properties

getProperties: () => Promise<AudioProperties>

Return the audio input properties.

const audioIn = new VIAM.AudioInClient(machine, 'my_audio_in');
const properties = await audioIn.getProperties();
name: string

The name of the resource.

Methods

  • Send/Receive arbitrary commands to the resource.

    Parameters

    • command: Struct

      The command to execute.

    Returns Promise<JsonValue>

    import { Struct } from '@viamrobotics/sdk';

    const result = await resource.doCommand(
    Struct.fromJson({
    myCommand: { key: 'value' },
    })
    );
  • Stream audio from the device.

    Parameters

    • codec: string
    • durationSeconds: number
    • OptionalpreviousTimestamp: bigint
    • Optionalextra: Struct

    Returns AsyncIterable<AudioChunk>

    const audioIn = new VIAM.AudioInClient(machine, 'my_audio_in');
    const stream = audioIn.getAudio(VIAM.AudioCodec.PCM16, 3, 0n, {});