Beispiel #1
0
def show_audio_signal(ai, ctx, ax=None, title="", **kwargs):
    ax = ifnone(ax, ctx)
    if ax is None:
        _, ax = plt.subplots()
    ax.axis(False)
    for i, channel in enumerate(ai):
        # x_start, y_start, x_lenght, y_lenght, all in percent
        ia = ax.inset_axes((i / ai.nchannels, 0.2, 1 / ai.nchannels, 0.7))
        waveplot(channel.cpu().numpy(), ai.sr, ax=ia, **kwargs)
        ia.set_title(f"Channel {i}")
    ax.set_title(title)

    return ax
Beispiel #2
0
def show_spectrogram(sg, title="", ax=None, ctx=None, **kwargs):
    ax = ifnone(ax, ctx)
    if ax is None:
        _, ax = plt.subplots()
    ax.axis(False)
    for i, channel in enumerate(sg):
        # x_start, y_start, x_lenght, y_lenght, all in percent
        ia = ax.inset_axes((i / sg.nchannels, 0.2, 1 / sg.nchannels, 0.7))
        z = specshow(
            channel.cpu().numpy(), ax=ia, **sg._all_show_args(show_y=i == 0), **kwargs
        )
        ia.set_title(f"Channel {i}")
        if i == 0:  # Only colorbar the first one
            plt.colorbar(z, format=sg._colorbar_fmt, ax=ax)
    ax.set_title(title)

    return ax