Ejemplo n.º 1
0
    def get_normalisation_params(self, dir_out, file_name=None):
        """
        Read the mean std_dev values from a file.
        Save them in self.norm_params.

        :param dir_out:       Directory containing the normalisation file.
        :param file_name:     Prefix of normalisation file.
                              Expects file to be named <file_name-><MeanStdDevExtractor.file_name_appendix>.bin
        :return:              Tuple of normalisation parameters (mean, std_dev).
        """

        if not self.add_deltas:
            # Collect all means and std_devs in a list.
            all_mean = list()
            all_std_dev = list()
            full_file_name = (
                file_name + "-" if file_name is not None else
                "") + MeanStdDevExtractor.file_name_appendix + ".bin"
            # Load normalisation parameters for all features.
            for dir_feature in [
                    self.dir_coded_sps, self.dir_lf0, self.dir_bap
            ]:
                mean, std_dev = MeanStdDevExtractor.load(
                    os.path.join(dir_out, dir_feature, full_file_name))
                all_mean.append(np.atleast_2d(mean))
                all_std_dev.append(np.atleast_2d(std_dev))
            # Manually set vuv normalisation paramters.
            all_mean.insert(-1, np.atleast_2d(0.0))
            all_std_dev.insert(-1, np.atleast_2d(1.0))

            # Save the concatenated normalisation parameters locally.
            self.norm_params = np.concatenate(
                all_mean, axis=1), np.concatenate(all_std_dev, axis=1)
        else:
            full_file_name = (
                file_name + "-" if file_name is not None else ""
            ) + MeanCovarianceExtractor.file_name_appendix  # + "_" + self.dir_coded_sps + ".bin"
            # Load the normalisation parameters.
            mean_coded_sp, self.cov_coded_sp, std_dev_coded_sp = MeanCovarianceExtractor.load(
                os.path.join(
                    dir_out, self.dir_deltas,
                    full_file_name + "_" + self.dir_coded_sps + ".bin"))
            mean_lf0, self.cov_lf0, std_dev_lf0 = MeanCovarianceExtractor.load(
                os.path.join(dir_out, self.dir_deltas,
                             full_file_name + "_" + self.dir_lf0 + ".bin"))
            mean_bap, self.cov_bap, std_dev_bap = MeanCovarianceExtractor.load(
                os.path.join(dir_out, self.dir_deltas,
                             full_file_name + "_" + self.dir_bap + ".bin"))

            self.norm_params = (np.concatenate(
                (mean_coded_sp, mean_lf0, np.atleast_1d(0.0), mean_bap)),
                                np.concatenate(
                                    (std_dev_coded_sp, std_dev_lf0,
                                     np.atleast_1d(1.0), std_dev_bap)))

        return self.norm_params
Ejemplo n.º 2
0
    def get_normalisation_params(self, dir_out, file_name=None):
        """
        Read the mean std_dev values from a file.
        Save them in self.norm_params.

        :param dir_out:       Directory containing the normalisation file.
        :param file_name:     Prefix of normalisation file.
                              Expects file to be named <file_name-><MeanStdDevExtractor.file_name_appendix>.bin
        :return:              Tuple of normalisation parameters (mean, std_dev).
        """

        full_file_name = (file_name + "-" if file_name is not None else "") + MeanStdDevExtractor.file_name_appendix + ".bin"

        if not self.add_deltas:
            # Collect all means and std_devs in a list.
            all_mean = list()
            all_std_dev = list()
            # Load normalisation parameters for all features.
            mean, std_dev = MeanStdDevExtractor.load(os.path.join(dir_out, self.dir_lf0, full_file_name))
            all_mean.append(np.atleast_2d(mean))
            all_std_dev.append(np.atleast_2d(std_dev))
            # Manually set vuv normalisation parameters.
            # Note that vuv normalisation parameters are not saved in gen_data method (except for add_deltas=True).
            all_mean.append(np.atleast_2d(0.0))
            all_std_dev.append(np.atleast_2d(1.0))

            # for dir_feature in [self.dir_lf0, self.dir_vuv]:
            #     mean, std_dev = MeanStdDevExtractor.load(os.path.join(dir_out, dir_feature, full_file_name))
            #     all_mean.append(np.atleast_2d(mean))
            #     all_std_dev.append(np.atleast_2d(std_dev))

            # Save the concatenated normalisation parameters locally.
            self.norm_params = np.concatenate(all_mean, axis=1), np.concatenate(all_std_dev, axis=1)
        else:
            # Save the normalisation parameters locally.
            # VUV normalisation parameters are manually set to mean=0 and std_dev=1 in gen_data method.
            self.norm_params = MeanStdDevExtractor.load(os.path.join(dir_out, self.dir_deltas, full_file_name))

        return self.norm_params
    def get_normalisation_params(self, dir_out, file_name=None):
        """
        Read mean std_dev values from a file.
        Save them in self.norm_params

        :param dir_out:       Directory containing the normalisation file.
        :param file_name:     Prefix of normalisation file.
                              Expects file to be named <file_name-><MeanStdDevExtractor.file_name_appendix>.bin
        :return:              Tuple of normalisation parameters (mean, std_dev).
        """

        full_file_name = (file_name + "-" if file_name is not None else
                          "") + MeanStdDevExtractor.file_name_appendix + ".bin"
        self.norm_params = MeanStdDevExtractor.load(
            os.path.join(self.dir_labels, full_file_name))

        return self.norm_params
Ejemplo n.º 4
0
    def get_normalisation_params(self, dir_out, file_name=None):
        """
        Read the mean std_dev values from a file.
        Save them in self.norm_params.

        :param dir_out:       Directory containing the normalisation file, usually the atom directory.
        :param file_name:     Prefix of normalisation file.
                              Expects file to be named <file_name-><MeanStdDevExtractor.file_name_appendix>.bin
        :return:              Tuple of normalisation parameters (mean, std_dev).
        """

        full_file_name = (file_name + "-" if file_name is not None else "") + MeanStdDevExtractor.file_name_appendix + ".bin"

        # Use the same normalisation parameters for the LF0 curve without phrase curve
        # as for atoms. The phrase directory is the same as the atom directory.
        mean, std_dev = MeanStdDevExtractor.load(os.path.join(self.dir_phrase, full_file_name))
        mean, std_dev = mean[:, 0:1], std_dev[:, 0:1]  # Dimension of both is 1 x 2(atom amplitude, theta).

        # Manually set V/UV normalisation parameters and save the concatenated normalisation parameters locally.
        self.norm_params = np.concatenate((mean, np.zeros((1, 1))), axis=1),\
                           np.concatenate((std_dev, np.ones((1, 1))), axis=1)

        return self.norm_params