_holoviews_manipulations Module#

Inheritance diagram of waloviz._holoviews_manipulations

_holoviews_manipulations Module#

class waloviz._holoviews_manipulations.ThemeHook(theme_obj: Dict[str, Any])[source]#

Bases: object

A 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.
TODO: Open an Issue in the HoloViews \ Panel repository about this

Parameters#

theme_objDict[str, Any]

A Bokeh theme object


hook(plot: Model, element: Any) None[source]#
A HoloViews hook for applying a Bokeh theme.

Parameters#

plotDict[str, Any]

A Bokeh theme object

elementAny

Irrelevant


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#

srint

Resolved sample-rate

n_fftint

Sets the n_fft of the torchaudio spectrogram

Returns#

hz_minint

Minimum frequency in the torchaudio spectrogram

hz_maxint

Maximum 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_legendsbool

Whether the legends of both audio channels over_curve s should be synchronized

theme_hookThemeHook

The HoloViews hook for applying a Bokeh theme, see ThemeHook.

stay_colorstr

The color for the current time cursor when not following it

responsivebool

Whether the plot width and height should be responsive

Returns#

player_hvhv.Layout

A 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_indexint

The current channel to generate spectrogram for

spec_channeltorch.Tensor

The spectrogram of the current channel

total_secondsfloat

The total amount of seconds in the wav as calculated according to the sr

over_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_curve

theme_hookThemeHook

The HoloViews hook for applying a Bokeh theme, see ThemeHook.

cmapstr

The colormap used to display the spectrogram

over_curve_colorsList[str]

A list of display colors corresponding to the list given in over_curve

stay_colorstr

The color for the current time cursor when not following it

colorbarbool

Whether to display a colorbar for the spectrograms

titlestr

Sets the title of the chart, which is displayed when embed_title=True

embed_titlebool

Displayed the title as part of the plot when ``True

freq_labelstr

The label of the frequency axis (vertical), hides the label when set to None which saves space.

hz_minint

Minimum frequency in the torchaudio spectrogram

hz_maxint

Maximum frequency in the torchaudio spectrogram

over_curve_axesList[str]

A list of axes names corresponding to the list given in over_curve

axes_limitsDict[str, Tuple[float, float]]

Default limits for any of the axes

Returns#

channel_spectrogram_plothv.Layout

A 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_secondsfloat

The total amount of seconds in the wav as calculated according to the sr

pbar_heightint

The total height of both the pbar itself and its axis

Returns#

pbarhv.Layout

A 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.Tensor

Loaded audio tensor

srint

Resolved sample-rate

total_secondsfloat

The total amount of seconds in the wav as calculated according to the sr

over_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_curve

n_fftint

Sets the n_fft of the torchaudio spectrogram

hop_lengthint

Sets the hop_length of the torchaudio spectrogram

sync_legendsbool

Whether the legends of both audio channels over_curve s should be synchronized

pbar_heightint

The total height of both the pbar itself and its axis

theme_hookThemeHook

The HoloViews hook for applying a Bokeh theme, see ThemeHook.

max_sizeint

The maximum amount of values allowed in the time axis, for both spectrograms and overlaid curves.

cmapstr

The colormap used to display the spectrogram

over_curve_colorsList[str]

A list of display colors corresponding to the list given in over_curve

stay_colorstr

The color for the current time cursor when not following it

follow_colorstr

The color for the current time cursor only when following it

colorbarbool

Whether to display a colorbar for the spectrograms

titlestr

Sets the title of the chart, which is displayed when embed_title=True

embed_titlebool

Displayed the title as part of the plot when True

freq_labelstr

The 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_curve

axes_limitsDict[str, Tuple[float, float]]

Default limits for any of the axes

Returns#

player_hvhv.Layout

The basic player plot elements in HoloViews format, without any custom interactivity