Spaces:
Running
Running
Update app.py
Browse files127 unmodified lines12812913013113213313413585 unmodified lines2212222232242252262277 unmodified lines23523623723823924024124224324424524624724824925025125225325425525625725825926026126226378 unmodified lines34234334434534634734812 unmodified lines361362363364365366367368369127 unmodified lineselif tag in['replace', 'insert']:html_parts.append(f'<span style="background-color: #ffe066; font-weight: bold; padding: 2px; border-radius: 3px; color: #000;">{chunk}</span>')# โ CSS์์ ์ฒ๋ฆฌํ๋ฏ๋ก HTML ํ๊ทธ ๋ด์ padding ๋ฑ์ ์ ๊ฑฐํ๊ณ id๋ง ๋จ๊น๋๋ค. โhtml_output = f'''<div id="prompter_output_div" style="font-size:{font_size}px;">{"".join(html_parts)}</div>85 unmodified linesexcept Exception as e:return f"โ JSON ํ์ฑ ์๋ฌ: {e}"# โ ์์ชฝ ์ฐฝ์ ๋ด๋ถ ์ฌ๋ฐฑ(padding), ์ค๊ฐ๊ฒฉ(line-height), ํฐํธ ์ฒ๋ฆฌ ๋ฐฉ์์ ํฝ์ ๋จ์๋ก ๋๊ฐ์ด ๋ง์ถ๋ ๋ง๋ฒ์ CSS โcustom_css = """/* ์ผ์ชฝ ์๋ณธ ํ ์คํธ ์ฐฝ */#input_text_area textarea {7 unmodified linesword-break: break-word !important;}/* ์ค๋ฅธ์ชฝ ํ๋กฌํํฐ ๋ทฐ ์ฐฝ */#prompter_output_div {height: 500px !important;max-height: 500px !important;overflow-y: auto !important;padding: 16px !important;line-height: 1.8 !important;box-sizing: border-box !important;background-color: #333 !important;color: #fff !important;border: 1px solid #ddd !important;border-radius: 8px !important;font-family: inherit !important; /* ์ผ์ชฝ ์ฐฝ๊ณผ ๊ธ๊ผด ์๋ฒฝ ๋์ผํ */white-space: pre-wrap !important; /* ์ค๋ฐ๊ฟ ๊ท์น ๋์ผํ */word-break: break-word !important;}/* ์ค๋ฅธ์ชฝ ๋ผ๋ฒจ ๊ฐ์ ๋์ด ๋ง์ถค (์ผ์ชฝ ๋ผ๋ฒจ๊ณผ ๊ณต๊ฐ ์ผ์น) */#prompter_label_space {font-size: var(--input-text-size);color: var(--body-text-color-subdued);margin-bottom: 8px;display: block;}"""78 unmodified linesgr.Markdown("## ๐๏ธ ๋๋ง์ TTS ์ ์ฒ๋ฆฌ ๋ณํ๊ธฐ (ํ๋กฌํํฐ ๋ชจ๋)")with gr.Tabs():with gr.Tab("๐๏ธ ๋ฉ์ธ ํ๋ฉด"):with gr.Row():with gr.Column():input_text = gr.Textbox(label="1๏ธโฃ ์๋ณธ ํ ์คํธ ์ ๋ ฅ", elem_id="input_text_area")12 unmodified linesbtn_clr = gr.Button("๐๏ธ ๋๋ณธ ์ด๊ธฐํ", variant="stop")with gr.Column():# โ ๋ณ๊ฒฝ๋ ๋ถ๋ถ: ์ค๋ฅธ์ชฝ ์ฐฝ ์์ ์ผ์ชฝ(1๏ธโฃ ์๋ณธ...)๊ณผ ์๋ฒฝํ ๋๊ฐ์ ๋์ด๋ฅผ ์ฐจ์งํ๋ ๊ฐ์ง ๋ผ๋ฒจ์ ๋ฌ์์ต๋๋ค! โgr.HTML("<div id='prompter_label_space'>๐บ ํ๋กฌํํฐ ๋ทฐ (๋ณ๊ฒฝ์ ํ์ธ)</div>")output_html = gr.HTML()with gr.Accordion("๐ ์์ ํ ์คํธ ๊ฒฐ๊ณผ (๋ณต์ฌ์ฉ) - ํด๋ฆญํด์ ํผ์น๊ธฐ", open=False):output_text = gr.Textbox(lines=8, show_label=False, show_copy_button=True, elem_id="output_text_area")127 unmodified lines12812913013113213313413513685 unmodified lines2222232242252262272287 unmodified lines23623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726878 unmodified lines34734834935035135235312 unmodified lines366367368369370371372373374127 unmodified lineselif tag in['replace', 'insert']:html_parts.append(f'<span style="background-color: #ffe066; font-weight: bold; padding: 2px; border-radius: 3px; color: #000;">{chunk}</span>')# โ ํต์ฌ 1: ๋ผ๋ฒจ(์ ๋ชฉ)๊ณผ ๊น๋ง์ฐฝ์ ํ๋์ HTML๋ก ๋ฌถ์ด์ ๊ฐ๊ฒฉ(Gap)์ ์๋ฒฝํ ์์ด์ต๋๋ค. โhtml_output = f'''<div id="prompter_label_space">๐บ ํ๋กฌํํฐ ๋ทฐ (๋ณ๊ฒฝ์ ํ์ธ)</div><div id="prompter_output_div" style="font-size:{font_size}px;">{"".join(html_parts)}</div>85 unmodified linesexcept Exception as e:return f"โ JSON ํ์ฑ ์๋ฌ: {e}"# โ ์์ชฝ ์ฐฝ์ ๋ด๋ถ ์ฌ๋ฐฑ(padding), ์ ๋ ฌ(text-align), ์ค๊ฐ๊ฒฉ(line-height)์ ์๋ฅ์ด์ฒ๋ผ ๋๊ฐ์ด ๋ง์ถ๋ CSS โcustom_css = """/* ์ผ์ชฝ ์๋ณธ ํ ์คํธ ์ฐฝ */#input_text_area textarea {7 unmodified linesword-break: break-word !important;}/* ์ค๋ฅธ์ชฝ ํ๋กฌํํฐ ๋ทฐ ๋ผ๋ฒจ (์ผ์ชฝ ๋ผ๋ฒจ๊ณผ ์ ํํ ์ผ์น) */#prompter_label_space {font-size: 13px !important;color: #6b7280 !important;margin-bottom: 6px !important;display: block !important;text-align: left !important;font-weight: 500 !important;}/* ์ค๋ฅธ์ชฝ ํ๋กฌํํฐ ๋ทฐ ๊น๋ง ์ฐฝ */#prompter_output_div {height: 500px !important;max-height: 500px !important;overflow-y: auto !important;padding: 16px !important; /* ์ผ์ชฝ ์ฐฝ๊ณผ ๋๊ฐ์ ์ฌ๋ฐฑ */line-height: 1.8 !important;box-sizing: border-box !important;background-color: #333 !important;color: #fff !important;border: 1px solid #ddd !important;border-radius: 8px !important;font-family: inherit !important;white-space: pre-wrap !important;word-break: break-word !important;text-align: left !important; /* โ ํต์ฌ 2: ๊ธ์๊ฐ ๊ฐ์ด๋ฐ ์ ๋ ฌ๋์ง ์๊ณ ๋ฌด์กฐ๊ฑด ์ผ์ชฝ๋ถํฐ ์์๋๋๋ก ๊ฐ์ ๊ณ ์ โ */margin-top: 0 !important;}"""78 unmodified linesgr.Markdown("## ๐๏ธ ๋๋ง์ TTS ์ ์ฒ๋ฆฌ ๋ณํ๊ธฐ (ํ๋กฌํํฐ ๋ชจ๋)")with gr.Tabs():with Tab("๐๏ธ ๋ฉ์ธ ํ๋ฉด"):with gr.Row():with gr.Column():input_text = gr.Textbox(label="1๏ธโฃ ์๋ณธ ํ ์คํธ ์ ๋ ฅ", elem_id="input_text_area")12 unmodified linesbtn_clr = gr.Button("๐๏ธ ๋๋ณธ ์ด๊ธฐํ", variant="stop")with gr.Column():# ์ด๊ธฐ ๋น ํ๋ฉด์ ์ํด ๋ผ๋ฒจ๊ณผ ๊น๋ง ์ฐฝ ๋ผ๋๋ฅผ ์์ฑํฉ๋๋ค.initial_html = '<div id="prompter_label_space">๐บ ํ๋กฌํํฐ ๋ทฐ (๋ณ๊ฒฝ์ ํ์ธ)</div><div id="prompter_output_div" style="font-size:22px;"></div>'output_html = gr.HTML(value=initial_html)with gr.Accordion("๐ ์์ ํ ์คํธ ๊ฒฐ๊ณผ (๋ณต์ฌ์ฉ) - ํด๋ฆญํด์ ํผ์น๊ธฐ", open=False):output_text = gr.Textbox(lines=8, show_label=False, show_copy_button=True, elem_id="output_text_area")
app.py+23-18