audio · Play and record sound

Plays and stops mp3 and wav audio files and records sound with the microphone.

Class: Audio

class openpibo.audio.Audio[source]

Bases: object

Functions: play() stop() record()

Plays and stops mp3 and wav audio files.

play(filename, volume=80, background=True, volume2=1.0)[source]

Plays an mp3 or wav file

Parameters:
  • filename (str) – Audio file path (mp3, wav)

  • volume (int) – Sets the volume. (0~100)

  • background (bool) – Whether to run in the background

  • volume2 (float) – Adjusts the individual volume. (ratio)

stop()[source]

Stops the audio being played

record(filename, timeout=5, verbose=True)[source]

Records sound (piBo microphone)

Parameters:
  • filename (str) – Path to save the recorded file. wav extension

  • timeout (int) – Recording time (s)