anki_vector.audio

Support for accessing Vector’s audio.

Vector’s speakers can be used for playing user-provided audio.

The AudioComponent class defined in this module is made available as anki_vector.robot.Robot.audio and can be used to play audio data on the robot.

Classes

AudioComponent(robot)

Handles audio on Vector.

RobotVolumeLevel

Use these values for setting the master audio volume.

class anki_vector.audio.AudioComponent(robot)

Handles audio on Vector.

The AudioComponent object plays audio data to Vector’s speaker.

The anki_vector.robot.Robot or anki_vector.robot.AsyncRobot instance owns this audio component.

import anki_vector

with anki_vector.Robot() as robot:
    robot.audio.stream_wav_file('../examples/sounds/vector_alert.wav')
set_master_volume(volume)

Sets Vector’s master volume level.

Note that muting the robot is not supported from the SDK.

import anki_vector
from anki_vector import audio

with anki_vector.Robot(behavior_control_level=None) as robot:
    robot.audio.set_master_volume(audio.RobotVolumeLevel.MEDIUM_HIGH)
Parameters

volume (RobotVolumeLevel) – the robot’s desired volume

Return type

MasterVolumeResponse

stream_wav_file(filename, volume=50)

Plays audio using Vector’s speakers.

import anki_vector

with anki_vector.Robot() as robot:
    robot.audio.stream_wav_file('../examples/sounds/vector_alert.wav')
Parameters
  • filename – the filename/path to the .wav audio file

  • volume – the audio playback level (0-100)