def _map_sample()

in ultravox/tools/ds_tool/ds_tool.py [0:0]


    def _map_sample(self, sample, exclude_fields: Set[str]):
        # using a Jinja template for some added flexibility, template can include variables and functions
        # e.g., {{ text }} or {{ text_proc.format_asr_text(text) }}
        text_or_texts = apply_jinja_template(self.template, sample, exclude_fields)

        if self.json_mode:
            text_or_texts = yaml.safe_load(text_or_texts)
            assert isinstance(text_or_texts, list)
            assert all(isinstance(turn, str) for turn in text_or_texts)

        sample[self.audio_column_name] = tts_client.tts(text_or_texts, self.voice)
        return sample