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 to FrameComputer.frame_style()).

Additional keyword args will be passed to the plotting routine.

Parameters:
  • computers (Union[FrameComputer, Sequence[FrameComputer]]) – One or more frame computers to compare

  • signal (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 ordered Axes. If axes do not belong to the same figure, a ValueError will be raised

  • figure_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. A ValueError will be raised if both figure_height and axes are set

  • figure_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. A ValueError will be raised if both figure_width and axes are set

  • plot_titles (Tuple[str, ...]) – An ordered list of strings specifying the titles of each subplot. The default is to not display subplot titles

  • positions (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 specified

  • post_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 a ValueError will be thrown

  • title (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]) – An Axes object to plot on. Default is to generate a new figure

  • dft_size (Optional[int]) – The size of the Discrete Fourier Transform to plot. Defaults to max(max(bank.supports), 2 * bank.sampling_rate // min(bank.supports_hz)

  • half (Optional[bool]) – Whether to plot the half or full spectrum. Defaults to bank.is_real

  • title (Optional[str]) – What to call the graph. The default is not to show a title

  • x_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 DFT

  • y_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 lines

  • cmap (Colormap) – A Colormap to pull colours from. Defaults to matplotlib’s default colormap

Returns:

fig (matplotlib.figure.Figure) – The containing figure