lchumaceiro commited on
Commit
1560c31
·
verified ·
1 Parent(s): 6446aa5
Files changed (1) hide show
  1. app.py +4 -5
app.py CHANGED
@@ -19,21 +19,20 @@ if hf_token:
19
  else:
20
  print("⚠️ Hugging Face API token is missing! Set HF_TOKEN in Space secrets.")
21
 
22
- # ✅ Sound generation tool with explicitly formatted docstring
23
  @tool
24
  def generate_sound(sound_type: str, duration: int) -> str:
25
  """
26
  Generates a simple sound based on the specified type and duration.
27
 
28
  Arguments:
29
- sound_type (str): The type of sound to generate (e.g., 'rain', 'white_noise').
30
- duration (int): The duration of the sound in seconds.
31
 
32
  Returns:
33
  str: Path to the generated sound file (e.g., '/home/user/app/rain_3s.wav').
34
  """
35
  try:
36
- # Convert duration to milliseconds
37
  duration_ms = duration * 1000
38
  output_path = f"/home/user/app/{sound_type}_{duration}s.wav"
39
 
@@ -42,7 +41,6 @@ def generate_sound(sound_type: str, duration: int) -> str:
42
  else:
43
  return f"Unsupported sound type: {sound_type}"
44
 
45
- # Export sound to the specified file path
46
  sound.export(output_path, format="wav")
47
  return output_path # ✅ Returns a valid file path for Gradio
48
 
@@ -50,6 +48,7 @@ def generate_sound(sound_type: str, duration: int) -> str:
50
  return f"Error generating sound: {str(e)}"
51
 
52
 
 
53
  # ✅ Time zone tool
54
  @tool
55
  def get_current_time_in_timezone(timezone: str) -> str:
 
19
  else:
20
  print("⚠️ Hugging Face API token is missing! Set HF_TOKEN in Space secrets.")
21
 
22
+ # ✅ Sound generation tool with explicitly formatted docstring for smolagents
23
  @tool
24
  def generate_sound(sound_type: str, duration: int) -> str:
25
  """
26
  Generates a simple sound based on the specified type and duration.
27
 
28
  Arguments:
29
+ sound_type (str): The type of sound to generate, valid options are 'rain', 'white_noise'.
30
+ duration (int): The duration of the sound in seconds. Must be an integer value.
31
 
32
  Returns:
33
  str: Path to the generated sound file (e.g., '/home/user/app/rain_3s.wav').
34
  """
35
  try:
 
36
  duration_ms = duration * 1000
37
  output_path = f"/home/user/app/{sound_type}_{duration}s.wav"
38
 
 
41
  else:
42
  return f"Unsupported sound type: {sound_type}"
43
 
 
44
  sound.export(output_path, format="wav")
45
  return output_path # ✅ Returns a valid file path for Gradio
46
 
 
48
  return f"Error generating sound: {str(e)}"
49
 
50
 
51
+
52
  # ✅ Time zone tool
53
  @tool
54
  def get_current_time_in_timezone(timezone: str) -> str: