def load_and_process_audio(flac_path, sequence_length, device):
    random = np.random.RandomState(seed=42)
    (audio, sr) = soundfile.read(flac_path, dtype='int16')
    assert (sr == SAMPLE_RATE)
    audio = torch.ShortTensor(audio)
    if (sequence_length is not None):
        audio_length = len(audio)
        step_begin = (random.randint((audio_length - sequence_length)) // HOP_LENGTH)
        n_steps = (sequence_length // HOP_LENGTH)
        begin = (step_begin * HOP_LENGTH)
        end = (begin + sequence_length)
        audio = audio[begin:end].to(device)
    else:
        audio = audio.to(device)
    audio = audio.float().div_(32768.0)
    return audio
def load_and_process_audio(flac_path, sequence_length, device):
    random = np.random.RandomState(seed=42)
    (audio, sr) = soundfile.read(flac_path, dtype='int16')
    assert (sr == SAMPLE_RATE)
    audio = torch.ShortTensor(audio)
    if (sequence_length is not None):
        audio_length = len(audio)
        step_begin = (random.randint((audio_length - sequence_length)) // HOP_LENGTH)
        n_steps = (sequence_length // HOP_LENGTH)
        begin = (step_begin * HOP_LENGTH)
        end = (begin + sequence_length)
        audio = audio[begin:end].to(device)
    else:
        audio = audio.to(device)
    audio = audio.float().div_(32768.0)
    return audio