Class AudioOutClient

A gRPC-web client for the AudioOut component.

Implements

Constructors

Properties

Methods

Constructors

Properties

callOptions: CallOptions = ...
name: string

The name of the resource.

Methods

  • Send/Receive arbitrary commands to the resource.

    Parameters

    • command: Struct

      The command to execute.

    • callOptions: CallOptions = ...

    Returns Promise<JsonValue>

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

    const result = await resource.doCommand(
    Struct.fromJson({
    myCommand: { key: 'value' },
    })
    );
  • Return the audio output properties.

    Parameters

    • callOptions: CallOptions = ...

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

    const audioOut = new VIAM.AudioOutClient(machine, 'my_audio_out');
    const properties = await audioOut.getProperties();
  • Play audio on the device.

    Parameters

    • audioData: Uint8Array

      The audio data to play

    • OptionalaudioInfo: AudioInfo

      Information about the audio format (optional, required for raw pcm data)

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

    Returns Promise<void>

    const audioOut = new VIAM.AudioOutClient(machine, 'my_audio_out');
    const audioData = new Uint8Array([...]); // Your audio data
    const audioInfo = { codec: 'pcm16', sampleRateHz: 48000, numChannels: 2 };
    await audioOut.play(audioData, audioInfo);