Spaces:
Paused
Paused
Upload app.py with huggingface_hub
Browse files
app.py
CHANGED
|
@@ -54,11 +54,18 @@ def generate(req: GenerateRequest):
|
|
| 54 |
with tempfile.NamedTemporaryFile(suffix=".wav", delete=False) as f:
|
| 55 |
tmp_path = f.name
|
| 56 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 57 |
start = time.time()
|
| 58 |
result = dia.generate(
|
| 59 |
req.text,
|
| 60 |
config=config,
|
| 61 |
output_wav=tmp_path,
|
|
|
|
| 62 |
verbose=True,
|
| 63 |
)
|
| 64 |
elapsed = time.time() - start
|
|
|
|
| 54 |
with tempfile.NamedTemporaryFile(suffix=".wav", delete=False) as f:
|
| 55 |
tmp_path = f.name
|
| 56 |
|
| 57 |
+
# Use voice reference if it exists
|
| 58 |
+
voice_ref = Path("/app/voice-reference.wav")
|
| 59 |
+
audio_prompt = str(voice_ref) if voice_ref.exists() else None
|
| 60 |
+
if audio_prompt:
|
| 61 |
+
print(f"[dia2] Using voice clone from {audio_prompt}", flush=True)
|
| 62 |
+
|
| 63 |
start = time.time()
|
| 64 |
result = dia.generate(
|
| 65 |
req.text,
|
| 66 |
config=config,
|
| 67 |
output_wav=tmp_path,
|
| 68 |
+
audio_prompt=audio_prompt,
|
| 69 |
verbose=True,
|
| 70 |
)
|
| 71 |
elapsed = time.time() - start
|