def read(self, num_frames):
from samplerate.lowlevel import src_callback_read, src_error<EOL>from samplerate.exceptions import ResamplingError<EOL>if self._state is None:<EOL><INDENT>self._create()<EOL><DEDENT>if self._channels > <NUM_LIT:1>:<EOL><INDENT>output_shape = (num_frames, self._channels)<EOL><DEDENT>elif self._channels == <NUM_LIT:1>:<EOL><INDENT>output_shape = (num_frames, )<EOL><DEDENT>output_data = np.empty(output_shape, dtype=np.float32)<EOL>ret = src_callback_read(self._state, self._ratio, num_frames,<EOL>output_data)<EOL>if ret == <NUM_LIT:0>:<EOL><INDENT>error = src_error(self._state)<EOL>if error:<EOL><INDENT>raise ResamplingError(error)<EOL><DEDENT><DEDENT>return (output_data[:ret, :]<EOL>if self._channels > <NUM_LIT:1> else output_data[:ret])<EOL>
Read a number of frames from the resampler.

        Parameters
        ----------
        num_frames : int
            Number of frames to read.

        Returns
        -------
        output_data : ndarray
            Resampled frames as a (`num_output_frames`, `num_channels`) or
            (`num_output_frames`,) array. Note that this may return fewer frames
            than requested, for example when no more input is available.