Spaces:
Running
Running
Merge branch 'spaces'
Browse files
app.py
CHANGED
@@ -44,7 +44,6 @@ AVAILABLE_MODELS = {
|
|
44 |
'coqui/xtts': '1#1',
|
45 |
'collabora/WhisperSpeech': '/whisper_speech_demo#0',
|
46 |
'myshell-ai/OpenVoice': '1#1',
|
47 |
-
# 'PolyAI/pheme': '/predict#0', #sleepy HF Space
|
48 |
'mrfakename/MetaVoice-1B-v0.1': '/tts#0',
|
49 |
|
50 |
# xVASynth (CPU)
|
@@ -53,10 +52,11 @@ AVAILABLE_MODELS = {
|
|
53 |
# CoquiTTS (CPU)
|
54 |
# 'coqui/CoquiTTS': '0#0',
|
55 |
|
56 |
-
'amphion/Text-to-Speech': '/predict#0',
|
57 |
'LeeSangHoon/HierSpeech_TTS': '/predict#0',
|
58 |
|
59 |
# TTS w issues
|
|
|
|
|
60 |
# 'suno/bark': '3#0', # Hallucinates
|
61 |
# 'shivammehta25/Matcha-TTS': '5#0', #seems to require multiple requests for setup
|
62 |
# 'styletts2/styletts2': '0#0', #API disabled
|
@@ -425,6 +425,7 @@ def get_leaderboard(reveal_prelim = False):
|
|
425 |
df = pd.DataFrame(data, columns=['name', 'upvote', 'downvote'])
|
426 |
# df['license'] = df['name'].map(model_license)
|
427 |
df['name'] = df['name'].replace(model_names)
|
|
|
428 |
df['votes'] = df['upvote'] + df['downvote']
|
429 |
# df['score'] = round((df['upvote'] / df['votes']) * 100, 2) # Percentage score
|
430 |
|
@@ -447,6 +448,13 @@ def get_leaderboard(reveal_prelim = False):
|
|
447 |
# df = df[['order', 'name', 'score', 'license', 'votes']]
|
448 |
df = df[['order', 'name', 'score', 'votes']]
|
449 |
return df
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
450 |
def mkuuid(uid):
|
451 |
if not uid:
|
452 |
uid = uuid.uuid4()
|
@@ -537,16 +545,19 @@ def reload(chosenmodel1=None, chosenmodel2=None, userid=None, chose_a=False, cho
|
|
537 |
# return out
|
538 |
# return (f'This model was {chosenmodel1}', f'This model was {chosenmodel2}', gr.update(visible=False), gr.update(visible=False))
|
539 |
# return (gr.update(variant='secondary', value=chosenmodel1, interactive=False), gr.update(variant='secondary', value=chosenmodel2, interactive=False))
|
|
|
|
|
540 |
out = [
|
541 |
gr.update(interactive=False, visible=False),
|
542 |
gr.update(interactive=False, visible=False)
|
543 |
]
|
|
|
544 |
if chose_a == True:
|
545 |
-
out.append(gr.update(value=f'Your vote: {chosenmodel1}',
|
546 |
-
out.append(gr.update(value=f'{chosenmodel2}',
|
547 |
else:
|
548 |
-
out.append(gr.update(value=f'{chosenmodel1}',
|
549 |
-
out.append(gr.update(value=f'Your vote: {chosenmodel2}',
|
550 |
out.append(gr.update(visible=True))
|
551 |
return out
|
552 |
|
@@ -642,12 +653,15 @@ def synthandreturn(text):
|
|
642 |
except:
|
643 |
pass
|
644 |
# Get two random models
|
645 |
-
# your TTS model versus The World!!!
|
646 |
mdl1 = 'Pendrokar/xVASynth'
|
647 |
vsModels = dict(AVAILABLE_MODELS)
|
648 |
del vsModels[mdl1]
|
|
|
649 |
mdl2 = random.sample(list(vsModels.keys()), 1)
|
|
|
650 |
mdl1, mdl2 = random.sample(list([mdl1, mdl2[0]]), 2)
|
|
|
651 |
# mdl1, mdl2 = random.sample(list(AVAILABLE_MODELS.keys()), 2)
|
652 |
log_text(text)
|
653 |
print("[debug] Using", mdl1, mdl2)
|
@@ -834,7 +848,10 @@ def randomsent():
|
|
834 |
return random.choice(sents), '🎲'
|
835 |
def clear_stuff():
|
836 |
return "", "Synthesize", gr.update(visible=False), '', '', gr.update(visible=False), gr.update(visible=False), gr.update(visible=False), gr.update(visible=False), gr.update(visible=False), gr.update(visible=False), gr.update(visible=False)
|
837 |
-
|
|
|
|
|
|
|
838 |
with gr.Blocks() as vote:
|
839 |
# sample played
|
840 |
aplayed = gr.State(value=False)
|
@@ -855,15 +872,16 @@ with gr.Blocks() as vote:
|
|
855 |
with gr.Group():
|
856 |
aud1 = gr.Audio(interactive=False, show_label=False, show_download_button=False, show_share_button=False, waveform_options={'waveform_progress_color': '#3C82F6'})
|
857 |
abetter = gr.Button("A is better", variant='primary', interactive=False)
|
858 |
-
prevmodel1 = gr.
|
859 |
with gr.Column():
|
860 |
with gr.Group():
|
861 |
aud2 = gr.Audio(interactive=False, show_label=False, show_download_button=False, show_share_button=False, waveform_options={'waveform_progress_color': '#3C82F6'})
|
862 |
bbetter = gr.Button("B is better", variant='primary', interactive=False)
|
863 |
-
prevmodel2 = gr.
|
864 |
nxtroundbtn = gr.Button('Next round', visible=False)
|
|
|
865 |
outputs = [text, btn, r2, model1, model2, aud1, aud2, abetter, bbetter, prevmodel1, prevmodel2, nxtroundbtn, aplayed, bplayed]
|
866 |
-
btn.click(synthandreturn, inputs=[text], outputs=outputs)
|
867 |
nxtroundbtn.click(clear_stuff, outputs=outputs)
|
868 |
|
869 |
# Allow interaction with the vote buttons only when both audio samples have finished playing
|
|
|
44 |
'coqui/xtts': '1#1',
|
45 |
'collabora/WhisperSpeech': '/whisper_speech_demo#0',
|
46 |
'myshell-ai/OpenVoice': '1#1',
|
|
|
47 |
'mrfakename/MetaVoice-1B-v0.1': '/tts#0',
|
48 |
|
49 |
# xVASynth (CPU)
|
|
|
52 |
# CoquiTTS (CPU)
|
53 |
# 'coqui/CoquiTTS': '0#0',
|
54 |
|
|
|
55 |
'LeeSangHoon/HierSpeech_TTS': '/predict#0',
|
56 |
|
57 |
# TTS w issues
|
58 |
+
# 'PolyAI/pheme': '/predict#0', #sleepy HF Space
|
59 |
+
# 'amphion/Text-to-Speech': '/predict#0', #takes a whole minute to synthesize
|
60 |
# 'suno/bark': '3#0', # Hallucinates
|
61 |
# 'shivammehta25/Matcha-TTS': '5#0', #seems to require multiple requests for setup
|
62 |
# 'styletts2/styletts2': '0#0', #API disabled
|
|
|
425 |
df = pd.DataFrame(data, columns=['name', 'upvote', 'downvote'])
|
426 |
# df['license'] = df['name'].map(model_license)
|
427 |
df['name'] = df['name'].replace(model_names)
|
428 |
+
df['name'] = make_link_to_space(df['name'])
|
429 |
df['votes'] = df['upvote'] + df['downvote']
|
430 |
# df['score'] = round((df['upvote'] / df['votes']) * 100, 2) # Percentage score
|
431 |
|
|
|
448 |
# df = df[['order', 'name', 'score', 'license', 'votes']]
|
449 |
df = df[['order', 'name', 'score', 'votes']]
|
450 |
return df
|
451 |
+
|
452 |
+
def make_link_to_space(model_name):
|
453 |
+
# create a anchor link if a HF space
|
454 |
+
if '/' in model_name:
|
455 |
+
return '🤗 <a href="'+ 'https://huggingface.co/spaces/' + model_name + '">' + model_name + '</a>'
|
456 |
+
# otherwise just return the model name
|
457 |
+
return model_name
|
458 |
def mkuuid(uid):
|
459 |
if not uid:
|
460 |
uid = uuid.uuid4()
|
|
|
545 |
# return out
|
546 |
# return (f'This model was {chosenmodel1}', f'This model was {chosenmodel2}', gr.update(visible=False), gr.update(visible=False))
|
547 |
# return (gr.update(variant='secondary', value=chosenmodel1, interactive=False), gr.update(variant='secondary', value=chosenmodel2, interactive=False))
|
548 |
+
chosenmodel1 = make_link_to_space(chosenmodel1)
|
549 |
+
chosenmodel2 = make_link_to_space(chosenmodel2)
|
550 |
out = [
|
551 |
gr.update(interactive=False, visible=False),
|
552 |
gr.update(interactive=False, visible=False)
|
553 |
]
|
554 |
+
style = 'text-align: center; font-size: 1rem; margin-bottom: 0; padding: var(--input-padding)'
|
555 |
if chose_a == True:
|
556 |
+
out.append(gr.update(value=f'<p style="{style}">Your vote: {chosenmodel1}</p>', visible=True))
|
557 |
+
out.append(gr.update(value=f'<p style="{style}">{chosenmodel2}</p>', visible=True))
|
558 |
else:
|
559 |
+
out.append(gr.update(value=f'<p style="{style}">{chosenmodel1}</p>', visible=True))
|
560 |
+
out.append(gr.update(value=f'<p style="{style}">Your vote: {chosenmodel2}</p>', visible=True))
|
561 |
out.append(gr.update(visible=True))
|
562 |
return out
|
563 |
|
|
|
653 |
except:
|
654 |
pass
|
655 |
# Get two random models
|
656 |
+
# forced model: your TTS model versus The World!!!
|
657 |
mdl1 = 'Pendrokar/xVASynth'
|
658 |
vsModels = dict(AVAILABLE_MODELS)
|
659 |
del vsModels[mdl1]
|
660 |
+
# randomize position of the forced model
|
661 |
mdl2 = random.sample(list(vsModels.keys()), 1)
|
662 |
+
# forced random
|
663 |
mdl1, mdl2 = random.sample(list([mdl1, mdl2[0]]), 2)
|
664 |
+
# actual random
|
665 |
# mdl1, mdl2 = random.sample(list(AVAILABLE_MODELS.keys()), 2)
|
666 |
log_text(text)
|
667 |
print("[debug] Using", mdl1, mdl2)
|
|
|
848 |
return random.choice(sents), '🎲'
|
849 |
def clear_stuff():
|
850 |
return "", "Synthesize", gr.update(visible=False), '', '', gr.update(visible=False), gr.update(visible=False), gr.update(visible=False), gr.update(visible=False), gr.update(visible=False), gr.update(visible=False), gr.update(visible=False)
|
851 |
+
def disable():
|
852 |
+
return [gr.update(interactive=False), gr.update(interactive=False), gr.update(interactive=False)]
|
853 |
+
def enable():
|
854 |
+
return [gr.update(interactive=True), gr.update(interactive=True), gr.update(interactive=True)]
|
855 |
with gr.Blocks() as vote:
|
856 |
# sample played
|
857 |
aplayed = gr.State(value=False)
|
|
|
872 |
with gr.Group():
|
873 |
aud1 = gr.Audio(interactive=False, show_label=False, show_download_button=False, show_share_button=False, waveform_options={'waveform_progress_color': '#3C82F6'})
|
874 |
abetter = gr.Button("A is better", variant='primary', interactive=False)
|
875 |
+
prevmodel1 = gr.HTML(show_label=False, value="Vote to reveal model A", visible=False)
|
876 |
with gr.Column():
|
877 |
with gr.Group():
|
878 |
aud2 = gr.Audio(interactive=False, show_label=False, show_download_button=False, show_share_button=False, waveform_options={'waveform_progress_color': '#3C82F6'})
|
879 |
bbetter = gr.Button("B is better", variant='primary', interactive=False)
|
880 |
+
prevmodel2 = gr.HTML(show_label=False, value="Vote to reveal model B", visible=False)
|
881 |
nxtroundbtn = gr.Button('Next round', visible=False)
|
882 |
+
# outputs = [text, btn, r2, model1, model2, prevmodel1, aud1, prevmodel2, aud2, abetter, bbetter]
|
883 |
outputs = [text, btn, r2, model1, model2, aud1, aud2, abetter, bbetter, prevmodel1, prevmodel2, nxtroundbtn, aplayed, bplayed]
|
884 |
+
btn.click(disable, outputs=[btn, abetter, bbetter]).then(synthandreturn, inputs=[text], outputs=outputs).then(enable, outputs=[btn, abetter, bbetter])
|
885 |
nxtroundbtn.click(clear_stuff, outputs=outputs)
|
886 |
|
887 |
# Allow interaction with the vote buttons only when both audio samples have finished playing
|