Commit ·
5d5cc81
1
Parent(s): ac443d1
* New leaderboard styling with custom table (instead of Gradio dataframe)
Browse filesFiles changed (7)
- .gitignoreAdded+176
- README.md+6-1
- app/config.py+7-1
- app/leaderboard.py+225-12
- app/models.py+30
- app/ui.py+26-1
- app/ui_leaderboard.py+45-7
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176# Byte-compiled / optimized / DLL files__pycache__/*.py[cod]*$py.class
# C extensions*.so
# Distribution / packaging.Pythonbuild/develop-eggs/dist/downloads/eggs/.eggs/lib/lib64/parts/sdist/var/wheels/share/python-wheels/*.egg-info/.installed.cfg*.eggMANIFEST
# PyInstaller# Usually these files are written by a python script from a template# before PyInstaller builds the exe, so as to inject date/other infos into it.*.manifest*.spec
# Installer logspip-log.txtpip-delete-this-directory.txt
# Unit test / coverage reportshtmlcov/.tox/.nox/.coverage.coverage.*.cachenosetests.xmlcoverage.xml*.cover*.py,cover.hypothesis/.pytest_cache/cover/
# Translations*.mo*.pot
# Django stuff:*.loglocal_settings.pydb.sqlite3db.sqlite3-journal
# Flask stuff:instance/.webassets-cache
# Scrapy stuff:.scrapy
# Sphinx documentationdocs/_build/
# PyBuilder.pybuilder/target/
# Jupyter Notebook.ipynb_checkpoints
# IPythonprofile_default/ipython_config.py
# pyenv# For a library or package, you might want to ignore these files since the code is# intended to run in multiple environments; otherwise, check them in:# .python-version
# pipenv# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.# However, in case of collaboration, if having platform-specific dependencies or dependencies# having no cross-platform support, pipenv may install dependencies that don't work, or not# install all needed dependencies.#Pipfile.lock
# UV# Similar to Pipfile.lock, it is generally recommended to include uv.lock in version control.# This is especially recommended for binary packages to ensure reproducibility, and is more# commonly ignored for libraries.#uv.lock
# poetry# Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control.# This is especially recommended for binary packages to ensure reproducibility, and is more# commonly ignored for libraries.# https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control#poetry.lock
# pdm# Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control.#pdm.lock# pdm stores project-wide configurations in .pdm.toml, but it is recommended to not include it# in version control.# https://pdm.fming.dev/latest/usage/project/#working-with-version-control.pdm.toml.pdm-python.pdm-build/
# PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm__pypackages__/
# Celery stuffcelerybeat-schedulecelerybeat.pid
# SageMath parsed files*.sage.py
# Environments.env.venvenv/venv/ENV/env.bak/venv.bak/
# Spyder project settings.spyderproject.spyproject
# Rope project settings.ropeproject
# mkdocs documentation/site
# mypy.mypy_cache/.dmypy.jsondmypy.json
# Pyre type checker.pyre/
# pytype static type analyzer.pytype/
# Cython debug symbolscython_debug/
# PyCharm# JetBrains specific template is maintained in a separate JetBrains.gitignore that can# be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore# and can be added to the global gitignore or merged into this file. For a more nuclear# option (not recommended) you can uncomment the following to ignore the entire idea folder.#.idea/
# Ruff stuff:.ruff_cache/
# PyPI configuration file.pypirc
*.db12 unmodified lines1314151612 unmodified linessdk_version: 5.1.0short_description: Vote on the latest TTS models!---# TTS Arena12 unmodified lines13141516171819202112 unmodified linessdk_version: 5.1.0short_description: Vote on the latest TTS models!---# TTS ArenaThe codebase for TTS Arena v2.The TTS Arena is a Gradio app with several components. Please refer to the `app` directory for more information.
1234511 unmodified lines17181920212223import os# NOTE: Configure models in `models.py`#########################11 unmodified linesROUTER_ID = "TTS-AGI/tts-router" # You should use a router space to route TTS models to avoid exposing your API keys!SYNC_DB = True # Sync DB to HF dataset?DB_DATASET_ID = os.getenv('DATASET_ID') # HF dataset ID, can be None if not syncingSPACE_ID = os.getenv('SPACE_ID') # Don't change this! It detects if we're running in a HF Space1234567891011 unmodified lines2223242526272829import osRUNNING_LOCALLY = os.getenv('RUNNING_LOCALLY', '0').lower() in ('true', '1', 't')if RUNNING_LOCALLY:print("Running locally, not syncing DB to HF dataset")else:print("Running in HF Space, syncing DB to HF dataset")# NOTE: Configure models in `models.py`#########################11 unmodified linesROUTER_ID = "TTS-AGI/tts-router" # You should use a router space to route TTS models to avoid exposing your API keys!SYNC_DB = not RUNNING_LOCALLY # Sync DB to HF dataset?DB_DATASET_ID = os.getenv('DATASET_ID') # HF dataset ID, can be None if not syncingSPACE_ID = os.getenv('SPACE_ID') # Don't change this! It detects if we're running in a HF Space
2 unmodified lines345678920 unmodified lines3031323334353637383940414243444546474849505152535455565758592 unmodified linesfrom .models import *import pandas as pddef get_leaderboard(reveal_prelim = False, hide_battle_votes = False):conn = get_db()cursor = conn.cursor()20 unmodified linesdata = cursor.fetchall()df = pd.DataFrame(data, columns=['name', 'upvote', 'downvote'])df['name'] = df['name'].replace(model_names).replace('Anonymous Sparkle', 'Fish Speech v1.5')df['votes'] = df['upvote'] + df['downvote']# Filter out rows with insufficient votes if not revealing preliminary resultsif not reveal_prelim:df = df[df['votes'] > 500]## ELO SCOREdf['score'] = 1200for i in range(len(df)):for j in range(len(df)):if i != j:try:expected_a = 1 / (1 + 10 ** ((df['score'].iloc[j] - df['score'].iloc[i]) / 400))expected_b = 1 / (1 + 10 ** ((df['score'].iloc[i] - df['score'].iloc[j]) / 400))actual_a = df['upvote'].iloc[i] / df['votes'].iloc[i] if df['votes'].iloc[i] > 0 else 0.5actual_b = df['upvote'].iloc[j] / df['votes'].iloc[j] if df['votes'].iloc[j] > 0 else 0.5df.iloc[i, df.columns.get_loc('score')] += 32 * (actual_a - expected_a)df.iloc[j, df.columns.get_loc('score')] += 32 * (actual_b - expected_b)except Exception as e:print(f"Error in ELO calculation for rows {i} and {j}: {str(e)}")continuedf['score'] = round(df['score'])## ELO SCOREdf = df.sort_values(by='score', ascending=False)df['order'] = ['#' + str(i + 1) for i in range(len(df))]df = df[['order', 'name', 'score', 'votes']]return df2 unmodified lines345678920 unmodified lines303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722 unmodified linesfrom .models import *import pandas as pddef get_leaderboard(reveal_prelim = False, hide_battle_votes = False, sort_by_elo = False, hide_proprietary = False):conn = get_db()cursor = conn.cursor()20 unmodified linesdata = cursor.fetchall()df = pd.DataFrame(data, columns=['name', 'upvote', 'downvote'])df['name'] = df['name'].replace(model_names).replace('Anonymous Sparkle', 'Fish Speech v1.5')# Calculate total votes and win ratedf['votes'] = df['upvote'] + df['downvote']df['win_rate'] = (df['upvote'] / df['votes'] * 100).round(1)# Remove models with no votesdf = df[df['votes'] > 0]# Filter out rows with insufficient votes if not revealing preliminary resultsif not reveal_prelim:df = df[df['votes'] > 500]## Calculate ELO SCORE (kept as secondary metric)df['elo'] = 1200for i in range(len(df)):for j in range(len(df)):if i != j:try:expected_a = 1 / (1 + 10 ** ((df['elo'].iloc[j] - df['elo'].iloc[i]) / 400))expected_b = 1 / (1 + 10 ** ((df['elo'].iloc[i] - df['elo'].iloc[j]) / 400))actual_a = df['upvote'].iloc[i] / df['votes'].iloc[i] if df['votes'].iloc[i] > 0 else 0.5actual_b = df['upvote'].iloc[j] / df['votes'].iloc[j] if df['votes'].iloc[j] > 0 else 0.5df.iloc[i, df.columns.get_loc('elo')] += 32 * (actual_a - expected_a)df.iloc[j, df.columns.get_loc('elo')] += 32 * (actual_b - expected_b)except Exception as e:print(f"Error in ELO calculation for rows {i} and {j}: {str(e)}")continuedf['elo'] = round(df['elo'])# Sort based on user preferencesort_column = 'elo' if sort_by_elo else 'win_rate'df = df.sort_values(by=sort_column, ascending=False)df['order'] = ['#' + str(i + 1) for i in range(len(df))]# Select and order columns for displaydf = df[['order', 'name', 'win_rate', 'votes', 'elo']]# Remove proprietary models if filter is enabledif hide_proprietary:df = df[~df['name'].isin(closed_source)]# Convert DataFrame to markdown table with CSS stylingmarkdown_table = """<style>/* Reset any Gradio table styles */.leaderboard-table,.leaderboard-table th,.leaderboard-table td {border: none !important;border-collapse: separate !important;border-spacing: 0 !important;}.leaderboard-container {background: var(--background-fill-primary);border: 1px solid var(--border-color-primary);border-radius: 12px;padding: 4px;margin: 10px 0;width: 100%;overflow-x: auto; /* Enable horizontal scroll */}.leaderboard-scroll {max-height: 600px;overflow-y: auto;border-radius: 8px;}.leaderboard-table {width: 100%;border-spacing: 0;border-collapse: separate;font-size: 15px;line-height: 1.5;table-layout: auto; /* Allow flexible column widths */}.leaderboard-table th {background: var(--background-fill-secondary);color: var(--body-text-color);font-weight: 600;text-align: left;padding: 12px 16px;position: sticky;top: 0;z-index: 1;}.leaderboard-table th:after {content: '';position: absolute;left: 0;bottom: 0;width: 100%;border-bottom: 1px solid var(--border-color-primary);}.leaderboard-table td {padding: 12px 16px;color: var(--body-text-color);}.leaderboard-table tr td {border-bottom: 1px solid var(--border-color-primary);}.leaderboard-table tr:last-child td {border-bottom: none;}.leaderboard-table tr:hover td {background: var(--background-fill-secondary);}/* Column-specific styles */.leaderboard-table .col-rank {width: 70px;min-width: 70px; /* Prevent rank from shrinking */}.leaderboard-table .col-model {min-width: 200px; /* Minimum width before scrolling */}.leaderboard-table .col-winrate {width: 100px;min-width: 100px; /* Prevent win rate from shrinking */}.leaderboard-table .col-votes {width: 100px;min-width: 100px; /* Prevent votes from shrinking */}.leaderboard-table .col-arena {width: 100px;min-width: 100px; /* Prevent arena score from shrinking */}.win-rate {display: inline-block;font-weight: 600;padding: 4px 8px;border-radius: 6px;min-width: 65px;text-align: center;}.win-rate-excellent {background-color: var(--color-accent);color: var(--color-accent-foreground);}.win-rate-good {background-color: var(--color-accent-soft);color: var(--body-text-color);}.win-rate-average {background-color: var(--background-fill-secondary);color: var(--body-text-color);border: 1px solid var(--border-color-primary);}.win-rate-below {background-color: var(--error-background-fill);color: var(--body-text-color);}.model-link {color: var(--body-text-color) !important;text-decoration: none !important;border-bottom: 1px dashed var(--border-color-primary);}.model-link:hover {color: var(--color-accent) !important;border-bottom-color: var(--color-accent) !important;}.proprietary-badge {display: inline-block;font-size: 12px;padding: 2px 6px;border-radius: 4px;background-color: var(--background-fill-secondary);color: var(--body-text-color);margin-left: 6px;border: 1px solid var(--border-color-primary);}</style><div class="leaderboard-container"><div class="leaderboard-scroll"><table class="leaderboard-table"><thead><tr><th class="col-rank">Rank</th><th class="col-model">Model</th><th class="col-winrate">Win Rate</th><th class="col-votes">Votes</th>""" + ("""<th class="col-arena">Arena Score</th>""" if sort_by_elo else "") + """</tr></thead><tbody>"""def get_win_rate_class(win_rate):if win_rate >= 60:return "win-rate-excellent"elif win_rate >= 55:return "win-rate-good"elif win_rate >= 45:return "win-rate-average"else:return "win-rate-below"for _, row in df.iterrows():win_rate_class = get_win_rate_class(row['win_rate'])win_rate_html = f'<span class="win-rate {win_rate_class}">{row["win_rate"]}%</span>'# Add link to model name if available and proprietary badge if closed sourcemodel_name = row['name']original_model_name = model_nameif model_name in model_links:model_name = f'<a href="{model_links[model_name]}" target="_blank" class="model-link">{model_name}</a>'if original_model_name in closed_source:model_name += '<span class="proprietary-badge">Proprietary</span>'markdown_table += f'''<tr><td class="col-rank">{row['order']}</td><td class="col-model">{model_name}</td><td class="col-winrate">{win_rate_html}</td><td class="col-votes">{row['votes']:,}</td>''' + (f'''<td class="col-arena">{int(row['elo'])}</td>''' if sort_by_elo else "") + "</tr>\n"markdown_table += "</tbody></table></div></div>"return markdown_table
21 unmodified lines22232425262721 unmodified lines#'Fish Speech v1.4': 'fish',}# Model name mapping, can include models that users cannot vote onmodel_names = {21 unmodified lines22232425262728293031323334353637383940414243444546474849505152535455565721 unmodified lines#'Fish Speech v1.4': 'fish',}model_links = {'ElevenLabs': 'https://elevenlabs.io/','Play.HT 2.0': 'https://play.ht/','Play.HT 3.0 Mini': 'https://play.ht/','XTTSv2': 'https://huggingface.co/coqui/XTTS-v2','MeloTTS': 'https://github.com/myshell-ai/MeloTTS','StyleTTS 2': 'https://github.com/yl4579/StyleTTS2','Parler TTS Large': 'https://github.com/huggingface/parler-tts','Parler TTS': 'https://github.com/huggingface/parler-tts','Fish Speech v1.5': 'https://github.com/fishaudio/fish-speech','Fish Speech v1.4': 'https://github.com/fishaudio/fish-speech','GPT-SoVITS': 'https://github.com/RVC-Boss/GPT-SoVITS','WhisperSpeech': 'https://github.com/WhisperSpeech/WhisperSpeech','VoiceCraft 2.0': 'https://github.com/jasonppy/VoiceCraft','PlayDialog': 'https://play.ht/','Kokoro v0.19': 'https://huggingface.co/hexgrad/Kokoro-82M','CosyVoice 2.0': 'https://github.com/FunAudioLLM/CosyVoice','MetaVoice': 'https://github.com/metavoiceio/metavoice-src','OpenVoice': 'https://github.com/myshell-ai/OpenVoice','OpenVoice V2': 'https://github.com/myshell-ai/OpenVoice','Pheme': 'https://github.com/PolyAI-LDN/pheme','Vokan TTS': 'https://huggingface.co/ShoukanLabs/Vokan',}closed_source = ['ElevenLabs','Play.HT 2.0','Play.HT 3.0 Mini','PlayDialog',]# Model name mapping, can include models that users cannot vote onmodel_names = {
8 unmodified lines91011121314158 unmodified lineswith gr.Blocks() as about:gr.Markdown(ABOUT)with gr.Blocks(css="footer {visibility: hidden}textbox{resize:none}", title="TTS Arena") as app:gr.Markdown(DESCR)gr.TabbedInterface([vote, battle, leaderboard, about], ['Vote', 'Battle', 'Leaderboard', 'About'])if CITATION_TEXT:8 unmodified lines9101112131415161718192021222324252627282930313233343536373839408 unmodified lineswith gr.Blocks() as about:gr.Markdown(ABOUT)CSS = """footer {visibility: hidden}textbox {resize: none}/* Custom scrollbar styles */::-webkit-scrollbar {width: 8px;height: 8px;}::-webkit-scrollbar-track {background: var(--background-fill-primary);border-radius: 4px;}::-webkit-scrollbar-thumb {background: var(--border-color-primary);border-radius: 4px;}::-webkit-scrollbar-thumb:hover {background: var(--body-text-color);}"""with gr.Blocks(css=CSS, theme=gr.themes.Default(font=[gr.themes.GoogleFont("Geist"), "sans-serif"]), title="TTS Arena") as app:gr.Markdown(DESCR)gr.TabbedInterface([vote, battle, leaderboard, about], ['Vote', 'Battle', 'Leaderboard', 'About'])if CITATION_TEXT:
4 unmodified lines5678910111213141516174 unmodified lineswith gr.Blocks() as leaderboard:gr.Markdown(LDESC)df = gr.Dataframe(interactive=False, min_width=0, wrap=True, column_widths=[30, 200, 50, 50])reloadbtn = gr.Button("Refresh")with gr.Row():reveal_prelim = gr.Checkbox(label="Reveal preliminary results", info="Show all models, including models with very few human ratings.", scale=1)hide_battle_votes = gr.Checkbox(label="Hide Battle Mode votes", info="Exclude votes obtained through Battle Mode.", scale=1)reveal_prelim.input(get_leaderboard, inputs=[reveal_prelim, hide_battle_votes], outputs=[df])hide_battle_votes.input(get_leaderboard, inputs=[reveal_prelim, hide_battle_votes], outputs=[df])leaderboard.load(get_leaderboard, inputs=[reveal_prelim, hide_battle_votes], outputs=[df])reloadbtn.click(get_leaderboard, inputs=[reveal_prelim, hide_battle_votes], outputs=[df])# gr.Markdown("DISCLAIMER: The licenses listed may not be accurate or up to date, you are responsible for checking the licenses before using the models. Also note that some models may have additional usage restrictions.")4 unmodified lines56789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354554 unmodified lineswith gr.Blocks() as leaderboard:gr.Markdown(LDESC)table = gr.HTML() # Changed to HTML to support custom CSSreloadbtn = gr.Button("Refresh")with gr.Row():with gr.Column(scale=1):reveal_prelim = gr.Checkbox(label="Reveal preliminary results",info="Show all models, including models with very few human ratings.",)with gr.Column(scale=1):hide_battle_votes = gr.Checkbox(label="Hide Battle Mode votes",info="Exclude votes obtained through Battle Mode.",)with gr.Column(scale=1):sort_by_elo = gr.Checkbox(label="Sort by Arena Score",info="Sort models by Arena Score instead of win rate",value=False,)with gr.Column(scale=1):hide_proprietary = gr.Checkbox(label="Hide proprietary models",info="Show only open models",value=False,)def update_leaderboard(*args):return get_leaderboard(*args)reveal_prelim.input(update_leaderboard,inputs=[reveal_prelim, hide_battle_votes, sort_by_elo, hide_proprietary],outputs=[table])hide_battle_votes.input(update_leaderboard,inputs=[reveal_prelim, hide_battle_votes, sort_by_elo, hide_proprietary],outputs=[table])sort_by_elo.input(update_leaderboard,inputs=[reveal_prelim, hide_battle_votes, sort_by_elo, hide_proprietary],outputs=[table])hide_proprietary.input(update_leaderboard,inputs=[reveal_prelim, hide_battle_votes, sort_by_elo, hide_proprietary],outputs=[table])leaderboard.load(update_leaderboard,inputs=[reveal_prelim, hide_battle_votes, sort_by_elo, hide_proprietary],outputs=[table])reloadbtn.click(update_leaderboard,inputs=[reveal_prelim, hide_battle_votes, sort_by_elo, hide_proprietary],outputs=[table])# gr.Markdown("DISCLAIMER: The licenses listed may not be accurate or up to date, you are responsible for checking the licenses before using the models. Also note that some models may have additional usage restrictions.")
.gitignoreAdded+176
README.md+6-1
app/config.py+7-1
app/leaderboard.py+225-12
app/models.py+30
app/ui.py+26-1
app/ui_leaderboard.py+45-7