Spaces:
Running
Running
Curinha
commited on
Commit
·
671b217
1
Parent(s):
451ea25
Refactor sound generation functions to remove user_id parameter and adjust GPU duration
Browse files- sound_generator.py +3 -6
sound_generator.py
CHANGED
|
@@ -16,9 +16,8 @@ music_model = MusicGen.get_pretrained('facebook/musicgen-small')
|
|
| 16 |
sound_model.set_generation_params(duration=5)
|
| 17 |
music_model.set_generation_params(duration=5)
|
| 18 |
|
| 19 |
-
|
| 20 |
@spaces.GPU(duration=20)
|
| 21 |
-
def generate_sound(prompt: str
|
| 22 |
"""
|
| 23 |
Generate sound using Audiocraft based on the given prompt.
|
| 24 |
|
|
@@ -28,7 +27,6 @@ def generate_sound(prompt: str, user_id: str):
|
|
| 28 |
Returns:
|
| 29 |
- str: The path to the saved audio file.
|
| 30 |
"""
|
| 31 |
-
print(f"Generando sonido para prompt: '{prompt}' en dispositivo {device} (usuario: {user_id})")
|
| 32 |
descriptions = [prompt]
|
| 33 |
timestamp = str(time.time()).replace(".", "")
|
| 34 |
wav = sound_model.generate(descriptions) # Generate audio
|
|
@@ -38,8 +36,8 @@ def generate_sound(prompt: str, user_id: str):
|
|
| 38 |
|
| 39 |
return f"{output_path}.wav"
|
| 40 |
|
| 41 |
-
@spaces.GPU(duration=
|
| 42 |
-
def generate_music(prompt: str
|
| 43 |
"""
|
| 44 |
Generate music using Audiocraft based on the given prompt.
|
| 45 |
|
|
@@ -49,7 +47,6 @@ def generate_music(prompt: str, user_id: str):
|
|
| 49 |
Returns:
|
| 50 |
- str: The path to the saved audio file.
|
| 51 |
"""
|
| 52 |
-
print(f"Generando sonido para prompt: '{prompt}' en dispositivo {device} (usuario: {user_id})")
|
| 53 |
descriptions = [prompt]
|
| 54 |
timestamp = str(time.time()).replace(".", "")
|
| 55 |
wav = music_model.generate(descriptions) # Generate music
|
|
|
|
| 16 |
sound_model.set_generation_params(duration=5)
|
| 17 |
music_model.set_generation_params(duration=5)
|
| 18 |
|
|
|
|
| 19 |
@spaces.GPU(duration=20)
|
| 20 |
+
def generate_sound(prompt: str):
|
| 21 |
"""
|
| 22 |
Generate sound using Audiocraft based on the given prompt.
|
| 23 |
|
|
|
|
| 27 |
Returns:
|
| 28 |
- str: The path to the saved audio file.
|
| 29 |
"""
|
|
|
|
| 30 |
descriptions = [prompt]
|
| 31 |
timestamp = str(time.time()).replace(".", "")
|
| 32 |
wav = sound_model.generate(descriptions) # Generate audio
|
|
|
|
| 36 |
|
| 37 |
return f"{output_path}.wav"
|
| 38 |
|
| 39 |
+
@spaces.GPU(duration=15)
|
| 40 |
+
def generate_music(prompt: str):
|
| 41 |
"""
|
| 42 |
Generate music using Audiocraft based on the given prompt.
|
| 43 |
|
|
|
|
| 47 |
Returns:
|
| 48 |
- str: The path to the saved audio file.
|
| 49 |
"""
|
|
|
|
| 50 |
descriptions = [prompt]
|
| 51 |
timestamp = str(time.time()).replace(".", "")
|
| 52 |
wav = music_model.generate(descriptions) # Generate music
|