add rlhf
Browse files
app.py
CHANGED
|
@@ -164,17 +164,17 @@ def generate_audio_gradio(
|
|
| 164 |
|
| 165 |
audio = fade_out(audio, seq_cfg.sampling_rate)
|
| 166 |
|
| 167 |
-
|
| 168 |
-
|
| 169 |
-
|
| 170 |
-
|
| 171 |
-
|
| 172 |
-
|
| 173 |
-
|
| 174 |
-
|
| 175 |
-
|
| 176 |
-
|
| 177 |
-
|
| 178 |
if device == "cuda":
|
| 179 |
torch.cuda.empty_cache()
|
| 180 |
|
|
|
|
| 164 |
|
| 165 |
audio = fade_out(audio, seq_cfg.sampling_rate)
|
| 166 |
|
| 167 |
+
safe_prompt = (
|
| 168 |
+
"".join(c for c in prompt if c.isalnum() or c in (" ", "_"))
|
| 169 |
+
.rstrip()
|
| 170 |
+
.replace(" ", "_")[:50]
|
| 171 |
+
)
|
| 172 |
+
current_time_string = datetime.now().strftime("%Y%m%d_%H%M%S_%f")
|
| 173 |
+
filename = f"{safe_prompt}_{current_time_string}_{i}.flac"
|
| 174 |
+
save_path = OUTPUT_DIR / filename
|
| 175 |
+
torchaudio.save(str(save_path), audio, seq_cfg.sampling_rate)
|
| 176 |
+
log.info(f"Audio saved to {save_path}")
|
| 177 |
+
save_paths.append(str(save_path))
|
| 178 |
if device == "cuda":
|
| 179 |
torch.cuda.empty_cache()
|
| 180 |
|