コード例 #1
0
    def convert_loop(self, in_feature: AcousticFeature, n_len: int = 512, n_wrap: int = 128):
        out_feature_list: List[AcousticFeature] = []
        N = len(in_feature.f0)
        for i in numpy.arange(0, int(numpy.ceil(N / n_len))):
            # convert with overwrapped
            start = i * n_len
            mi = max(start - n_wrap, 0)
            ma = min(start + n_len + n_wrap, N)
            f = in_feature.indexing(numpy.arange(mi, ma))
            o_warp = self.convert(f)

            # eliminate overwrap
            ex_mi = start - mi
            ex_len = min(ma - start, n_len)
            o = o_warp.indexing(numpy.arange(ex_mi, ex_mi + ex_len))
            out_feature_list.append(o)
        return AcousticFeature.concatenate(out_feature_list)
コード例 #2
0
    def post_convert(self, start_time: float, time_length: float):
        sizes = AcousticFeature.get_sizes(sampling_rate=self.sampling_rate, order=self.order)
        keys = ['f0', 'ap', 'sp', 'voiced']
        out_feature = self.fetch(
            start_time=start_time,
            time_length=time_length,
            data_stream=self._out_feature_stream,
            rate=1000 / self.frame_period,
            pad_function=lambda length: AcousticFeature.silent(length, sizes=sizes, keys=keys),
            pick_function=lambda segment, first, last: segment.feature.pick(first, last, keys=keys),
            concat_function=lambda buffers: AcousticFeature.concatenate(buffers, keys=keys),
        )

        out_wave = self.vocoder.decode(
            acoustic_feature=out_feature,
        )

        w = out_wave.wave
        w[numpy.isnan(w)] = 0
        out_wave = Wave(wave=w, sampling_rate=out_wave.sampling_rate)
        return out_wave
コード例 #3
0
ファイル: feature_segment.py プロジェクト: RaiJPch/test
 def concat(self, datas: Iterable[AcousticFeatureWrapper]):
     return AcousticFeature.concatenate(list(datas), keys=self._keys)