The Audio
pane displays an audio player given a local or remote audio file, NumPy ndarray or a Torch Tensor.
The pane also allows access and control over the player state including toggling of playing/paused
and loop
state, the current time
, and the volume
.
The audio player supports ogg
, mp3
, and wav
file formats
If SciPy is installed, 1-dim Numpy ndarrys and 1-dim Torch Tensors are also supported. The dtype must be one of the following
numpy: np.int16, np.uint16, np.float32, np.float64
torch: torch.short, torch.int16, torch.half, torch.float16, torch.float, torch.float32, torch.double, torch.float64
The array or tensor input will be downsampled to 16bit and converted to a wav file by SciPy.
Parameters:
For details on other options for customizing the component see the layout and styling how-to guides.
autoplay
(boolean): When True, it specifies that the output will play automatically. In Chromium browsers this requires the user to click play onceloop
(boolean): Whether to loop when reaching the end of playbackmuted
(boolean): When True, it specifies that the output should be mutedname
(str): The title of the paneobject
(string): Local file path, remote URL pointing to audio file, 1-dim numpy array or 1-dim torch tensorpaused
(boolean): Whether the player is pausedsample_rate
(int): The sample_rate of the audio when given a NumPy array or Torch Tensor. Default is 44100.throttle
(int): How frequently to sample the current playback in millisecondstime
(float): Current playback time in secondsvolume
(int): Volume in the range 0-100
The Audio
pane can be constructed with a URL pointing to a remote audio file or a local audio file (in which case the data is embedded).
The player can be controlled using its own widgets, as well as by using Python code as follows. To pause or unpause it in code, use the paused
property:
The current player time
can be read and set with the time variable (in seconds):
The volume
may also be read and set:
When providing a NumPy Array or Torch Tensor, you should specify the sample_rate
.
In this example we plot a frequency modulated signal:
Controls
The Audio
pane exposes a number of options which can be changed from both Python and Javascript. Try out the effect of these parameters interactively: