added error logs and changes some emojies
Browse files
app.py
CHANGED
|
@@ -74,7 +74,7 @@ def get_random_sentence(language):
|
|
| 74 |
|
| 75 |
|
| 76 |
def toggle_generate_button_state(choice, text_input, recording_data=None):
|
| 77 |
-
if choice == "
|
| 78 |
return (
|
| 79 |
gr.update(interactive=True),
|
| 80 |
gr.update(
|
|
@@ -85,7 +85,7 @@ def toggle_generate_button_state(choice, text_input, recording_data=None):
|
|
| 85 |
gr.update(visible=False, value=None),
|
| 86 |
)
|
| 87 |
|
| 88 |
-
elif choice == "
|
| 89 |
if recording_data is None:
|
| 90 |
return (
|
| 91 |
gr.update(interactive=False),
|
|
@@ -382,6 +382,17 @@ def handle_input_pronunc_pair(key,value,pronunc_dict):
|
|
| 382 |
gr.Error("Tried to set key value pair in pronunciation dict with empty value please check input")
|
| 383 |
|
| 384 |
def process_voice_clone(filepath, user_id):
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 385 |
try:
|
| 386 |
url = parameters.voice_clone_URL
|
| 387 |
payload = {"user_id": user_id}
|
|
@@ -396,14 +407,14 @@ def process_voice_clone(filepath, user_id):
|
|
| 396 |
response = response.json()
|
| 397 |
response = response["voice_id"]
|
| 398 |
return response
|
|
|
|
|
|
|
| 399 |
else:
|
| 400 |
response = response.json()
|
| 401 |
-
|
| 402 |
-
return ["Jyoti"]
|
| 403 |
except Exception as e:
|
| 404 |
print(f"An Error occurred: {e}")
|
| 405 |
-
|
| 406 |
-
return ["Jyoti"]
|
| 407 |
|
| 408 |
def tts_inference(
|
| 409 |
session_id: str,
|
|
@@ -428,10 +439,14 @@ def tts_inference(
|
|
| 428 |
clone_voice_name = process_voice_clone(recording_data, user_id)
|
| 429 |
if clone_voice_name is not None:
|
| 430 |
voice_name = str(clone_voice_name)
|
|
|
|
|
|
|
|
|
|
|
|
|
| 431 |
else:
|
| 432 |
voice_name = [agents[agent]]
|
| 433 |
|
| 434 |
-
print("
|
| 435 |
print("speechReqId", session_id)
|
| 436 |
print("text", [text])
|
| 437 |
print("language", [language_codes[language]])
|
|
@@ -443,7 +458,7 @@ def tts_inference(
|
|
| 443 |
print("speech_rate", speech_rate)
|
| 444 |
print("loudness", loudness)
|
| 445 |
print("refine_grneration", refine_generation)
|
| 446 |
-
print("\n")
|
| 447 |
|
| 448 |
try:
|
| 449 |
if not text or text.strip() == "":
|
|
@@ -549,7 +564,7 @@ def tts_inference(
|
|
| 549 |
code=response.status_code,
|
| 550 |
session_id=session_id,
|
| 551 |
language=language,
|
| 552 |
-
input_method="Select Voice" if agent else "
|
| 553 |
agent_used=voice_name,
|
| 554 |
voice_path=saved_path,
|
| 555 |
text_input=text,
|
|
@@ -620,10 +635,10 @@ def tts_tab():
|
|
| 620 |
π **Select Language**
|
| 621 |
* Choose from our listed languages
|
| 622 |
|
| 623 |
-
|
| 624 |
* Select from the curated collection of high-quality voices
|
| 625 |
* Each voice is optimized for natural speech patterns
|
| 626 |
-
* You can give your
|
| 627 |
|
| 628 |
βοΈ **Enter Your Text**
|
| 629 |
* Type or paste your text in the input box
|
|
@@ -644,7 +659,7 @@ def tts_tab():
|
|
| 644 |
* Your feedback helps improve our system
|
| 645 |
|
| 646 |
πΎ **Access Your Audio**
|
| 647 |
-
* Download generated audio for offline use
|
| 648 |
""")
|
| 649 |
|
| 650 |
# Language and Voice Selection
|
|
@@ -678,16 +693,16 @@ def tts_tab():
|
|
| 678 |
)
|
| 679 |
|
| 680 |
input_toggle = gr.Radio(
|
| 681 |
-
choices=["
|
| 682 |
-
value="
|
| 683 |
-
label="
|
| 684 |
interactive=True,
|
| 685 |
visible=True,
|
| 686 |
)
|
| 687 |
|
| 688 |
with gr.Row():
|
| 689 |
agent_dropdown = gr.Dropdown(
|
| 690 |
-
label="
|
| 691 |
choices=list(agents.keys()),
|
| 692 |
value=list(agents.keys())[0],
|
| 693 |
interactive=True,
|
|
@@ -852,13 +867,13 @@ def tts_tab():
|
|
| 852 |
gr.HTML("""
|
| 853 |
<div class="voice-param-heading">π‘ Pro Tips</div>
|
| 854 |
<ul style="margin-top: 5px; padding-left: 15px; font-size: 1em;">
|
| 855 |
-
<li>For minimal hallucination use default low values</li>
|
| 856 |
<li>Start with defaults and adjust gradually</li>
|
| 857 |
<li>Test different combinations for specific use cases</li>
|
| 858 |
<li>Higher values may increase processing time</li>
|
| 859 |
<li>Monitor quality vs performance trade-offs</li>
|
| 860 |
-
<li>Add your pronunciation of any
|
| 861 |
-
<li>If you don't like the
|
| 862 |
<li><b style = "color:red">Note:-</b>Pronunciation pairs are <i style="color:red">case sensitive</i></li>
|
| 863 |
</ul>
|
| 864 |
""")
|
|
|
|
| 74 |
|
| 75 |
|
| 76 |
def toggle_generate_button_state(choice, text_input, recording_data=None):
|
| 77 |
+
if choice == "Ori voices":
|
| 78 |
return (
|
| 79 |
gr.update(interactive=True),
|
| 80 |
gr.update(
|
|
|
|
| 85 |
gr.update(visible=False, value=None),
|
| 86 |
)
|
| 87 |
|
| 88 |
+
elif choice == "Voice clone":
|
| 89 |
if recording_data is None:
|
| 90 |
return (
|
| 91 |
gr.update(interactive=False),
|
|
|
|
| 382 |
gr.Error("Tried to set key value pair in pronunciation dict with empty value please check input")
|
| 383 |
|
| 384 |
def process_voice_clone(filepath, user_id):
|
| 385 |
+
"""
|
| 386 |
+
Make the clone of given audio
|
| 387 |
+
|
| 388 |
+
Parameters:
|
| 389 |
+
-filepath(str): The given audio path
|
| 390 |
+
-user_id(str): User id
|
| 391 |
+
|
| 392 |
+
Returns:
|
| 393 |
+
-voice name(str):The voice name of the cloned voice
|
| 394 |
+
|
| 395 |
+
"""
|
| 396 |
try:
|
| 397 |
url = parameters.voice_clone_URL
|
| 398 |
payload = {"user_id": user_id}
|
|
|
|
| 407 |
response = response.json()
|
| 408 |
response = response["voice_id"]
|
| 409 |
return response
|
| 410 |
+
elif response.status_code==422:
|
| 411 |
+
print(response.text)
|
| 412 |
else:
|
| 413 |
response = response.json()
|
| 414 |
+
return None
|
|
|
|
| 415 |
except Exception as e:
|
| 416 |
print(f"An Error occurred: {e}")
|
| 417 |
+
return None
|
|
|
|
| 418 |
|
| 419 |
def tts_inference(
|
| 420 |
session_id: str,
|
|
|
|
| 439 |
clone_voice_name = process_voice_clone(recording_data, user_id)
|
| 440 |
if clone_voice_name is not None:
|
| 441 |
voice_name = str(clone_voice_name)
|
| 442 |
+
print(f"The voice name, get from voice clone API:::--{voice_name}")
|
| 443 |
+
else:
|
| 444 |
+
gr.Error("Sorry, we are facing some issues with cloning this voice.\nPlease reload the app and try again.")
|
| 445 |
+
print("Did not get any voice name from voice clone api:------")
|
| 446 |
else:
|
| 447 |
voice_name = [agents[agent]]
|
| 448 |
|
| 449 |
+
print("\nParameters Recieved:\n")
|
| 450 |
print("speechReqId", session_id)
|
| 451 |
print("text", [text])
|
| 452 |
print("language", [language_codes[language]])
|
|
|
|
| 458 |
print("speech_rate", speech_rate)
|
| 459 |
print("loudness", loudness)
|
| 460 |
print("refine_grneration", refine_generation)
|
| 461 |
+
print("\n\n")
|
| 462 |
|
| 463 |
try:
|
| 464 |
if not text or text.strip() == "":
|
|
|
|
| 564 |
code=response.status_code,
|
| 565 |
session_id=session_id,
|
| 566 |
language=language,
|
| 567 |
+
input_method="Select Voice" if agent else "Voice clone",
|
| 568 |
agent_used=voice_name,
|
| 569 |
voice_path=saved_path,
|
| 570 |
text_input=text,
|
|
|
|
| 635 |
π **Select Language**
|
| 636 |
* Choose from our listed languages
|
| 637 |
|
| 638 |
+
π€ **Choose Voice**
|
| 639 |
* Select from the curated collection of high-quality voices
|
| 640 |
* Each voice is optimized for natural speech patterns
|
| 641 |
+
* You can give your own voice by clicking on Voice clone
|
| 642 |
|
| 643 |
βοΈ **Enter Your Text**
|
| 644 |
* Type or paste your text in the input box
|
|
|
|
| 659 |
* Your feedback helps improve our system
|
| 660 |
|
| 661 |
πΎ **Access Your Audio**
|
| 662 |
+
* Download the generated audio for offline use
|
| 663 |
""")
|
| 664 |
|
| 665 |
# Language and Voice Selection
|
|
|
|
| 693 |
)
|
| 694 |
|
| 695 |
input_toggle = gr.Radio(
|
| 696 |
+
choices=["Ori voices", "Voice clone"],
|
| 697 |
+
value="Ori voices",
|
| 698 |
+
label="π€ Choose Input Method",
|
| 699 |
interactive=True,
|
| 700 |
visible=True,
|
| 701 |
)
|
| 702 |
|
| 703 |
with gr.Row():
|
| 704 |
agent_dropdown = gr.Dropdown(
|
| 705 |
+
label="π£οΈ Select Voice",
|
| 706 |
choices=list(agents.keys()),
|
| 707 |
value=list(agents.keys())[0],
|
| 708 |
interactive=True,
|
|
|
|
| 867 |
gr.HTML("""
|
| 868 |
<div class="voice-param-heading">π‘ Pro Tips</div>
|
| 869 |
<ul style="margin-top: 5px; padding-left: 15px; font-size: 1em;">
|
| 870 |
+
<li>For minimal hallucination, use default low values</li>
|
| 871 |
<li>Start with defaults and adjust gradually</li>
|
| 872 |
<li>Test different combinations for specific use cases</li>
|
| 873 |
<li>Higher values may increase processing time</li>
|
| 874 |
<li>Monitor quality vs performance trade-offs</li>
|
| 875 |
+
<li>Add your pronunciation of any word that doesn't sound well</li>
|
| 876 |
+
<li>If you don't like the pronunciation of any word, then add your word with the key and value pair</li>
|
| 877 |
<li><b style = "color:red">Note:-</b>Pronunciation pairs are <i style="color:red">case sensitive</i></li>
|
| 878 |
</ul>
|
| 879 |
""")
|