| Server IP : 217.160.0.135 / Your IP : 216.73.216.115 Web Server : Apache System : Linux www 6.18.52-i1-ampere #1203 SMP Mon Sep 14 18:29:59 CEST 2026 aarch64 User : sws1074145052 ( 1074145052) PHP Version : 8.3.32 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : OFF | Sudo : OFF | Pkexec : OFF Directory : /usr/lib/python3/dist-packages/IPython/lib/__pycache__/ |
Upload File : |
�
�@�c�_ � �R � d Z ddlmZ ddlmZmZmZmZm Z m
Z
ddlmZm
Z
mZ ddlmZmZ ddlmZmZ g d�Z G d� d e� � Z G d
� de� � Z G d� d
e� � Z G d� de� � Z G d� de� � Z G d� de� � Z G d� de� � Z G d� de� � ZdS )zMVarious display related classes.
Authors : MinRK, gregcaporaso, dannystaple
� )�escape)�exists�isfile�splitext�abspath�join�isdir)�walk�sep�fsdecode)�
DisplayObject�TextDisplayObject)�Tuple�Iterable)�Audio�IFrame�YouTubeVideo�
VimeoVideo�ScribdDocument�FileLink� FileLinks�Codec �� � � e Zd ZdZdZddd�� fd�Z� fd�Zed � � � Zed
e e
ef fd�� � Zed� � � Z
ed
� � � Zd� Zd� Zd� Zd� Zd� Z� xZS )r a� Create an audio object.
When this object is returned by an input cell or passed to the
display function, it will result in Audio controls being displayed
in the frontend (only works in the notebook).
Parameters
----------
data : numpy array, list, unicode, str or bytes
Can be one of
* Numpy 1d array containing the desired waveform (mono)
* Numpy 2d array containing waveforms for each channel.
Shape=(NCHAN, NSAMPLES). For the standard channel order, see
http://msdn.microsoft.com/en-us/library/windows/hardware/dn653308(v=vs.85).aspx
* List of float or integer representing the waveform (mono)
* String containing the filename
* Bytestring containing raw PCM data or
* URL pointing to a file on the web.
If the array option is used, the waveform will be normalized.
If a filename or url is used, the format support will be browser
dependent.
url : unicode
A URL to download the data from.
filename : unicode
Path to a local file to load the data from.
embed : boolean
Should the audio data be embedded using a data URI (True) or should
the original source be referenced. Set this to True if you want the
audio to playable later with no internet connection in the notebook.
Default is `True`, unless the keyword argument `url` is set, then
default value is `False`.
rate : integer
The sampling rate of the raw data.
Only required when data parameter is being used as an array
autoplay : bool
Set to True if the audio should immediately start playing.
Default is `False`.
normalize : bool
Whether audio should be normalized (rescaled) to the maximum possible
range. Default is `True`. When set to `False`, `data` must be between
-1 and 1 (inclusive), otherwise an error is raised.
Applies only when `data` is a list or array of samples; other types of
audio are never normalized.
Examples
--------
>>> import pytest
>>> np = pytest.importorskip("numpy")
Generate a sound
>>> import numpy as np
>>> framerate = 44100
>>> t = np.linspace(0,5,framerate*5)
>>> data = np.sin(2*np.pi*220*t) + np.sin(2*np.pi*224*t)
>>> Audio(data, rate=framerate)
<IPython.lib.display.Audio object>
Can also do stereo or more channels
>>> dataleft = np.sin(2*np.pi*220*t)
>>> dataright = np.sin(2*np.pi*224*t)
>>> Audio([dataleft, dataright], rate=framerate)
<IPython.lib.display.Audio object>
From URL:
>>> Audio("http://www.nch.com.au/acm/8k16bitpcm.wav") # doctest: +SKIP
>>> Audio(url="http://www.w3schools.com/html/horse.ogg") # doctest: +SKIP
From a File:
>>> Audio('IPython/lib/tests/test.wav') # doctest: +SKIP
>>> Audio(filename='IPython/lib/tests/test.wav') # doctest: +SKIP
From Bytes:
>>> Audio(b'RAW_WAV_DATA..') # doctest: +SKIP
>>> Audio(data=b'RAW_WAV_DATA..') # doctest: +SKIP
See Also
--------
ipywidgets.Audio
Audio widget with more more flexibility and options.
�rbNFT��
element_idc � �� |�|�|�t d� � �|du r|�t d� � �|�|durd| _ nd| _ || _ || _ t t
| � � � |||�� � | j �Nt | j t � � s6|�t d� � �t
�
|||� � | _ d S d S d S )Nz6No audio data found. Expecting filename, url, or data.Fz,No url found. Expecting url when embed=FalseT��data�url�filenamezKrate must be specified when data is a numpy array or list of audio samples.)�
ValueError�embed�autoplayr �superr �__init__r �
isinstance�bytes� _make_wav)
�selfr r! r r# �rater$ � normalizer � __class__s
��5/usr/lib/python3/dist-packages/IPython/lib/display.pyr&