anki_vector.audio

Support for Vector’s audio.

Vector has multiple built-in microphones which can detect sound and the direction it originated from. The robot then processing this data into a single-channel audio feed available to the SDK.

The AudioComponent class defined in this module is made available as anki_vector.robot.Robot.audio and can be used to enable/disable audio sending and process audio data being sent by the robot.

Classes

AudioComponent(robot) Represents Vector’s audio feed.
class anki_vector.audio.AudioComponent(robot)

Represents Vector’s audio feed.

The AudioComponent object receives audio data from Vector’s microphones.

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

import time

try:
    from scipy.io import wavfile
except ImportError as exc:
    sys.exit("Cannot import scipy: Do `pip3 install scipy` to install")

with anki_vector.Robot(enable_audio_feed=True) as robot:
    time.sleep(5.0)
    wavfile.write("outputfile.wav", anki_vector.protocol.PROCESSED_SAMPLE_RATE, robot.audio.raw_audio_waveform_history)
Parameters:robot – A reference to the owner Robot object.
audio_processing_mode

The current mode which the robot is processing audio.

Getter:Returns the most recently received audio processing mode on the robot
Return type:<google.protobuf.internal.enum_type_wrapper.EnumTypeWrapper object at 0x107086080>
close_audio_feed()

Cancel audio feed task

Return type:None
init_audio_feed()

Begin audio feed task

Return type:None
latest_sample_id

The most recent received audio sample from the robot.

Getter:Returns the id for the latest audio sample
Return type:int
raw_audio_waveform_history

np.array – The most recent processed image received from the robot.

Audio history as signed-16-bit-int waveform data

The sample rate from the microphones is 15625, which the robot processes at 16khz. As a result the pitch is altered by 2.4%. The last 16000 values of the array represent the last second of audio amplitude.

import time

try:
    from scipy.io import wavfile
except ImportError as exc:
    sys.exit("Cannot import scipy: Do `pip3 install scipy` to install")

with anki_vector.Robot(enable_audio_feed=True) as robot:
    time.sleep(5.0)
    wavfile.write("outputfile.wav", anki_vector.protocol.PROCESSED_SAMPLE_RATE, robot.audio.raw_audio_waveform_history)
Getter:Returns the numpy array representing the audio history
Return type:<built-in function array>