Update app.py
Browse files
app.py
CHANGED
|
@@ -210,29 +210,7 @@ if __name__ == "__main__":
|
|
| 210 |
symbol_input.change(to_symbol_fn,
|
| 211 |
[symbol_input, textbox, temp_text_var],
|
| 212 |
[textbox, temp_text_var])
|
| 213 |
-
symbol_list.click(None, [symbol_list, symbol_list_json], textbox,
|
| 214 |
-
_js=f"""
|
| 215 |
-
(i, symbols, text) => {{
|
| 216 |
-
let root = document.querySelector("body > gradio-app");
|
| 217 |
-
if (root.shadowRoot != null)
|
| 218 |
-
root = root.shadowRoot;
|
| 219 |
-
let text_input = root.querySelector("#tts-input").querySelector("textarea");
|
| 220 |
-
let startPos = text_input.selectionStart;
|
| 221 |
-
let endPos = text_input.selectionEnd;
|
| 222 |
-
let oldTxt = text_input.value;
|
| 223 |
-
let result = oldTxt.substring(0, startPos) + symbols[i] + oldTxt.substring(endPos);
|
| 224 |
-
text_input.value = result;
|
| 225 |
-
let x = window.scrollX, y = window.scrollY;
|
| 226 |
-
text_input.focus();
|
| 227 |
-
text_input.selectionStart = startPos + symbols[i].length;
|
| 228 |
-
text_input.selectionEnd = startPos + symbols[i].length;
|
| 229 |
-
text_input.blur();
|
| 230 |
-
window.scrollTo(x, y);
|
| 231 |
-
|
| 232 |
-
text = text_input.value;
|
| 233 |
-
|
| 234 |
-
return text;
|
| 235 |
-
}}""")
|
| 236 |
# select character
|
| 237 |
char_dropdown = gr.Dropdown(choices=speakers, value=speakers[0], label='character')
|
| 238 |
language_dropdown = gr.Dropdown(choices=lang, value=lang[0], label='language')
|
|
|
|
| 210 |
symbol_input.change(to_symbol_fn,
|
| 211 |
[symbol_input, textbox, temp_text_var],
|
| 212 |
[textbox, temp_text_var])
|
| 213 |
+
symbol_list.click(None, [symbol_list, symbol_list_json], textbox,)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 214 |
# select character
|
| 215 |
char_dropdown = gr.Dropdown(choices=speakers, value=speakers[0], label='character')
|
| 216 |
language_dropdown = gr.Dropdown(choices=lang, value=lang[0], label='language')
|