from smolagents import Tool class KokoroText2Speech(Tool): name = "KokoroText2Speech" description = "This is a tool that returns audio data from text." inputs = { "input_text": { "type": "string", "description": "Text that you want to convert", } } output_type = "array" def forward(self, input_text: str) -> str: from kokoro import KPipeline generator = KPipeline(lang_code='a')( input_text, voice='af_heart', speed=1, split_pattern=r'\n+' ) _, _, audio = next(generator) return audio