cbspace commited on
Commit
134578e
·
verified ·
1 Parent(s): 8c5c24b

Update app.py

Browse files

Added cool_speak tool

Files changed (1) hide show
  1. app.py +33 -7
app.py CHANGED
@@ -4,19 +4,45 @@ import requests
4
  import pytz
5
  import yaml
6
  from tools.final_answer import FinalAnswerTool
7
-
8
  from Gradio_UI import GradioUI
9
 
10
  # Below is an example of a tool that does nothing. Amaze us with your creativity !
11
  @tool
12
- def my_custom_tool(arg1:str, arg2:int)-> str: #it's import to specify the return type
13
- #Keep this format for the description / args / args description but feel free to modify the tool
14
- """A tool that does nothing yet
15
  Args:
16
- arg1: the first argument
17
- arg2: the second argument
18
  """
19
- return "What magic will you build ?"
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
20
 
21
  @tool
22
  def get_current_time_in_timezone(timezone: str) -> str:
 
4
  import pytz
5
  import yaml
6
  from tools.final_answer import FinalAnswerTool
7
+ import re
8
  from Gradio_UI import GradioUI
9
 
10
  # Below is an example of a tool that does nothing. Amaze us with your creativity !
11
  @tool
12
+ def cool_speak(speech_text:str)-> str:
13
+ """A tool that makes your speech much cooler
 
14
  Args:
15
+ speech_text: Input speech text to be translated to cool talk
 
16
  """
17
+ cool_mapping = {
18
+ 'hello': 'yo',
19
+ 'bye': 'peace out!',
20
+ 'man': 'homie',
21
+ 'money': 'moolah',
22
+ 'brother': 'bro',
23
+ 'sister': 'sis',
24
+ 'boss': 'big chief',
25
+ 'everyone': 'the crew',
26
+ 'understand': 'vibe with',
27
+ 'hurry': 'step on it',
28
+ 'leave': 'bounce',
29
+ 'sleep': 'crash',
30
+ 'work': 'the grind',
31
+ 'house': 'crib',
32
+ 'car': 'whip',
33
+ 'shoes': 'kicks',
34
+ 'food': 'grub',
35
+ 'clothes': 'threads'
36
+ }
37
+ coolified = []
38
+ words_of_interest = set(cool_mapping.keys())
39
+ words = re.sub(r'[^a-z\s]', '', speech_text.lower()).split()
40
+ for word in words:
41
+ if word in words_of_interest:
42
+ coolified.append(cool_mapping[word])
43
+ else:
44
+ coolified.append(word)
45
+ return ' '.join(coolified)
46
 
47
  @tool
48
  def get_current_time_in_timezone(timezone: str) -> str: