Spaces:
Sleeping
Sleeping
Rasmus Lellep
commited on
Commit
·
4af9842
1
Parent(s):
03381f4
remove language auto-detect
Browse files
app.py
CHANGED
|
@@ -98,7 +98,6 @@ def predict(
|
|
| 98 |
language,
|
| 99 |
speaker_wav,
|
| 100 |
voice_cleanup,
|
| 101 |
-
no_lang_auto_detect,
|
| 102 |
agree,
|
| 103 |
):
|
| 104 |
if agree == True:
|
|
@@ -125,25 +124,6 @@ def predict(
|
|
| 125 |
|
| 126 |
print(f"Detected language:{language_predicted}, Chosen language:{language}")
|
| 127 |
|
| 128 |
-
# After text character length 15 trigger language detection
|
| 129 |
-
if len(prompt) > 15:
|
| 130 |
-
# allow any language for short text as some may be common
|
| 131 |
-
# If user unchecks language autodetection it will not trigger
|
| 132 |
-
# You may remove this completely for own use
|
| 133 |
-
if language_predicted != language and not no_lang_auto_detect:
|
| 134 |
-
# Please duplicate and remove this check if you really want this
|
| 135 |
-
# Or auto-detector fails to identify language (which it can on pretty short text or mixed text)
|
| 136 |
-
gr.Warning(
|
| 137 |
-
f"It looks like your text isn’t the language you chose , if you’re sure the text is the same language you chose, please check disable language auto-detection checkbox"
|
| 138 |
-
)
|
| 139 |
-
|
| 140 |
-
return (
|
| 141 |
-
None,
|
| 142 |
-
None,
|
| 143 |
-
None,
|
| 144 |
-
None,
|
| 145 |
-
)
|
| 146 |
-
|
| 147 |
# Filtering for microphone input, as it has BG noise, maybe silence in beginning and end
|
| 148 |
# This is fast filtering not perfect
|
| 149 |
|
|
@@ -337,7 +317,6 @@ def predict(
|
|
| 337 |
language,
|
| 338 |
speaker_wav,
|
| 339 |
voice_cleanup,
|
| 340 |
-
no_lang_auto_detect,
|
| 341 |
agree,
|
| 342 |
]
|
| 343 |
error_data = [str(e) if type(e) != str else e for e in error_data]
|
|
@@ -710,11 +689,6 @@ with gr.Blocks(analytics_enabled=False) as demo:
|
|
| 710 |
value=False,
|
| 711 |
info="This check can improve output if your microphone or reference voice is noisy",
|
| 712 |
)
|
| 713 |
-
auto_det_lang_gr = gr.Checkbox(
|
| 714 |
-
label="Do not use language auto-detect",
|
| 715 |
-
value=False,
|
| 716 |
-
info="Check to disable language auto-detection",
|
| 717 |
-
)
|
| 718 |
tos_gr = gr.Checkbox(
|
| 719 |
label="Agree",
|
| 720 |
value=False,
|
|
@@ -732,12 +706,12 @@ with gr.Blocks(analytics_enabled=False) as demo:
|
|
| 732 |
with gr.Row():
|
| 733 |
gr.Examples(examples,
|
| 734 |
label="Examples",
|
| 735 |
-
inputs=[input_text_gr, language_gr, ref_gr, clean_ref_gr,
|
| 736 |
outputs=[audio_gr, out_text_gr, ref_audio_gr],
|
| 737 |
fn=predict,
|
| 738 |
cache_examples=False,)
|
| 739 |
|
| 740 |
-
tts_button.click(predict, [input_text_gr, language_gr, ref_gr, clean_ref_gr,
|
| 741 |
|
| 742 |
if __name__ == "__main__":
|
| 743 |
demo.queue()
|
|
|
|
| 98 |
language,
|
| 99 |
speaker_wav,
|
| 100 |
voice_cleanup,
|
|
|
|
| 101 |
agree,
|
| 102 |
):
|
| 103 |
if agree == True:
|
|
|
|
| 124 |
|
| 125 |
print(f"Detected language:{language_predicted}, Chosen language:{language}")
|
| 126 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 127 |
# Filtering for microphone input, as it has BG noise, maybe silence in beginning and end
|
| 128 |
# This is fast filtering not perfect
|
| 129 |
|
|
|
|
| 317 |
language,
|
| 318 |
speaker_wav,
|
| 319 |
voice_cleanup,
|
|
|
|
| 320 |
agree,
|
| 321 |
]
|
| 322 |
error_data = [str(e) if type(e) != str else e for e in error_data]
|
|
|
|
| 689 |
value=False,
|
| 690 |
info="This check can improve output if your microphone or reference voice is noisy",
|
| 691 |
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 692 |
tos_gr = gr.Checkbox(
|
| 693 |
label="Agree",
|
| 694 |
value=False,
|
|
|
|
| 706 |
with gr.Row():
|
| 707 |
gr.Examples(examples,
|
| 708 |
label="Examples",
|
| 709 |
+
inputs=[input_text_gr, language_gr, ref_gr, clean_ref_gr, tos_gr],
|
| 710 |
outputs=[audio_gr, out_text_gr, ref_audio_gr],
|
| 711 |
fn=predict,
|
| 712 |
cache_examples=False,)
|
| 713 |
|
| 714 |
+
tts_button.click(predict, [input_text_gr, language_gr, ref_gr, clean_ref_gr, tos_gr], outputs=[audio_gr, out_text_gr, ref_audio_gr])
|
| 715 |
|
| 716 |
if __name__ == "__main__":
|
| 717 |
demo.queue()
|