Viam SDK
    Preparing search index...

    Class AudioInClient

    Represents a device that takes audio input.

    Implements

    Index

    Constructors

    Properties

    callOptions: CallOptions = ...
    name: string

    The name of the resource.

    Methods

    • Send/Receive arbitrary commands to the resource.

      Parameters

      • command: Struct | Record<string, JsonValue>

        The command to execute. Accepts either a Struct or a plain object, which will be converted automatically.

      • callOptions: CallOptions = ...

      Returns Promise<JsonValue>

      // Plain object (recommended)
      const result = await resource.doCommand({
      myCommand: { key: 'value' },
      });

      // Struct (still supported)
      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
      • previousTimestamp: bigint = 0n
      • extra: {} = {}
      • callOptions: CallOptions = ...

      Returns AsyncIterable<AudioChunk>

      const audioIn = new VIAM.AudioInClient(machine, 'my_audio_in');
      const stream = audioIn.getAudio(VIAM.AudioCodec.PCM16, 3, 0n, {});
    • Return the audio input properties.

      Parameters

      • extra: {} = {}
      • callOptions: CallOptions = ...

      Returns Promise<
          { numChannels: number; sampleRateHz: number; supportedCodecs: string[] },
      >

      const audioIn = new VIAM.AudioInClient(machine, 'my_audio_in');
      const properties = await audioIn.getProperties();
    • Get the status of the resource.

      Parameters

      • callOptions: CallOptions = ...

      Returns Promise<JsonValue>