Spaces:
Running on Zero
Running on Zero
Update app.py
Browse files
app.py
CHANGED
|
@@ -741,17 +741,21 @@ async def register_voice_clone_sample(
|
|
| 741 |
"""
|
| 742 |
try:
|
| 743 |
temp_dir = tempfile.mkdtemp()
|
| 744 |
-
|
|
|
|
| 745 |
with open(sample_path, "wb") as f:
|
| 746 |
content = await file.read()
|
| 747 |
f.write(content)
|
| 748 |
|
|
|
|
|
|
|
| 749 |
return JSONResponse(content={
|
| 750 |
"status": "success",
|
| 751 |
"message": "Voice sample analyzed and cloned successfully!",
|
| 752 |
"profile_name": profile_name,
|
| 753 |
-
"
|
| 754 |
-
"
|
|
|
|
| 755 |
"voice_gender": "cloned"
|
| 756 |
})
|
| 757 |
except Exception as e:
|
|
@@ -762,13 +766,22 @@ async def register_voice_clone_sample(
|
|
| 762 |
async def test_voice_clone_tts(
|
| 763 |
text: str = Form("வணக்கம்! இது உங்கள் சொந்த AI குரல் டப்பிங் மாதிரி."),
|
| 764 |
target_lang: str = Form("ta"),
|
| 765 |
-
pitch: str = Form("+0Hz")
|
|
|
|
| 766 |
):
|
| 767 |
"""
|
| 768 |
Synthesizes a live test audio clip using the cloned voice profile.
|
| 769 |
"""
|
| 770 |
try:
|
| 771 |
temp_dir = tempfile.mkdtemp()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 772 |
out_path = os.path.join(temp_dir, f"clone_test_{target_lang}.mp3")
|
| 773 |
await tts_service.generate_speech_async(
|
| 774 |
text=text,
|
|
|
|
| 741 |
"""
|
| 742 |
try:
|
| 743 |
temp_dir = tempfile.mkdtemp()
|
| 744 |
+
ext = os.path.splitext(file.filename)[1] or ".wav"
|
| 745 |
+
sample_path = os.path.join(temp_dir, f"voice_sample{ext}")
|
| 746 |
with open(sample_path, "wb") as f:
|
| 747 |
content = await file.read()
|
| 748 |
f.write(content)
|
| 749 |
|
| 750 |
+
profile = tts_service.analyze_voice_sample(sample_path, profile_name=profile_name)
|
| 751 |
+
|
| 752 |
return JSONResponse(content={
|
| 753 |
"status": "success",
|
| 754 |
"message": "Voice sample analyzed and cloned successfully!",
|
| 755 |
"profile_name": profile_name,
|
| 756 |
+
"detected_gender": profile.get("detected_gender", "male"),
|
| 757 |
+
"f0_hz": profile.get("f0_hz", 130),
|
| 758 |
+
"pitch_offset": profile.get("pitch_offset", "+0Hz"),
|
| 759 |
"voice_gender": "cloned"
|
| 760 |
})
|
| 761 |
except Exception as e:
|
|
|
|
| 766 |
async def test_voice_clone_tts(
|
| 767 |
text: str = Form("வணக்கம்! இது உங்கள் சொந்த AI குரல் டப்பிங் மாதிரி."),
|
| 768 |
target_lang: str = Form("ta"),
|
| 769 |
+
pitch: str = Form("+0Hz"),
|
| 770 |
+
sample_file: UploadFile = File(None)
|
| 771 |
):
|
| 772 |
"""
|
| 773 |
Synthesizes a live test audio clip using the cloned voice profile.
|
| 774 |
"""
|
| 775 |
try:
|
| 776 |
temp_dir = tempfile.mkdtemp()
|
| 777 |
+
if sample_file:
|
| 778 |
+
sample_ext = os.path.splitext(sample_file.filename)[1] or ".wav"
|
| 779 |
+
sample_path = os.path.join(temp_dir, f"live_sample{sample_ext}")
|
| 780 |
+
with open(sample_path, "wb") as f:
|
| 781 |
+
content = await sample_file.read()
|
| 782 |
+
f.write(content)
|
| 783 |
+
tts_service.analyze_voice_sample(sample_path)
|
| 784 |
+
|
| 785 |
out_path = os.path.join(temp_dir, f"clone_test_{target_lang}.mp3")
|
| 786 |
await tts_service.generate_speech_async(
|
| 787 |
text=text,
|