Audio#

This component is also available in the classic reference.

The Audio pane displays an audio player given a local or remote audio file, a NumPy Array or Torch Tensor.

Use pn.ui.Audio to create this component.

API#

.. py:class:: Audio(object=None, **params) :module: panel.pane.media

The Audio pane displays an audio player given a local or remote audio file, a NumPy Array or 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 files

If SciPy is installed, 1- or 2-dim Numpy Arrays and 1- or 2-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.

Reference: https://panel.holoviz.org/reference/panes/Audio.html

:Example:

Audio(‘http://ccrma.stanford.edu/~jos/mp3/pno-cs.mp3’, name=’Audio’)

.. rubric:: Methods

.. autosummary::

  applies

.. !! processed by numpydoc !!

Parameter Definitions


Parameters inherited from:

   :class:`panel.viewable.Layoutable`: align, aspect_ratio, css_classes, design, height, min_width, min_height, max_width, max_height, styles, stylesheets, tags, width, width_policy, height_policy, sizing_mode, visible

   :class:`panel.viewable.Viewable`: loading

   :class:`panel.pane.base.PaneBase`: margin, default_layout

   :class:`panel.pane.media._MediaBase`: loop, time, throttle, paused, volume, autoplay, muted

object = ClassSelector(allow_None=True, allow_refs=True, class_=(<class 'str'>, <class 'bytes'>, <class 'pathlib.Path'>, <class '_io.BytesIO'>, <class 'numpy.ndarray'>, <class 'panel.pane.media.TensorLike'>), default='', label='Object')

    The audio file either local or remote, a 1- or 2-dim NumPy ndarray or a 1- or 2-dim Torch Tensor
    or a bytes or BytesIO object.

sample_rate = Integer(default=44100, inclusive_bounds=(True, True), label='Sample rate')

    The sample_rate of the audio when given a NumPy array or Torch tensor.

.. py:method:: Audio.applies(object: ~typing.Any) -> float | bool | None :module: panel.pane.media :classmethod:

  Returns boolean or float indicating whether the Pane
  can render the object.

  If the priority of the pane is set to
  `None`, this method may also be used to define a float priority
  depending on the object being rendered.















  ..
      !! processed by numpydoc !!