Fork of https://github.com/alokprasad/fastspeech_squeezewave to also fix denoising in squeezewave
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

34 lines
988 B

  1. import numpy as np
  2. import os
  3. import audio as Audio
  4. def build_from_path(in_dir, out_dir):
  5. index = 1
  6. out = list()
  7. with open(os.path.join(in_dir, 'metadata.csv'), encoding='utf-8') as f:
  8. for line in f:
  9. parts = line.strip().split('|')
  10. wav_path = os.path.join(in_dir, 'wavs', '%s.wav' % parts[0])
  11. text = parts[2]
  12. out.append(_process_utterance(out_dir, index, wav_path, text))
  13. if index % 100 == 0:
  14. print("Done %d" % index)
  15. index = index + 1
  16. return out
  17. def _process_utterance(out_dir, index, wav_path, text):
  18. # Compute a mel-scale spectrogram from the wav:
  19. mel_spectrogram = Audio.tools.get_mel(wav_path).numpy().astype(np.float32)
  20. # print(mel_spectrogram)
  21. # Write the spectrograms to disk:
  22. mel_filename = 'ljspeech-mel-%05d.npy' % index
  23. np.save(os.path.join(out_dir, mel_filename),
  24. mel_spectrogram.T, allow_pickle=False)
  25. return text