pydrobert.speech.vis
Visualization functions
- raises ImportError:
This submodule requires
matplotlib
- pydrobert.speech.vis.compare_feature_frames(computers, signal, axes=None, figure_height=None, figure_width=None, plot_titles=None, positions=None, post_ops=None, title=None, **kwargs)[source]
Compare features from frame computers via spectrogram-like heat map
Direct comparison of
FrameComputer
objects is possible because all subclasses of this abstract data type share a common interpretation of frame boundaries (according toFrameComputer.frame_style()
).Additional keyword args will be passed to the plotting routine.
- Parameters:
computers (
Union
[FrameComputer
,Sequence
[FrameComputer
]]) – One or more frame computers to comparesignal (
ndarray
) – A 1D array of the raw speech. Assumed to be valid with respect to computer settings (e.g. sample rate).axes (
Optional
[int
]) – By default, this function creates a new figure and subplots. Setting one axes value for every computers value will plot feature representations from computers into each orderedAxes
. If axes do not belong to the same figure, aValueError
will be raisedfigure_height (
float
) – If a new figure is created, this sets the figure height (in inches). This value is determined dynamically according to figure_width by default. AValueError
will be raised if both figure_height and axes are setfigure_width (
float
) – If a new figure is created, this set the figure width (in inches). This value defaults to 3.33 inches if all subplots are positioned vertically, and to 7 inches if there are at least two columns of plots. AValueError
will be raised if both figure_width and axes are setplot_titles (
Tuple
[str
,...
]) – An ordered list of strings specifying the titles of each subplot. The default is to not display subplot titlespositions (
Tuple
[Union
[int
,Tuple
[int
,int
]],...
]) – If a new figure is created, positions decides how the subplots should be positioned relative to one another. Can contain only ints (describing the position on only the row-axis) or pairs of ints (describing the row-col positions). Positions must be contiguous and start from index 0 or 0,0 (top or top-left). positions cannot be specified if axes is specifiedpost_ops (
Union
[PostProcessor
,Sequence
[PostProcessor
],None
]) – One or more post-processors to apply (in order) to each computed feature representation. If a simple list of post-processors is provided, each operation is applied to the default axis (the feature coefficient axis). To explicitly set the axis, pairs of(op, axis)
can be specified in the list. No op is allowed to change the shape of the feature representation (e.g.Deltas
), or aValueError
will be throwntitle (
Optional
[str
]) – The title of the whole figure. Default is to display no title
- Returns:
fig (
matplotlib.figure.Figure
) – The containing figure
- pydrobert.speech.vis.plot_frequency_response(banks, axes=None, dft_size=None, half=None, title=None, x_scale='hz', y_scale='dB', cmap=None)[source]
Plot frequency response of filters in a filter bank
- Parameters:
bank –
axes (
Optional
[Axes
]) – AnAxes
object to plot on. Default is to generate a new figuredft_size (
Optional
[int
]) – The size of the Discrete Fourier Transform to plot. Defaults tomax(max(bank.supports), 2 * bank.sampling_rate // min(bank.supports_hz)
half (
Optional
[bool
]) – Whether to plot the half or full spectrum. Defaults tobank.is_real
title (
Optional
[str
]) – What to call the graph. The default is not to show a titlex_scale (
Literal
['hz'
,'ang'
,'bins'
]) – The frequency coordinate scale along the x axis. Hertz ('hz'
) is cycles/sec, angular frequency ('ang'
) is radians/sec, and'bins'
is the sample index within the DFTy_scale (
Literal
['dB'
,'power'
,'real'
,'imag'
,'both'
]) – How to express the frequency response along the y axis. Decibels ('dB'
) is the log of a ratio of the maximum quantity in the bank. The range between 0 and -20 decibels is displayed. Power spectrum ('power'
) is the squared magnitude of the frequency response.'real'
is the real part of the response,'imag'
is the imaginary part of the response, and'both'
displays both'real'
and'imag'
as separate linescmap (
Colormap
) – AColormap
to pull colours from. Defaults to matplotlib’s default colormap
- Returns:
fig (
matplotlib.figure.Figure
) – The containing figure