docarray.document.mixins.audio module#

class docarray.document.mixins.audio.AudioDataMixin[source]#

Bases: object

Provide helper functions for Document to support audio data.

save_audio_tensor_to_file(file, sample_rate=44100, sample_width=2)[source]#

Save tensor into an wav file. Mono/stereo is preserved.

Parameters:
  • file (Union[str, BinaryIO]) – if file is a string, open the file by that name, otherwise treat it as a file-like object.

  • sample_rate (int) – sampling frequency

  • sample_width (int) – sample width in bytes

Return type:

T

Returns:

Document itself after processed

load_uri_to_audio_tensor()[source]#

Convert an audio uri into tensor inplace

Return type:

T

Returns:

Document itself after processed