lchumaceiro commited on
Commit
a73def9
·
verified ·
1 Parent(s): 86096d8
Files changed (1) hide show
  1. app.py +12 -3
app.py CHANGED
@@ -19,10 +19,19 @@ if hf_token:
19
  else:
20
  print("⚠️ Hugging Face API token is missing! Set HF_TOKEN in Space secrets.")
21
 
22
- # ✅ Sound generation tool
23
  @tool
24
  def generate_sound(sound_type: str, duration: int) -> str:
25
- """Generates a simple sound file and returns its path for download."""
 
 
 
 
 
 
 
 
 
26
  try:
27
  duration_ms = duration * 1000
28
  output_path = f"/home/user/app/{sound_type}_{duration}s.wav"
@@ -33,7 +42,7 @@ def generate_sound(sound_type: str, duration: int) -> str:
33
  return f"Unsupported sound type: {sound_type}"
34
 
35
  sound.export(output_path, format="wav")
36
- return output_path # ✅ Returns a file path for Gradio to display/download
37
 
38
  except Exception as e:
39
  return f"Error generating sound: {str(e)}"
 
19
  else:
20
  print("⚠️ Hugging Face API token is missing! Set HF_TOKEN in Space secrets.")
21
 
22
+ # ✅ Sound generation tool with properly formatted docstring
23
  @tool
24
  def generate_sound(sound_type: str, duration: int) -> str:
25
+ """
26
+ Generates a simple sound file and returns its file path.
27
+
28
+ Args:
29
+ sound_type (str): The type of sound to generate (e.g., 'rain', 'white_noise').
30
+ duration (int): The duration of the generated sound in seconds.
31
+
32
+ Returns:
33
+ str: The file path of the generated sound file.
34
+ """
35
  try:
36
  duration_ms = duration * 1000
37
  output_path = f"/home/user/app/{sound_type}_{duration}s.wav"
 
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
 
47
  except Exception as e:
48
  return f"Error generating sound: {str(e)}"