import numpy as np
import wave as wv


def load_sound(file, n0):

    x_raw = wv.open(file)
    n = x_raw.getnframes()
    x = np.fromstring(x_raw.readframes(-1), 'Int16')
    x_raw.close()

    if file[::-1][:8][::-1] == "bird.wav":
        x = np.delete(
            x,
            list(range(6001)) + list(range(12500, 15001)) +
            list(range(22500, 24001)) + list(range(32500, 34001)))

    if n0 != 0 and n0 < n:
        x = x[:n0]

    return x / np.max(x)
