def __audioread_load(path, offset, duration, dtype):
y = []<EOL>with audioread.audio_open(path) as input_file:<EOL><INDENT>sr_native = input_file.samplerate<EOL>n_channels = input_file.channels<EOL>s_start = int(np.round(sr_native * offset)) * n_channels<EOL>if duration is None:<EOL><INDENT>s_end = np.inf<EOL><DEDENT>else:<EOL><INDENT>s_end = s_start + (int(np.round(sr_native * duration))<EOL>* n_channels)<EOL><DEDENT>n = <NUM_LIT:0><EOL>for frame in input_file:<EOL><INDENT>frame = util.buf_to_float(frame, dtype=dtype)<EOL>n_prev = n<EOL>n = n + len(frame)<EOL>if n < s_start:<EOL><INDENT>continue<EOL><DEDENT>if s_end < n_prev:<EOL><INDENT>break<EOL><DEDENT>if s_end < n:<EOL><INDENT>frame = frame[:s_end - n_prev]<EOL><DEDENT>if n_prev <= s_start <= n:<EOL><INDENT>frame = frame[(s_start - n_prev):]<EOL><DEDENT>y.append(frame)<EOL><DEDENT><DEDENT>if y:<EOL><INDENT>y = np.concatenate(y)<EOL>if n_channels > <NUM_LIT:1>:<EOL><INDENT>y = y.reshape((-<NUM_LIT:1>, n_channels)).T<EOL><DEDENT><DEDENT>else:<EOL><INDENT>y = np.empty(<NUM_LIT:0>, dtype=dtype)<EOL><DEDENT>return y, sr_native<EOL>
Load an audio buffer using audioread.

    This loads one block at a time, and then concatenates the results.