davidxia commited on
Commit
0811999
·
verified ·
1 Parent(s): 1b8f451

Change to use text_to_speech

Browse files
Files changed (4) hide show
  1. README.md +1 -1
  2. app.py +2 -2
  3. tool.py +8 -9
  4. tool_config.json +5 -5
README.md CHANGED
@@ -1,5 +1,5 @@
1
  ---
2
- title: Text To Image
3
  emoji: 👀
4
  colorFrom: blue
5
  colorTo: indigo
 
1
  ---
2
+ title: Text To Speech
3
  emoji: 👀
4
  colorFrom: blue
5
  colorTo: indigo
app.py CHANGED
@@ -1,4 +1,4 @@
1
  from transformers import launch_gradio_demo
2
- from tool import TextToImageTool
3
 
4
- launch_gradio_demo(TextToImageTool)
 
1
  from transformers import launch_gradio_demo
2
+ from tool import TextToSpeechTool
3
 
4
+ launch_gradio_demo(TextToSpeechTool)
tool.py CHANGED
@@ -2,14 +2,13 @@ from smolagents import Tool
2
  from huggingface_hub import InferenceClient
3
 
4
 
5
- class TextToImageTool(Tool):
6
- description = "This tool creates an image according to a prompt, which is a text description."
7
- name = "image_generator"
8
- inputs = {"prompt": {"type": "string", "description": "The image generator prompt. Don't hesitate to add details in the prompt to make the image look better, like 'high-res, photorealistic', etc."}}
9
- output_type = "image"
10
- model_sdxl = "black-forest-labs/FLUX.1-schnell"
11
- client = InferenceClient(model_sdxl)
12
 
13
 
14
- def forward(self, prompt):
15
- return self.client.text_to_image(prompt)
 
2
  from huggingface_hub import InferenceClient
3
 
4
 
5
+ class TextToSpeechTool(Tool):
6
+ description = "This tool synthesizes speech from text."
7
+ name = "speech_generator"
8
+ inputs = {"text": {"type": "string", "description": "The text input"}}
9
+ output_type = "audio"
10
+ client = InferenceClient()
 
11
 
12
 
13
+ def forward(self, text):
14
+ return self.client.text_to_speech(text)
tool_config.json CHANGED
@@ -1,7 +1,7 @@
1
  {
2
- "description": "This is a tool that creates an image according to a prompt, which is a text description.",
3
- "inputs": "{'prompt': {'type': 'string', 'description': \"The image generator prompt. Don't hesitate to add details in the prompt to make the image look better, like 'high-res, photorealistic', etc.\"}}",
4
- "name": "image_generator",
5
- "output_type": "image",
6
- "tool_class": "tool.TextToImageTool"
7
  }
 
1
  {
2
+ "description": "This is a tool that synthesizes speech from text.",
3
+ "inputs": "{'prompt': {'type': 'string', 'description': \"The text input"}}",
4
+ "name": "speech_generator",
5
+ "output_type": "audio",
6
+ "tool_class": "tool.TextToSpeechTool"
7
  }