(wav_audio, hparams)
return frames
Transforms the contents of a wav file into a series of framed samples.
Transforms the contents of a wav file into a series of framed samples.
Transforms the contents of a wav file into a series of framed samples .
def _wav_to_framed_samples(wav_audio, hparams):
  """Transforms the contents of a wav file into a series of framed samples."""
  y = audio_io.wav_data_to_samples(wav_audio, hparams.sample_rate)

  hl = hparams.spec_hop_length
  n_frames = int(np.ceil(y.shape[0] / hl))
  frames = np.zeros((n_frames, hl), dtype=np.float32)

  # Fill in everything but the last frame which may not be the full length
  cutoff = (n_frames - 1) * hl
  frames[:n_frames - 1, :] = np.reshape(y[:cutoff], (n_frames - 1, hl))
  # Fill the last frame
  remain_len = len(y[cutoff:])
  frames[n_frames - 1, :remain_len] = y[cutoff:]

  return frames
def _wav_to_framed_samples ( wav_audio , hparams ) : y = audio_io . wav_data_to_samples ( wav_audio , hparams . sample_rate ) hl = hparams . spec_hop_length n_frames = int ( np . ceil ( y . shape [ 0 ] / hl ) ) frames = np . zeros ( ( n_frames , hl ) , dtype = np . float32 ) # Fill in everything but the last frame which may not be the full length cutoff = ( n_frames - 1 ) * hl frames [ : n_frames - 1 , : ] = np . reshape ( y [ : cutoff ] , ( n_frames - 1 , hl ) ) # Fill the last frame remain_len = len ( y [ cutoff : ] ) frames [ n_frames - 1 , : remain_len ] = y [ cutoff : ] return frames