#!/usr/bin/env python2 # Copyright 2014 The Chromium OS Authors. All rights reserved. # Use of this source code is governed by a BSD-style license that can be # found in the LICENSE file. """This module provides abstraction of audio data.""" import contextlib import copy import numpy as np import struct import StringIO """The dict containing information on how to parse sample from raw data. Keys: The sample format as in aplay command. Values: A dict containing: message: Human-readable sample format. dtype_str: Data type used in numpy dtype. Check https://docs.scipy.org/doc/numpy/reference/arrays.dtypes.html for supported data type. size_bytes: Number of bytes for one sample. """ SAMPLE_FORMATS = dict( S32_LE=dict( message='Signed 32-bit integer, little-endian', dtype_str='