import IPython.display
import numpy as np
import json
def Audio(audio: np.ndarray, rate: int):
"""
Use instead of IPython.display.Audio as a workaround for VS Code.
`audio` is an array with shape (channels, samples) or just (samples,) for mono.
"""
if np.ndim(audio) == 1:
channels = [audio.tolist()]
else:
channels = audio.tolist()
return IPython.display.HTML("""
""" % (json.dumps(channels), rate))