Update app.py
Browse files
app.py
CHANGED
|
@@ -320,8 +320,9 @@ CRITICAL: Do NOT overthink. Do NOT deliberate over conditions, edge cases, or re
|
|
| 320 |
"""
|
| 321 |
|
| 322 |
# DEBUG: Log prompt text
|
| 323 |
-
|
| 324 |
-
|
|
|
|
| 325 |
|
| 326 |
content = []
|
| 327 |
pil_images = []
|
|
@@ -513,8 +514,9 @@ CRITICAL: Do NOT overthink. Do NOT deliberate over conditions, edge cases, or re
|
|
| 513 |
global_stop_thinking[0] = False
|
| 514 |
|
| 515 |
# DEBUG: Log raw output text
|
| 516 |
-
|
| 517 |
-
|
|
|
|
| 518 |
|
| 519 |
except Exception as e:
|
| 520 |
print(f"Error during Transformers inference: {e}")
|
|
@@ -568,8 +570,9 @@ Korean words:
|
|
| 568 |
"""
|
| 569 |
|
| 570 |
# DEBUG: Log translation prompt text
|
| 571 |
-
|
| 572 |
-
|
|
|
|
| 573 |
|
| 574 |
messages = [
|
| 575 |
{
|
|
@@ -606,8 +609,9 @@ Korean words:
|
|
| 606 |
output_text = processor.batch_decode(generated_ids, skip_special_tokens=True)[0]
|
| 607 |
|
| 608 |
# DEBUG: Log raw translation output text
|
| 609 |
-
|
| 610 |
-
|
|
|
|
| 611 |
|
| 612 |
except Exception as e:
|
| 613 |
print(f"Error during Transformers text inference: {e}")
|
|
@@ -702,8 +706,9 @@ def process_pdf(pdf_file, url_input, audio_file_input, yt_url_input, yt_cookies_
|
|
| 702 |
return
|
| 703 |
|
| 704 |
# Log the transcription
|
| 705 |
-
|
| 706 |
-
|
|
|
|
| 707 |
elif is_audio_upload:
|
| 708 |
progress(0, desc="Transcribing uploaded audio with Cohere ASR...")
|
| 709 |
content_text = transcribe_audio_with_asr(audio_file_input)
|
|
@@ -714,8 +719,9 @@ def process_pdf(pdf_file, url_input, audio_file_input, yt_url_input, yt_cookies_
|
|
| 714 |
yield "<p>Could not transcribe any text from the uploaded audio.</p>", current_source_hash, None, "", "", [], extracted_audio_path
|
| 715 |
return
|
| 716 |
|
| 717 |
-
|
| 718 |
-
|
|
|
|
| 719 |
elif is_url:
|
| 720 |
progress(0, desc="Fetching Website...")
|
| 721 |
content_text, images = extract_website_content(url_input.strip())
|
|
@@ -797,8 +803,9 @@ def process_pdf(pdf_file, url_input, audio_file_input, yt_url_input, yt_cookies_
|
|
| 797 |
)
|
| 798 |
|
| 799 |
# DEBUG: Save audio locally
|
| 800 |
-
|
| 801 |
-
|
|
|
|
| 802 |
|
| 803 |
audio_data_uri = numpy_to_base64_audio(wav, tts.sample_rate)
|
| 804 |
item['audio_uri'] = audio_data_uri
|
|
@@ -1199,8 +1206,9 @@ def process_pdf_force(partial_text, pdf_file, url_input, translit_lang, translit
|
|
| 1199 |
import numpy as np
|
| 1200 |
import soundfile as sf
|
| 1201 |
|
| 1202 |
-
|
| 1203 |
-
|
|
|
|
| 1204 |
item["audio_uri"] = numpy_to_base64_audio(wav, tts.sample_rate)
|
| 1205 |
except Exception as e:
|
| 1206 |
print(f"Failed to generate audio for {korean}: {e}")
|
|
@@ -1692,14 +1700,17 @@ def create_demo():
|
|
| 1692 |
example_audio = get_example_audio()
|
| 1693 |
|
| 1694 |
custom_theme = gr.themes.Soft(
|
| 1695 |
-
primary_hue="
|
| 1696 |
-
secondary_hue="
|
| 1697 |
-
neutral_hue="
|
| 1698 |
-
font=[gr.themes.GoogleFont("Outfit"), "ui-sans-serif", "sans-serif"]
|
| 1699 |
)
|
| 1700 |
|
| 1701 |
css = """
|
| 1702 |
-
/* ββ
|
|
|
|
|
|
|
|
|
|
| 1703 |
@keyframes gradientBG {
|
| 1704 |
0% { background-position: 0% 50%; }
|
| 1705 |
50% { background-position: 100% 50%; }
|
|
@@ -1707,25 +1718,28 @@ def create_demo():
|
|
| 1707 |
}
|
| 1708 |
|
| 1709 |
body, .gradio-container {
|
| 1710 |
-
background: linear-gradient(-45deg, #
|
| 1711 |
background-size: 400% 400% !important;
|
| 1712 |
-
animation: gradientBG
|
| 1713 |
background-attachment: fixed !important;
|
| 1714 |
-
color: #
|
| 1715 |
-
font-family: 'Outfit', sans-serif !important;
|
| 1716 |
-
|
| 1717 |
-
/* Force internal Gradio
|
| 1718 |
--block-label-background-fill: transparent !important;
|
| 1719 |
--block-title-background-fill: transparent !important;
|
| 1720 |
--background-fill-primary: transparent !important;
|
| 1721 |
--background-fill-secondary: transparent !important;
|
| 1722 |
--block-background-fill: transparent !important;
|
| 1723 |
-
--input-background-fill: rgba(0, 0, 0, 0.
|
| 1724 |
-
--input-background-fill-focus: rgba(0, 0, 0, 0.
|
| 1725 |
--panel-background-fill: transparent !important;
|
|
|
|
|
|
|
|
|
|
| 1726 |
}
|
| 1727 |
|
| 1728 |
-
/* ββ AGGRESSIVE BACKGROUND OVERRIDES FOR FIREFOX
|
| 1729 |
.gradio-container .tabitem,
|
| 1730 |
.gradio-container .wrap,
|
| 1731 |
.gradio-container .form,
|
|
@@ -1735,33 +1749,67 @@ def create_demo():
|
|
| 1735 |
.gradio-container textarea,
|
| 1736 |
.gradio-container select,
|
| 1737 |
.gradio-container .dropdown-container,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1738 |
.gradio-container .file-preview,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1739 |
.gradio-container .upload-button,
|
| 1740 |
-
.gradio-container .
|
| 1741 |
-
|
| 1742 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1743 |
backdrop-filter: blur(20px) !important;
|
| 1744 |
-webkit-backdrop-filter: blur(20px) !important;
|
| 1745 |
-
|
| 1746 |
-
|
| 1747 |
-
|
| 1748 |
-
border-radius: 24px !important;
|
| 1749 |
-
border: 1px solid rgba(255, 255, 255, 0.1) !important;
|
| 1750 |
-
box-shadow: 0 15px 35px rgba(0, 0, 0, 0.2), inset 0 0 0 1px rgba(255, 255, 255, 0.05) !important;
|
| 1751 |
}
|
| 1752 |
|
| 1753 |
-
/* ββ
|
| 1754 |
::selection {
|
| 1755 |
-
background: rgba(
|
| 1756 |
color: #ffffff !important;
|
| 1757 |
}
|
| 1758 |
::-moz-selection {
|
| 1759 |
-
background: rgba(
|
| 1760 |
color: #ffffff !important;
|
| 1761 |
}
|
| 1762 |
|
| 1763 |
-
/* ββ GLOBAL BACKGROUND OVERRIDES
|
| 1764 |
-
/* Force label pills to be transparent so white text isn't invisible */
|
| 1765 |
.gradio-container label,
|
| 1766 |
.gradio-container .label-wrap,
|
| 1767 |
.gradio-container .block label,
|
|
@@ -1775,8 +1823,7 @@ def create_demo():
|
|
| 1775 |
box-shadow: none !important;
|
| 1776 |
}
|
| 1777 |
|
| 1778 |
-
/* ββ GLOBAL TEXT
|
| 1779 |
-
/* Force ALL text to be light on dark background */
|
| 1780 |
.gradio-container,
|
| 1781 |
.gradio-container label,
|
| 1782 |
.gradio-container .label-wrap,
|
|
@@ -1797,46 +1844,51 @@ def create_demo():
|
|
| 1797 |
.gradio-container input,
|
| 1798 |
.gradio-container select,
|
| 1799 |
.gradio-container textarea {
|
| 1800 |
-
color: #
|
| 1801 |
}
|
| 1802 |
|
| 1803 |
-
/* ββ
|
| 1804 |
h1 {
|
| 1805 |
text-align: center;
|
| 1806 |
-
background: linear-gradient(
|
| 1807 |
-webkit-background-clip: text;
|
| 1808 |
-webkit-text-fill-color: transparent;
|
| 1809 |
-
font-weight:
|
| 1810 |
-
font-size: 2.
|
| 1811 |
margin-bottom: 0.3em !important;
|
| 1812 |
-
letter-spacing:
|
| 1813 |
line-height: 1.2 !important;
|
|
|
|
| 1814 |
}
|
| 1815 |
|
| 1816 |
-
/* ββ TAB LABELS
|
| 1817 |
.gradio-container .tabs .tab-nav button,
|
| 1818 |
.gradio-container .tabs .tab-nav button span {
|
| 1819 |
-
color: #
|
| 1820 |
font-weight: 600 !important;
|
| 1821 |
font-size: 14px !important;
|
| 1822 |
padding: 10px 16px !important;
|
| 1823 |
background: transparent !important;
|
| 1824 |
border: none !important;
|
| 1825 |
border-bottom: 2px solid transparent !important;
|
| 1826 |
-
transition: all 0.
|
| 1827 |
}
|
| 1828 |
.gradio-container .tabs .tab-nav button.selected,
|
| 1829 |
.gradio-container .tabs .tab-nav button.selected span,
|
| 1830 |
.gradio-container .tabs .tab-nav button[aria-selected="true"],
|
| 1831 |
.gradio-container .tabs .tab-nav button[aria-selected="true"] span {
|
| 1832 |
-
color: #
|
| 1833 |
-
border-bottom-color: #
|
| 1834 |
-
background: rgba(
|
| 1835 |
}
|
| 1836 |
.gradio-container .tabs .tab-nav button:hover,
|
| 1837 |
.gradio-container .tabs .tab-nav button:hover span {
|
| 1838 |
-
color: #
|
| 1839 |
-
background: rgba(
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1840 |
}
|
| 1841 |
|
| 1842 |
/* ββ SLIDER / RANGE LABELS ββ */
|
|
@@ -1844,13 +1896,12 @@ def create_demo():
|
|
| 1844 |
.gradio-container .range-slider,
|
| 1845 |
.gradio-container input[type="number"],
|
| 1846 |
.gradio-container input[type="number"]::-moz-placeholder {
|
| 1847 |
-
color: #
|
| 1848 |
}
|
| 1849 |
-
/* Slider min/max number labels */
|
| 1850 |
.gradio-container .wrap.default span,
|
| 1851 |
.gradio-container .head span,
|
| 1852 |
.gradio-container .range_slider span {
|
| 1853 |
-
color: #
|
| 1854 |
}
|
| 1855 |
|
| 1856 |
/* ββ ACCORDION HEADERS ββ */
|
|
@@ -1858,7 +1909,7 @@ def create_demo():
|
|
| 1858 |
.gradio-container .accordion > .label-wrap,
|
| 1859 |
.gradio-container details > summary,
|
| 1860 |
.gradio-container details > summary span {
|
| 1861 |
-
color: #
|
| 1862 |
font-weight: 600 !important;
|
| 1863 |
}
|
| 1864 |
|
|
@@ -1870,35 +1921,33 @@ def create_demo():
|
|
| 1870 |
.gradio-container .md em,
|
| 1871 |
.gradio-container .md h3,
|
| 1872 |
.gradio-container .md h2 {
|
| 1873 |
-
color: #
|
| 1874 |
}
|
| 1875 |
.gradio-container .md strong {
|
| 1876 |
-
color: #
|
| 1877 |
}
|
| 1878 |
.gradio-container .md a {
|
| 1879 |
-
color: #
|
| 1880 |
}
|
| 1881 |
-
/* Subheading markdown like "### βοΈ Customization Settings" */
|
| 1882 |
.gradio-container .prose h3,
|
| 1883 |
.gradio-container h3 {
|
| 1884 |
-
color: #
|
| 1885 |
font-weight: 700 !important;
|
| 1886 |
font-size: 1.05em !important;
|
| 1887 |
}
|
| 1888 |
|
| 1889 |
-
/* ββ HINT TEXT
|
| 1890 |
.hint-text, .hint-text p, .hint-text * {
|
| 1891 |
-
color: #
|
| 1892 |
font-size: 13px !important;
|
| 1893 |
}
|
| 1894 |
|
| 1895 |
/* ββ FILE UPLOAD ββ */
|
| 1896 |
.gradio-container .file-upload,
|
| 1897 |
-
.gradio-container .upload-button
|
| 1898 |
-
|
| 1899 |
-
|
| 1900 |
-
|
| 1901 |
-
color: #94a3b8 !important;
|
| 1902 |
border-radius: 12px !important;
|
| 1903 |
}
|
| 1904 |
|
|
@@ -1906,116 +1955,115 @@ def create_demo():
|
|
| 1906 |
.gradio-container .dropdown-container,
|
| 1907 |
.gradio-container .secondary-wrap,
|
| 1908 |
.gradio-container ul[role="listbox"] {
|
| 1909 |
-
background: rgba(15,
|
| 1910 |
-
border: 1px solid rgba(
|
| 1911 |
-
color: #
|
| 1912 |
}
|
| 1913 |
.gradio-container ul[role="listbox"] li {
|
| 1914 |
-
color: #
|
| 1915 |
}
|
| 1916 |
.gradio-container ul[role="listbox"] li:hover {
|
| 1917 |
-
background: rgba(
|
| 1918 |
}
|
| 1919 |
|
| 1920 |
-
/* ββ BUTTONS ββ */
|
| 1921 |
button.primary {
|
| 1922 |
-
background: linear-gradient(135deg, #
|
| 1923 |
border: none !important;
|
| 1924 |
-
box-shadow: 0 0 20px rgba(
|
| 1925 |
transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1) !important;
|
| 1926 |
font-weight: 700 !important;
|
| 1927 |
letter-spacing: 1px !important;
|
| 1928 |
text-transform: uppercase;
|
| 1929 |
-
border-radius:
|
| 1930 |
-
color:
|
| 1931 |
}
|
| 1932 |
button.primary:hover {
|
| 1933 |
transform: translateY(-3px) scale(1.02) !important;
|
| 1934 |
-
box-shadow: 0 0 30px rgba(
|
|
|
|
| 1935 |
}
|
| 1936 |
button.secondary {
|
| 1937 |
-
background: rgba(100,
|
| 1938 |
-
border: 1px solid rgba(
|
| 1939 |
-
color: #
|
| 1940 |
-
border-radius:
|
| 1941 |
font-weight: 600 !important;
|
| 1942 |
transition: all 0.25s ease !important;
|
| 1943 |
}
|
| 1944 |
button.secondary:hover {
|
| 1945 |
-
background: rgba(
|
| 1946 |
-
border-color: rgba(
|
| 1947 |
-
color: #
|
| 1948 |
transform: translateY(-2px) !important;
|
| 1949 |
}
|
| 1950 |
button.stop {
|
| 1951 |
-
background: linear-gradient(135deg, #
|
| 1952 |
border: none !important;
|
| 1953 |
-
box-shadow: 0 0 20px rgba(
|
| 1954 |
transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1) !important;
|
| 1955 |
font-weight: 700 !important;
|
| 1956 |
text-transform: uppercase;
|
| 1957 |
letter-spacing: 1px !important;
|
| 1958 |
-
border-radius:
|
| 1959 |
-
color:
|
| 1960 |
}
|
| 1961 |
button.stop:hover {
|
| 1962 |
transform: translateY(-3px) scale(1.02) !important;
|
| 1963 |
-
box-shadow: 0 0 30px rgba(
|
| 1964 |
}
|
| 1965 |
|
| 1966 |
/* ββ INPUTS ββ */
|
| 1967 |
textarea, input[type="text"], input[type="number"], select {
|
| 1968 |
background: rgba(0, 0, 0, 0.3) !important;
|
| 1969 |
-
border: 1px solid rgba(
|
| 1970 |
-
border-radius:
|
| 1971 |
-
color: #
|
| 1972 |
transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1) !important;
|
| 1973 |
}
|
| 1974 |
textarea:focus, input[type="text"]:focus {
|
| 1975 |
-
border-color: #
|
| 1976 |
-
box-shadow: 0 0 15px rgba(
|
| 1977 |
}
|
| 1978 |
-
/* Textbox label */
|
| 1979 |
.gradio-container .textbox label span,
|
| 1980 |
.gradio-container .input-label {
|
| 1981 |
-
color: #
|
| 1982 |
font-weight: 600 !important;
|
| 1983 |
}
|
| 1984 |
|
| 1985 |
/* ββ EXPORT / DOWNLOAD FILE COMPONENT ββ */
|
| 1986 |
.gradio-container .download,
|
| 1987 |
.gradio-container .file a {
|
| 1988 |
-
color: #
|
| 1989 |
}
|
| 1990 |
|
| 1991 |
/* ββ GALLERY ββ */
|
| 1992 |
.gradio-container .gallery-item {
|
| 1993 |
background: rgba(0, 0, 0, 0.3) !important;
|
| 1994 |
-
border: 1px solid rgba(
|
| 1995 |
-
border-radius:
|
| 1996 |
}
|
| 1997 |
|
| 1998 |
-
/* ββ INFO / TOOLTIP
|
| 1999 |
.gradio-container .info,
|
| 2000 |
.gradio-container .wrap .info {
|
| 2001 |
-
color: #
|
| 2002 |
}
|
| 2003 |
|
| 2004 |
-
/* ββ BLOCK BACKGROUNDS
|
| 2005 |
.gradio-container .block {
|
| 2006 |
background: transparent !important;
|
| 2007 |
}
|
| 2008 |
.gradio-container .contain {
|
| 2009 |
background: transparent !important;
|
| 2010 |
}
|
| 2011 |
-
/* Tab panel content area */
|
| 2012 |
.gradio-container .tabitem {
|
| 2013 |
background: transparent !important;
|
| 2014 |
}
|
| 2015 |
|
| 2016 |
/* ββ AUDIO PLAYER ββ */
|
| 2017 |
.gradio-container audio {
|
| 2018 |
-
filter: invert(0.85) hue-rotate(180deg);
|
| 2019 |
border-radius: 8px;
|
| 2020 |
}
|
| 2021 |
|
|
@@ -2027,7 +2075,7 @@ def create_demo():
|
|
| 2027 |
display: none !important;
|
| 2028 |
}
|
| 2029 |
|
| 2030 |
-
/* ββ MAIN PROGRESS BAR
|
| 2031 |
.gradio-container .progress-container,
|
| 2032 |
.gradio-container .progress-text {
|
| 2033 |
color: #ffffff !important;
|
|
@@ -2035,18 +2083,24 @@ def create_demo():
|
|
| 2035 |
text-shadow: 0px 1px 4px rgba(0,0,0,0.9) !important;
|
| 2036 |
}
|
| 2037 |
.gradio-container .progress-level {
|
| 2038 |
-
background: linear-gradient(90deg, #
|
| 2039 |
}
|
| 2040 |
|
| 2041 |
-
/* ββ SCROLLBAR
|
| 2042 |
* {
|
| 2043 |
scrollbar-width: thin;
|
| 2044 |
-
scrollbar-color: rgba(
|
| 2045 |
}
|
| 2046 |
-
::-webkit-scrollbar { width:
|
| 2047 |
::-webkit-scrollbar-track { background: transparent; }
|
| 2048 |
-
::-webkit-scrollbar-thumb { background: rgba(
|
| 2049 |
-
::-webkit-scrollbar-thumb:hover { background: rgba(
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 2050 |
"""
|
| 2051 |
# Force dark mode via JavaScript so Gradio's internal CSS variables default to dark
|
| 2052 |
dark_mode_js = """
|
|
@@ -2401,8 +2455,9 @@ if __name__ == "__main__":
|
|
| 2401 |
wav, dur = tts.synthesize(
|
| 2402 |
text=korean_word,
|
| 2403 |
voice_style=voice_style,
|
| 2404 |
-
|
| 2405 |
-
speed=0.
|
|
|
|
| 2406 |
)
|
| 2407 |
item["audio_uri"] = numpy_to_base64_audio(wav, tts.sample_rate)
|
| 2408 |
except Exception as e:
|
|
|
|
| 320 |
"""
|
| 321 |
|
| 322 |
# DEBUG: Log prompt text
|
| 323 |
+
if not IS_HF:
|
| 324 |
+
with open(os.path.join(LOG_DIR, "debug_vlm_prompt.txt"), "w", encoding="utf-8") as f:
|
| 325 |
+
f.write(prompt_text)
|
| 326 |
|
| 327 |
content = []
|
| 328 |
pil_images = []
|
|
|
|
| 514 |
global_stop_thinking[0] = False
|
| 515 |
|
| 516 |
# DEBUG: Log raw output text
|
| 517 |
+
if not IS_HF:
|
| 518 |
+
with open(os.path.join(LOG_DIR, "debug_vlm_output.txt"), "w", encoding="utf-8") as f:
|
| 519 |
+
f.write(output_text)
|
| 520 |
|
| 521 |
except Exception as e:
|
| 522 |
print(f"Error during Transformers inference: {e}")
|
|
|
|
| 570 |
"""
|
| 571 |
|
| 572 |
# DEBUG: Log translation prompt text
|
| 573 |
+
if not IS_HF:
|
| 574 |
+
with open(os.path.join(LOG_DIR, "debug_translate_prompt.txt"), "w", encoding="utf-8") as f:
|
| 575 |
+
f.write(prompt_text)
|
| 576 |
|
| 577 |
messages = [
|
| 578 |
{
|
|
|
|
| 609 |
output_text = processor.batch_decode(generated_ids, skip_special_tokens=True)[0]
|
| 610 |
|
| 611 |
# DEBUG: Log raw translation output text
|
| 612 |
+
if not IS_HF:
|
| 613 |
+
with open(os.path.join(LOG_DIR, "debug_translate_output.txt"), "w", encoding="utf-8") as f:
|
| 614 |
+
f.write(output_text)
|
| 615 |
|
| 616 |
except Exception as e:
|
| 617 |
print(f"Error during Transformers text inference: {e}")
|
|
|
|
| 706 |
return
|
| 707 |
|
| 708 |
# Log the transcription
|
| 709 |
+
if not IS_HF:
|
| 710 |
+
with open(os.path.join(LOG_DIR, "debug_yt_transcription.txt"), "w", encoding="utf-8") as f:
|
| 711 |
+
f.write(f"Title: {yt_title}\n\n{content_text}")
|
| 712 |
elif is_audio_upload:
|
| 713 |
progress(0, desc="Transcribing uploaded audio with Cohere ASR...")
|
| 714 |
content_text = transcribe_audio_with_asr(audio_file_input)
|
|
|
|
| 719 |
yield "<p>Could not transcribe any text from the uploaded audio.</p>", current_source_hash, None, "", "", [], extracted_audio_path
|
| 720 |
return
|
| 721 |
|
| 722 |
+
if not IS_HF:
|
| 723 |
+
with open(os.path.join(LOG_DIR, "debug_audio_transcription.txt"), "w", encoding="utf-8") as f:
|
| 724 |
+
f.write(content_text)
|
| 725 |
elif is_url:
|
| 726 |
progress(0, desc="Fetching Website...")
|
| 727 |
content_text, images = extract_website_content(url_input.strip())
|
|
|
|
| 803 |
)
|
| 804 |
|
| 805 |
# DEBUG: Save audio locally
|
| 806 |
+
if not IS_HF:
|
| 807 |
+
wav_1d = wav.squeeze()
|
| 808 |
+
sf.write(os.path.join(LOG_DIR, f"debug_audio_{i}.wav"), wav_1d, tts.sample_rate, format='WAV')
|
| 809 |
|
| 810 |
audio_data_uri = numpy_to_base64_audio(wav, tts.sample_rate)
|
| 811 |
item['audio_uri'] = audio_data_uri
|
|
|
|
| 1206 |
import numpy as np
|
| 1207 |
import soundfile as sf
|
| 1208 |
|
| 1209 |
+
if not IS_HF:
|
| 1210 |
+
audio_path = os.path.join(LOG_DIR, f"audio_{i}.wav")
|
| 1211 |
+
sf.write(audio_path, wav, 24000)
|
| 1212 |
item["audio_uri"] = numpy_to_base64_audio(wav, tts.sample_rate)
|
| 1213 |
except Exception as e:
|
| 1214 |
print(f"Failed to generate audio for {korean}: {e}")
|
|
|
|
| 1700 |
example_audio = get_example_audio()
|
| 1701 |
|
| 1702 |
custom_theme = gr.themes.Soft(
|
| 1703 |
+
primary_hue="amber",
|
| 1704 |
+
secondary_hue="stone",
|
| 1705 |
+
neutral_hue="stone",
|
| 1706 |
+
font=[gr.themes.GoogleFont("Outfit"), gr.themes.GoogleFont("Noto Serif KR"), "ui-sans-serif", "sans-serif"]
|
| 1707 |
)
|
| 1708 |
|
| 1709 |
css = """
|
| 1710 |
+
/* ββ νκ΅ (Hanguk) Inspired Theme ββ */
|
| 1711 |
+
@import url('https://fonts.googleapis.com/css2?family=Noto+Serif+KR:wght@400;700;900&family=Outfit:wght@400;600;700;800&display=swap');
|
| 1712 |
+
|
| 1713 |
+
/* ββ Animated Background β ink wash μ묡ν ββ */
|
| 1714 |
@keyframes gradientBG {
|
| 1715 |
0% { background-position: 0% 50%; }
|
| 1716 |
50% { background-position: 100% 50%; }
|
|
|
|
| 1718 |
}
|
| 1719 |
|
| 1720 |
body, .gradio-container {
|
| 1721 |
+
background: linear-gradient(-45deg, #0a0a0f, #1a1008, #0d1a12, #12080a, #0f0f1a) !important;
|
| 1722 |
background-size: 400% 400% !important;
|
| 1723 |
+
animation: gradientBG 20s ease infinite !important;
|
| 1724 |
background-attachment: fixed !important;
|
| 1725 |
+
color: #e8e0d4 !important;
|
| 1726 |
+
font-family: 'Outfit', 'Noto Serif KR', sans-serif !important;
|
| 1727 |
+
|
| 1728 |
+
/* Force internal Gradio variables */
|
| 1729 |
--block-label-background-fill: transparent !important;
|
| 1730 |
--block-title-background-fill: transparent !important;
|
| 1731 |
--background-fill-primary: transparent !important;
|
| 1732 |
--background-fill-secondary: transparent !important;
|
| 1733 |
--block-background-fill: transparent !important;
|
| 1734 |
+
--input-background-fill: rgba(0, 0, 0, 0.25) !important;
|
| 1735 |
+
--input-background-fill-focus: rgba(0, 0, 0, 0.35) !important;
|
| 1736 |
--panel-background-fill: transparent !important;
|
| 1737 |
+
--checkbox-background-color: rgba(0, 0, 0, 0.2) !important;
|
| 1738 |
+
--table-even-background-fill: transparent !important;
|
| 1739 |
+
--table-odd-background-fill: rgba(0, 0, 0, 0.1) !important;
|
| 1740 |
}
|
| 1741 |
|
| 1742 |
+
/* ββ AGGRESSIVE BACKGROUND OVERRIDES FOR FIREFOX ββ */
|
| 1743 |
.gradio-container .tabitem,
|
| 1744 |
.gradio-container .wrap,
|
| 1745 |
.gradio-container .form,
|
|
|
|
| 1749 |
.gradio-container textarea,
|
| 1750 |
.gradio-container select,
|
| 1751 |
.gradio-container .dropdown-container,
|
| 1752 |
+
.gradio-container .block,
|
| 1753 |
+
.gradio-container .secondary-wrap,
|
| 1754 |
+
.gradio-container .contain {
|
| 1755 |
+
background: rgba(15, 12, 8, 0.5) !important;
|
| 1756 |
+
background-color: rgba(15, 12, 8, 0.5) !important;
|
| 1757 |
+
}
|
| 1758 |
+
|
| 1759 |
+
/* ββ FILE UPLOAD / PREVIEW β fix white backgrounds ββ */
|
| 1760 |
.gradio-container .file-preview,
|
| 1761 |
+
.gradio-container .file-preview *,
|
| 1762 |
+
.gradio-container .file-preview table,
|
| 1763 |
+
.gradio-container .file-preview tr,
|
| 1764 |
+
.gradio-container .file-preview td,
|
| 1765 |
+
.gradio-container .file-preview th,
|
| 1766 |
+
.gradio-container .file-preview tbody,
|
| 1767 |
+
.gradio-container .file-preview thead,
|
| 1768 |
.gradio-container .upload-button,
|
| 1769 |
+
.gradio-container .file-upload,
|
| 1770 |
+
.gradio-container [data-testid="file"],
|
| 1771 |
+
.gradio-container [data-testid="file"] *,
|
| 1772 |
+
.gradio-container .file,
|
| 1773 |
+
.gradio-container .file *,
|
| 1774 |
+
.gradio-container .upload-text,
|
| 1775 |
+
.gradio-container .icon-wrap,
|
| 1776 |
+
.gradio-container .waveform-container,
|
| 1777 |
+
.gradio-container .empty,
|
| 1778 |
+
.gradio-container .empty *,
|
| 1779 |
+
.gradio-container .wrap.default {
|
| 1780 |
+
background: rgba(10, 8, 5, 0.4) !important;
|
| 1781 |
+
background-color: rgba(10, 8, 5, 0.4) !important;
|
| 1782 |
+
color: #e8e0d4 !important;
|
| 1783 |
+
border-color: rgba(196, 164, 105, 0.15) !important;
|
| 1784 |
+
}
|
| 1785 |
+
.gradio-container .file-preview a,
|
| 1786 |
+
.gradio-container .file a {
|
| 1787 |
+
color: #c4a469 !important;
|
| 1788 |
+
}
|
| 1789 |
+
|
| 1790 |
+
/* ββ Glassmorphism Panels β hanji paper texture feel ββ */
|
| 1791 |
+
.gradio-container .form,
|
| 1792 |
+
.gradio-container .panel,
|
| 1793 |
+
.gradio-container .box {
|
| 1794 |
+
background: rgba(15, 12, 8, 0.45) !important;
|
| 1795 |
backdrop-filter: blur(20px) !important;
|
| 1796 |
-webkit-backdrop-filter: blur(20px) !important;
|
| 1797 |
+
border-radius: 16px !important;
|
| 1798 |
+
border: 1px solid rgba(196, 164, 105, 0.12) !important;
|
| 1799 |
+
box-shadow: 0 12px 30px rgba(0, 0, 0, 0.3), inset 0 0 0 1px rgba(196, 164, 105, 0.05) !important;
|
|
|
|
|
|
|
|
|
|
| 1800 |
}
|
| 1801 |
|
| 1802 |
+
/* ββ Selection β warm gold ββ */
|
| 1803 |
::selection {
|
| 1804 |
+
background: rgba(196, 164, 105, 0.45) !important;
|
| 1805 |
color: #ffffff !important;
|
| 1806 |
}
|
| 1807 |
::-moz-selection {
|
| 1808 |
+
background: rgba(196, 164, 105, 0.45) !important;
|
| 1809 |
color: #ffffff !important;
|
| 1810 |
}
|
| 1811 |
|
| 1812 |
+
/* ββ GLOBAL BACKGROUND OVERRIDES ββ */
|
|
|
|
| 1813 |
.gradio-container label,
|
| 1814 |
.gradio-container .label-wrap,
|
| 1815 |
.gradio-container .block label,
|
|
|
|
| 1823 |
box-shadow: none !important;
|
| 1824 |
}
|
| 1825 |
|
| 1826 |
+
/* ββ GLOBAL TEXT β warm parchment tones ββ */
|
|
|
|
| 1827 |
.gradio-container,
|
| 1828 |
.gradio-container label,
|
| 1829 |
.gradio-container .label-wrap,
|
|
|
|
| 1844 |
.gradio-container input,
|
| 1845 |
.gradio-container select,
|
| 1846 |
.gradio-container textarea {
|
| 1847 |
+
color: #e8e0d4 !important;
|
| 1848 |
}
|
| 1849 |
|
| 1850 |
+
/* ββ Heading β μμ calligraphy style ββ */
|
| 1851 |
h1 {
|
| 1852 |
text-align: center;
|
| 1853 |
+
background: linear-gradient(135deg, #c4a469, #e8c97a, #a0825a);
|
| 1854 |
-webkit-background-clip: text;
|
| 1855 |
-webkit-text-fill-color: transparent;
|
| 1856 |
+
font-weight: 900 !important;
|
| 1857 |
+
font-size: 2.4em !important;
|
| 1858 |
margin-bottom: 0.3em !important;
|
| 1859 |
+
letter-spacing: 1px;
|
| 1860 |
line-height: 1.2 !important;
|
| 1861 |
+
font-family: 'Noto Serif KR', 'Outfit', serif !important;
|
| 1862 |
}
|
| 1863 |
|
| 1864 |
+
/* ββ TAB LABELS β λ¨μ² style ββ */
|
| 1865 |
.gradio-container .tabs .tab-nav button,
|
| 1866 |
.gradio-container .tabs .tab-nav button span {
|
| 1867 |
+
color: #8a7a65 !important;
|
| 1868 |
font-weight: 600 !important;
|
| 1869 |
font-size: 14px !important;
|
| 1870 |
padding: 10px 16px !important;
|
| 1871 |
background: transparent !important;
|
| 1872 |
border: none !important;
|
| 1873 |
border-bottom: 2px solid transparent !important;
|
| 1874 |
+
transition: all 0.3s ease !important;
|
| 1875 |
}
|
| 1876 |
.gradio-container .tabs .tab-nav button.selected,
|
| 1877 |
.gradio-container .tabs .tab-nav button.selected span,
|
| 1878 |
.gradio-container .tabs .tab-nav button[aria-selected="true"],
|
| 1879 |
.gradio-container .tabs .tab-nav button[aria-selected="true"] span {
|
| 1880 |
+
color: #c4a469 !important;
|
| 1881 |
+
border-bottom-color: #c4a469 !important;
|
| 1882 |
+
background: rgba(196, 164, 105, 0.08) !important;
|
| 1883 |
}
|
| 1884 |
.gradio-container .tabs .tab-nav button:hover,
|
| 1885 |
.gradio-container .tabs .tab-nav button:hover span {
|
| 1886 |
+
color: #e8e0d4 !important;
|
| 1887 |
+
background: rgba(196, 164, 105, 0.05) !important;
|
| 1888 |
+
}
|
| 1889 |
+
.gradio-container .tabs .tab-nav {
|
| 1890 |
+
background: transparent !important;
|
| 1891 |
+
border-bottom: 1px solid rgba(196, 164, 105, 0.15) !important;
|
| 1892 |
}
|
| 1893 |
|
| 1894 |
/* ββ SLIDER / RANGE LABELS ββ */
|
|
|
|
| 1896 |
.gradio-container .range-slider,
|
| 1897 |
.gradio-container input[type="number"],
|
| 1898 |
.gradio-container input[type="number"]::-moz-placeholder {
|
| 1899 |
+
color: #e8e0d4 !important;
|
| 1900 |
}
|
|
|
|
| 1901 |
.gradio-container .wrap.default span,
|
| 1902 |
.gradio-container .head span,
|
| 1903 |
.gradio-container .range_slider span {
|
| 1904 |
+
color: #8a7a65 !important;
|
| 1905 |
}
|
| 1906 |
|
| 1907 |
/* ββ ACCORDION HEADERS ββ */
|
|
|
|
| 1909 |
.gradio-container .accordion > .label-wrap,
|
| 1910 |
.gradio-container details > summary,
|
| 1911 |
.gradio-container details > summary span {
|
| 1912 |
+
color: #e8e0d4 !important;
|
| 1913 |
font-weight: 600 !important;
|
| 1914 |
}
|
| 1915 |
|
|
|
|
| 1921 |
.gradio-container .md em,
|
| 1922 |
.gradio-container .md h3,
|
| 1923 |
.gradio-container .md h2 {
|
| 1924 |
+
color: #d4cbbe !important;
|
| 1925 |
}
|
| 1926 |
.gradio-container .md strong {
|
| 1927 |
+
color: #f0e8da !important;
|
| 1928 |
}
|
| 1929 |
.gradio-container .md a {
|
| 1930 |
+
color: #c4a469 !important;
|
| 1931 |
}
|
|
|
|
| 1932 |
.gradio-container .prose h3,
|
| 1933 |
.gradio-container h3 {
|
| 1934 |
+
color: #c4a469 !important;
|
| 1935 |
font-weight: 700 !important;
|
| 1936 |
font-size: 1.05em !important;
|
| 1937 |
}
|
| 1938 |
|
| 1939 |
+
/* ββ HINT TEXT ββ */
|
| 1940 |
.hint-text, .hint-text p, .hint-text * {
|
| 1941 |
+
color: #6b5e4f !important;
|
| 1942 |
font-size: 13px !important;
|
| 1943 |
}
|
| 1944 |
|
| 1945 |
/* ββ FILE UPLOAD ββ */
|
| 1946 |
.gradio-container .file-upload,
|
| 1947 |
+
.gradio-container .upload-button {
|
| 1948 |
+
background: rgba(0, 0, 0, 0.25) !important;
|
| 1949 |
+
border: 1px dashed rgba(196, 164, 105, 0.2) !important;
|
| 1950 |
+
color: #8a7a65 !important;
|
|
|
|
| 1951 |
border-radius: 12px !important;
|
| 1952 |
}
|
| 1953 |
|
|
|
|
| 1955 |
.gradio-container .dropdown-container,
|
| 1956 |
.gradio-container .secondary-wrap,
|
| 1957 |
.gradio-container ul[role="listbox"] {
|
| 1958 |
+
background: rgba(15, 12, 8, 0.95) !important;
|
| 1959 |
+
border: 1px solid rgba(196, 164, 105, 0.15) !important;
|
| 1960 |
+
color: #e8e0d4 !important;
|
| 1961 |
}
|
| 1962 |
.gradio-container ul[role="listbox"] li {
|
| 1963 |
+
color: #e8e0d4 !important;
|
| 1964 |
}
|
| 1965 |
.gradio-container ul[role="listbox"] li:hover {
|
| 1966 |
+
background: rgba(196, 164, 105, 0.15) !important;
|
| 1967 |
}
|
| 1968 |
|
| 1969 |
+
/* ββ BUTTONS β ν볡 inspired ββ */
|
| 1970 |
button.primary {
|
| 1971 |
+
background: linear-gradient(135deg, #b8860b, #c4a469, #8b6914) !important;
|
| 1972 |
border: none !important;
|
| 1973 |
+
box-shadow: 0 0 20px rgba(196, 164, 105, 0.35) !important;
|
| 1974 |
transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1) !important;
|
| 1975 |
font-weight: 700 !important;
|
| 1976 |
letter-spacing: 1px !important;
|
| 1977 |
text-transform: uppercase;
|
| 1978 |
+
border-radius: 12px !important;
|
| 1979 |
+
color: #0a0a0f !important;
|
| 1980 |
}
|
| 1981 |
button.primary:hover {
|
| 1982 |
transform: translateY(-3px) scale(1.02) !important;
|
| 1983 |
+
box-shadow: 0 0 30px rgba(196, 164, 105, 0.6) !important;
|
| 1984 |
+
color: #0a0a0f !important;
|
| 1985 |
}
|
| 1986 |
button.secondary {
|
| 1987 |
+
background: rgba(100, 90, 70, 0.15) !important;
|
| 1988 |
+
border: 1px solid rgba(196, 164, 105, 0.2) !important;
|
| 1989 |
+
color: #e8e0d4 !important;
|
| 1990 |
+
border-radius: 12px !important;
|
| 1991 |
font-weight: 600 !important;
|
| 1992 |
transition: all 0.25s ease !important;
|
| 1993 |
}
|
| 1994 |
button.secondary:hover {
|
| 1995 |
+
background: rgba(196, 164, 105, 0.12) !important;
|
| 1996 |
+
border-color: rgba(196, 164, 105, 0.35) !important;
|
| 1997 |
+
color: #f0e8da !important;
|
| 1998 |
transform: translateY(-2px) !important;
|
| 1999 |
}
|
| 2000 |
button.stop {
|
| 2001 |
+
background: linear-gradient(135deg, #8b2020, #c0392b) !important;
|
| 2002 |
border: none !important;
|
| 2003 |
+
box-shadow: 0 0 20px rgba(192, 57, 43, 0.4) !important;
|
| 2004 |
transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1) !important;
|
| 2005 |
font-weight: 700 !important;
|
| 2006 |
text-transform: uppercase;
|
| 2007 |
letter-spacing: 1px !important;
|
| 2008 |
+
border-radius: 12px !important;
|
| 2009 |
+
color: #f0e8da !important;
|
| 2010 |
}
|
| 2011 |
button.stop:hover {
|
| 2012 |
transform: translateY(-3px) scale(1.02) !important;
|
| 2013 |
+
box-shadow: 0 0 30px rgba(192, 57, 43, 0.6) !important;
|
| 2014 |
}
|
| 2015 |
|
| 2016 |
/* ββ INPUTS ββ */
|
| 2017 |
textarea, input[type="text"], input[type="number"], select {
|
| 2018 |
background: rgba(0, 0, 0, 0.3) !important;
|
| 2019 |
+
border: 1px solid rgba(196, 164, 105, 0.12) !important;
|
| 2020 |
+
border-radius: 10px !important;
|
| 2021 |
+
color: #f0e8da !important;
|
| 2022 |
transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1) !important;
|
| 2023 |
}
|
| 2024 |
textarea:focus, input[type="text"]:focus {
|
| 2025 |
+
border-color: #c4a469 !important;
|
| 2026 |
+
box-shadow: 0 0 15px rgba(196, 164, 105, 0.25), inset 0 0 0 1px rgba(196, 164, 105, 0.25) !important;
|
| 2027 |
}
|
|
|
|
| 2028 |
.gradio-container .textbox label span,
|
| 2029 |
.gradio-container .input-label {
|
| 2030 |
+
color: #c4a469 !important;
|
| 2031 |
font-weight: 600 !important;
|
| 2032 |
}
|
| 2033 |
|
| 2034 |
/* ββ EXPORT / DOWNLOAD FILE COMPONENT ββ */
|
| 2035 |
.gradio-container .download,
|
| 2036 |
.gradio-container .file a {
|
| 2037 |
+
color: #c4a469 !important;
|
| 2038 |
}
|
| 2039 |
|
| 2040 |
/* ββ GALLERY ββ */
|
| 2041 |
.gradio-container .gallery-item {
|
| 2042 |
background: rgba(0, 0, 0, 0.3) !important;
|
| 2043 |
+
border: 1px solid rgba(196, 164, 105, 0.1) !important;
|
| 2044 |
+
border-radius: 10px !important;
|
| 2045 |
}
|
| 2046 |
|
| 2047 |
+
/* ββ INFO / TOOLTIP ββ */
|
| 2048 |
.gradio-container .info,
|
| 2049 |
.gradio-container .wrap .info {
|
| 2050 |
+
color: #6b5e4f !important;
|
| 2051 |
}
|
| 2052 |
|
| 2053 |
+
/* ββ BLOCK BACKGROUNDS ββ */
|
| 2054 |
.gradio-container .block {
|
| 2055 |
background: transparent !important;
|
| 2056 |
}
|
| 2057 |
.gradio-container .contain {
|
| 2058 |
background: transparent !important;
|
| 2059 |
}
|
|
|
|
| 2060 |
.gradio-container .tabitem {
|
| 2061 |
background: transparent !important;
|
| 2062 |
}
|
| 2063 |
|
| 2064 |
/* ββ AUDIO PLAYER ββ */
|
| 2065 |
.gradio-container audio {
|
| 2066 |
+
filter: invert(0.85) hue-rotate(180deg) sepia(0.15);
|
| 2067 |
border-radius: 8px;
|
| 2068 |
}
|
| 2069 |
|
|
|
|
| 2075 |
display: none !important;
|
| 2076 |
}
|
| 2077 |
|
| 2078 |
+
/* ββ MAIN PROGRESS BAR ββ */
|
| 2079 |
.gradio-container .progress-container,
|
| 2080 |
.gradio-container .progress-text {
|
| 2081 |
color: #ffffff !important;
|
|
|
|
| 2083 |
text-shadow: 0px 1px 4px rgba(0,0,0,0.9) !important;
|
| 2084 |
}
|
| 2085 |
.gradio-container .progress-level {
|
| 2086 |
+
background: linear-gradient(90deg, #b8860b, #c4a469) !important;
|
| 2087 |
}
|
| 2088 |
|
| 2089 |
+
/* ββ SCROLLBAR β ink brush style ββ */
|
| 2090 |
* {
|
| 2091 |
scrollbar-width: thin;
|
| 2092 |
+
scrollbar-color: rgba(196, 164, 105, 0.3) transparent;
|
| 2093 |
}
|
| 2094 |
+
::-webkit-scrollbar { width: 5px; height: 5px; }
|
| 2095 |
::-webkit-scrollbar-track { background: transparent; }
|
| 2096 |
+
::-webkit-scrollbar-thumb { background: rgba(196, 164, 105, 0.3); border-radius: 3px; }
|
| 2097 |
+
::-webkit-scrollbar-thumb:hover { background: rgba(196, 164, 105, 0.5); }
|
| 2098 |
+
|
| 2099 |
+
/* ββ Korean decorative border on main content ββ */
|
| 2100 |
+
.gradio-container > .main {
|
| 2101 |
+
border-top: 3px solid transparent !important;
|
| 2102 |
+
border-image: linear-gradient(90deg, transparent, rgba(196, 164, 105, 0.3), rgba(192, 57, 43, 0.2), rgba(196, 164, 105, 0.3), transparent) 1 !important;
|
| 2103 |
+
}
|
| 2104 |
"""
|
| 2105 |
# Force dark mode via JavaScript so Gradio's internal CSS variables default to dark
|
| 2106 |
dark_mode_js = """
|
|
|
|
| 2455 |
wav, dur = tts.synthesize(
|
| 2456 |
text=korean_word,
|
| 2457 |
voice_style=voice_style,
|
| 2458 |
+
lang="ko",
|
| 2459 |
+
speed=0.7,
|
| 2460 |
+
total_steps=12,
|
| 2461 |
)
|
| 2462 |
item["audio_uri"] = numpy_to_base64_audio(wav, tts.sample_rate)
|
| 2463 |
except Exception as e:
|