_holoviews_manipulations Module#

_holoviews_manipulations Module#
- class waloviz._holoviews_manipulations.ThemeHook(theme_obj: Dict[str, Any])[source]#
Bases:
objectA class with a HoloViews hook for applying a Bokeh theme.This is due to a problem when using the built-in theme support of HoloViews in integration with Panel, for some reason themes are only partially applied in those situations.Parameters#
theme_objDict[str, Any]A Bokeh theme object
- waloviz._holoviews_manipulations.calculate_frequency_range_of_torchaudio_spectrogram(sr: int, n_fft: int) Tuple[float, float][source]#
- Calculates the maximum and minimum frequency as in the torchaudio spectrogram.
Parameters#
srintResolved sample-rate
n_fftintSets the
n_fftof the torchaudio spectrogram
Returns#
hz_minintMinimum frequency in the torchaudio spectrogram
hz_maxintMaximum frequency in the torchaudio spectrogram
- waloviz._holoviews_manipulations.combine_player_plots(plots: List[Layout], sync_legends: bool, theme_hook: ThemeHook, stay_color: str, responsive: bool) Layout[source]#
- Combines the spectrograms and progress bar plots into one layout.
Parameters#
plotsList[hv.Layout]A list of the plots of the spectrograms and the progress bar
sync_legendsboolWhether the legends of both audio channels
over_curves should be synchronizedtheme_hookThemeHookThe HoloViews hook for applying a Bokeh theme, see ThemeHook.
stay_colorstrThe color for the current time cursor when not following it
responsiveboolWhether the plot width and height should be responsive
Returns#
player_hvhv.LayoutA HoloViews Layout with the spectrograms and progress bar stacked together.
- waloviz._holoviews_manipulations.create_channel_spectrogram_plot(channel_index: int, spec_channel: Tensor, total_seconds: float, over_curve: Optional[List[Union[Tensor, Tuple[Tensor, Tensor]]]], over_curve_names: Optional[List[str]], theme_hook: ThemeHook, cmap: str, over_curve_colors: Optional[List[Optional[str]]], stay_color: str, colorbar: bool, title: Optional[str], embed_title: bool, freq_label: Optional[str], hz_min: float, hv_max: float, over_curve_axes: Optional[List[str]], axes_limits: Optional[Dict[str, Tuple[Optional[Union[float, int]], Optional[Union[float, int]]]]]) Layout[source]#
- Creates a HoloViews plot of the progress bar.
Parameters#
channel_indexintThe current channel to generate spectrogram for
spec_channeltorch.TensorThe spectrogram of the current channel
total_secondsfloatThe total amount of seconds in the
wavas calculated according to thesrover_curveList[torch.Tensor]A list of curves to be displayed over the spectrogram
over_curve_namesList[str]A list of display names corresponding to the list given in
over_curvetheme_hookThemeHookThe HoloViews hook for applying a Bokeh theme, see ThemeHook.
cmapstrThe colormap used to display the spectrogram
over_curve_colorsList[str]A list of display colors corresponding to the list given in
over_curvestay_colorstrThe color for the current time cursor when not following it
colorbarboolWhether to display a colorbar for the spectrograms
titlestrSets the title of the chart, which is displayed when
embed_title=Trueembed_titleboolDisplayed the
title as part of the plot when ``Truefreq_labelstrThe label of the frequency axis (vertical), hides the label when set to None which saves space.
hz_minintMinimum frequency in the torchaudio spectrogram
hz_maxintMaximum frequency in the torchaudio spectrogram
over_curve_axesList[str]A list of axes names corresponding to the list given in
over_curveaxes_limitsDict[str, Tuple[float, float]]Default limits for any of the axes
Returns#
channel_spectrogram_plothv.LayoutA HoloViews plot of the current channel spectrogram
- waloviz._holoviews_manipulations.create_lim_kwargs(over_curve_axes: Optional[List[str]], axes_limits: Optional[Dict[str, Tuple[Optional[Union[float, int]], Optional[Union[float, int]]]]]) Dict[str, Dict[str, Tuple[Optional[Union[float, int]], Optional[Union[float, int]]]]][source]#
- Creates a dict with kwargs for axis limiting, in the required HoloViews axis limits format.
Parameters#
over_curve_axesList[str].
axes_limitsDict[str, Tuple[float, float]].
Returns#
lim_kwargsDict[str, Dict[str, Tuple[float, float]]]The limit kwargs for each axis as required by HoloViews
- waloviz._holoviews_manipulations.create_progress_bar_plot(total_seconds: float, pbar_height: int) Layout[source]#
- Creates a HoloViews plot of the progress bar.
Parameters#
total_secondsfloatThe total amount of seconds in the
wavas calculated according to thesrpbar_heightintThe total height of both the pbar itself and its axis
Returns#
pbarhv.LayoutA HoloViews plot of the progress bar
- waloviz._holoviews_manipulations.get_player_hv(wav: Tensor, sr: int, total_seconds: float, over_curve: Optional[List[Union[Tensor, Tuple[Tensor, Tensor]]]], over_curve_names: Optional[List[str]], n_fft: int, hop_length: int, sync_legends: bool, pbar_height: int, theme_hook: ThemeHook, max_size: int, cmap: str, over_curve_colors: Optional[List[Optional[str]]], stay_color: str, colorbar: bool, title: Optional[str], embed_title: bool, freq_label: Optional[str], over_curve_axes: Optional[List[str]], axes_limits: Optional[Dict[str, Tuple[Optional[Union[float, int]], Optional[Union[float, int]]]]]) Layout[source]#
- Uses HoloViews to create the plots elements of the player, without any custom interactivity.
Parameters#
wavtorch.TensorLoaded audio tensor
srintResolved sample-rate
total_secondsfloatThe total amount of seconds in the
wavas calculated according to thesrover_curveList[torch.Tensor]A list of curves to be displayed over the spectrogram
over_curve_namesList[str]A list of display names corresponding to the list given in
over_curven_fftintSets the
n_fftof the torchaudio spectrogramhop_lengthintSets the
hop_lengthof the torchaudio spectrogramsync_legendsboolWhether the legends of both audio channels
over_curves should be synchronizedpbar_heightintThe total height of both the pbar itself and its axis
theme_hookThemeHookThe HoloViews hook for applying a Bokeh theme, see ThemeHook.
max_sizeintThe maximum amount of values allowed in the time axis, for both spectrograms and overlaid curves.
cmapstrThe colormap used to display the spectrogram
over_curve_colorsList[str]A list of display colors corresponding to the list given in
over_curvestay_colorstrThe color for the current time cursor when not following it
follow_colorstrThe color for the current time cursor only when following it
colorbarboolWhether to display a colorbar for the spectrograms
titlestrSets the title of the chart, which is displayed when
embed_title=Trueembed_titleboolDisplayed the
titleas part of the plot whenTruefreq_labelstrThe label of the frequency axis (vertical), hides the label when set to None which saves space.
over_curve_axesList[str]A list of axes names corresponding to the list given in
over_curveaxes_limitsDict[str, Tuple[float, float]]Default limits for any of the axes
Returns#
player_hvhv.LayoutThe basic player plot elements in HoloViews format, without any custom interactivity