def get_f0s_from_list(conf, list_file, wav_dir): # open list file with open(list_file, 'r') as fp: files = fp.readlines() f0s = [] for f in files: # open wave file f = f.rstrip() wavf = os.path.join(wav_dir, f + '.wav') fs, x = wavfile.read(wavf) x = np.array(x, dtype=np.float) assert fs == conf.wav_fs print("Extract F0: " + wavf) # constract FeatureExtractor clas feat = FeatureExtractor(analyzer=conf.analyzer, fs=conf.wav_fs, fftl=conf.wav_fftl, shiftms=conf.wav_shiftms, minf0=conf.f0_minf0, maxf0=conf.f0_maxf0) f0 = feat.analyze_f0(x) f0s.append(f0) return f0s
def get_f0s_from_list(conf, list_file, wav_dir): """Get f0s from listfile Parameters --------- conf : SpeakerYML, Speaker dependent YAML class listfile : str, path-like, File path of the list file of the speaker wav_dir : str, path-like, Directory path of the waveform Returns --------- f0s : list, shape(`num_files`), List of the f0s """ # open list file with open(list_file, 'r') as fp: files = fp.readlines() f0s = [] for f in files: # open wave file f = f.rstrip() wavf = os.path.join(wav_dir, f + '.wav') fs, x = wavfile.read(wavf) x = np.array(x, dtype=np.float) x = low_cut_filter(x, fs, cutoff=70) assert fs == conf.wav_fs print("Extract F0: " + wavf) # constract FeatureExtractor clas feat = FeatureExtractor(analyzer=conf.analyzer, fs=conf.wav_fs, fftl=conf.wav_fftl, shiftms=conf.wav_shiftms, minf0=conf.f0_minf0, maxf0=conf.f0_maxf0) f0 = feat.analyze_f0(x) f0s.append(f0) return f0s
def get_f0s_from_list(conf, list_file, wav_dir): """Get f0s from listfile Parameters --------- conf : SpeakerYML, Speaker dependent YAML class listfile : str, path-like, File path of the list file of the speaker wav_dir : str, path-like, Directory path of the waveform Returns --------- f0s : list, shape(`num_files`), List of the f0s """ # open list file with open(list_file, 'r') as fp: files = fp.readlines() f0s = [] for f in files: # open wave file f = f.rstrip() wavf = os.path.join(wav_dir, f + '.wav') fs, x = wavfile.read(wavf) x = np.array(x, dtype=np.float) x = low_cut_filter(x, fs, cutoff=70) assert fs == conf.wav_fs print("Extract F0: " + wavf) # constract FeatureExtractor clas feat = FeatureExtractor(analyzer=conf.analyzer, fs=conf.wav_fs, fftl=conf.wav_fftl, shiftms=conf.wav_shiftms, minf0=conf.f0_minf0, maxf0=conf.f0_maxf0) f0 = feat.analyze_f0(x) f0s.append(f0) return f0s
def main(*argv): argv = argv if argv else sys.argv[1:] dcp = 'create speaker-dependent configure file (speaker.yml)' parser = argparse.ArgumentParser(description=dcp) parser.add_argument('speaker', type=str, help='Input speaker label') parser.add_argument('list_file', type=str, help='List file of the input speaker') parser.add_argument('wav_dir', type=str, help='Directory of wav file') parser.add_argument('figure_dir', type=str, help='Directory for figure output') args = parser.parse_args(argv) # open list file with open(args.list_file, 'r') as fp: files = fp.readlines() f0s = [] for f in files: # open waveform f = f.rstrip() wavf = os.path.join(args.wav_dir, f + '.wav') fs, x = wavfile.read(wavf) x = np.array(x, dtype=np.float) print("Extract f0: " + wavf) # constract FeatureExtractor clas feat = FeatureExtractor(analyzer='world', fs=fs) f0 = feat.analyze_f0(x) # f0 extraction f0s.append(f0) # create a figure to visualize F0 range of the speaker f0histogrampath = os.path.join(args.figure_dir, args.speaker + '_f0histogram.png') create_f0_histogram(np.hstack(f0s).flatten(), f0histogrampath)