GTimothee commited on
Commit
bea8b31
·
verified ·
1 Parent(s): b5d31dd

Create tool.py

Browse files
Files changed (1) hide show
  1. tool.py +22 -0
tool.py ADDED
@@ -0,0 +1,22 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from smolagents import Tool
2
+
3
+
4
+ class KokoroText2Speech(Tool):
5
+ name = "KokoroText2Speech"
6
+ description = "This is a tool that returns audio data from text."
7
+ inputs = {
8
+ "input_text": {
9
+ "type": "string",
10
+ "description": "Text that you want to convert",
11
+ }
12
+ }
13
+ output_type = "array"
14
+
15
+ def forward(self, input_text: str) -> str:
16
+ from kokoro import KPipeline
17
+ generator = KPipeline(lang_code='a')(
18
+ input_text, voice='af_heart',
19
+ speed=1, split_pattern=r'\n+'
20
+ )
21
+ _, _, audio = next(generator)
22
+ return audio