Esempio n. 1
0
def generate_feature(path: Path):
    out = Path(arguments.output, path.stem + '.npy')
    if out.exists() and not arguments.enable_overwrite:
        return

    # load wave and padding
    wave = Wave.load(path=path, sampling_rate=arguments.sampling_rate)
    wave = wave.pad(pre_second=arguments.pad_second,
                    post_second=arguments.pad_second)

    # make acoustic feature
    feature = AcousticFeature.extract(
        wave=wave,
        frame_period=arguments.frame_period,
        f0_floor=arguments.f0_floor,
        f0_ceil=arguments.f0_ceil,
        fft_length=arguments.fft_length,
        order=arguments.order,
        alpha=arguments.alpha,
        dtype=arguments.dtype,
    )

    if arguments.threshold_db is not None:
        index = wave.get_effective_frame(
            threshold_db=arguments.threshold_db,
            fft_length=arguments.fft_length,
            frame_period=arguments.frame_period,
        )
        feature = feature.indexing(index)

    # save
    feature.save(path=out, validate=True, ignores=arguments.ignore_feature)
Esempio n. 2
0
 def extract_acoustic_feature(self, wave: Wave):
     return AcousticFeature.extract(
         wave,
         frame_period=self._param.frame_period,
         f0_floor=self._param.f0_floor,
         f0_ceil=self._param.f0_ceil,
         fft_length=self._param.fft_length,
         order=self._param.order,
         alpha=self._param.alpha,
         dtype=self._param.dtype,
     )
Esempio n. 3
0
def generate_feature(path: Path):
    out = Path(arguments.output, path.stem + '.npy')
    if out.exists() and not arguments.enable_overwrite:
        return

    # load wave and padding
    wave = Wave.load(path=path, sampling_rate=arguments.sampling_rate)
    wave = wave.pad(pre_second=arguments.pad_second,
                    post_second=arguments.pad_second)

    # make acoustic feature
    feature = AcousticFeature.extract(
        wave=wave,
        frame_period=arguments.frame_period,
        f0_floor=arguments.f0_floor,
        f0_ceil=arguments.f0_ceil,
        fft_length=arguments.fft_length,
        order=arguments.order,
        alpha=arguments.alpha,
        dtype=arguments.dtype,
    )

    if arguments.threshold_db is not None:
        if arguments.sampling_rate_for_thresholding is not None:
            wave_ref = Wave.load(
                path=path,
                sampling_rate=arguments.sampling_rate_for_thresholding)
            wave_ref = wave_ref.pad(pre_second=arguments.pad_second,
                                    post_second=arguments.pad_second)
        else:
            wave_ref = wave

        effective = wave_ref.get_effective_frame(
            threshold_db=arguments.threshold_db,
            fft_length=arguments.fft_length,
            frame_period=arguments.frame_period,
        )

        # there is possibility mismatch of length
        # https://github.com/mmorise/World/blob/c41e580c24c8d360f322ba6e2092ad4785d2d5b9/src/harvest.cpp#L1220
        len_wave = wave.get_hop_and_length(arguments.frame_period)[1]
        len_wave_ref = wave_ref.get_hop_and_length(arguments.frame_period)[1]
        if len_wave == len_wave_ref - 1:
            effective = effective[:-1]

        feature = feature.indexing(effective)

    # save
    feature.save(path=out, ignores=arguments.ignore_feature)