Spaces:
Running
Running
commented code cleanup
Browse files
app.py
CHANGED
@@ -492,15 +492,6 @@ DESCR = """
|
|
492 |
|
493 |
Vote to help the community find the best available text-to-speech model!
|
494 |
""".strip()
|
495 |
-
# INSTR = """
|
496 |
-
# ## Instructions
|
497 |
-
|
498 |
-
# * Listen to two anonymous models
|
499 |
-
# * Vote on which synthesized audio sounds more natural to you
|
500 |
-
# * If there's a tie, click Skip
|
501 |
-
|
502 |
-
# **When you're ready to begin, login and begin voting!** The model names will be revealed once you vote.
|
503 |
-
# """.strip()
|
504 |
INSTR = """
|
505 |
## 🗳️ Vote
|
506 |
|
@@ -683,17 +674,6 @@ model_links = {
|
|
683 |
'speecht5': 'https://github.com/microsoft/SpeechT5',
|
684 |
'metavoice': 'https://github.com/metavoiceio/metavoice-src',
|
685 |
}
|
686 |
-
# def get_random_split(existing_split=None):
|
687 |
-
# choice = random.choice(list(audio_dataset.keys()))
|
688 |
-
# if existing_split and choice == existing_split:
|
689 |
-
# return get_random_split(choice)
|
690 |
-
# else:
|
691 |
-
# return choice
|
692 |
-
|
693 |
-
# def get_random_splits():
|
694 |
-
# choice1 = get_random_split()
|
695 |
-
# choice2 = get_random_split(choice1)
|
696 |
-
# return (choice1, choice2)
|
697 |
def model_license(name):
|
698 |
print(name)
|
699 |
for k, v in AVAILABLE_MODELS.items():
|
@@ -885,26 +865,6 @@ def both_good(model1, model2, userid):
|
|
885 |
return reload(model1, model2, userid)
|
886 |
def reload(chosenmodel1=None, chosenmodel2=None, userid=None, chose_a=False, chose_b=False):
|
887 |
# Select random splits
|
888 |
-
# row = random.choice(list(audio_dataset['train']))
|
889 |
-
# options = list(random.choice(list(audio_dataset['train'])).keys())
|
890 |
-
# split1, split2 = random.sample(options, 2)
|
891 |
-
# choice1, choice2 = (row[split1], row[split2])
|
892 |
-
# if chosenmodel1 in model_names:
|
893 |
-
# chosenmodel1 = model_names[chosenmodel1]
|
894 |
-
# if chosenmodel2 in model_names:
|
895 |
-
# chosenmodel2 = model_names[chosenmodel2]
|
896 |
-
# out = [
|
897 |
-
# (choice1['sampling_rate'], choice1['array']),
|
898 |
-
# (choice2['sampling_rate'], choice2['array']),
|
899 |
-
# split1,
|
900 |
-
# split2
|
901 |
-
# ]
|
902 |
-
# if userid: out.append(userid)
|
903 |
-
# if chosenmodel1: out.append(f'This model was {chosenmodel1}')
|
904 |
-
# if chosenmodel2: out.append(f'This model was {chosenmodel2}')
|
905 |
-
# return out
|
906 |
-
# return (f'This model was {chosenmodel1}', f'This model was {chosenmodel2}', gr.update(visible=False), gr.update(visible=False))
|
907 |
-
# return (gr.update(variant='secondary', value=chosenmodel1, interactive=False), gr.update(variant='secondary', value=chosenmodel2, interactive=False))
|
908 |
chosenmodel1 = make_link_to_space(chosenmodel1)
|
909 |
chosenmodel2 = make_link_to_space(chosenmodel2)
|
910 |
out = [
|
@@ -939,51 +899,6 @@ with gr.Blocks() as leaderboard:
|
|
939 |
reloadbtn.click(get_leaderboard, inputs=[reveal_prelim], outputs=[df])
|
940 |
# 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.")
|
941 |
|
942 |
-
# with gr.Blocks() as vote:
|
943 |
-
# useridstate = gr.State()
|
944 |
-
# gr.Markdown(INSTR)
|
945 |
-
# # gr.LoginButton()
|
946 |
-
# with gr.Row():
|
947 |
-
# gr.HTML('<div align="left"><h3>Model A</h3></div>')
|
948 |
-
# gr.HTML('<div align="right"><h3>Model B</h3></div>')
|
949 |
-
# model1 = gr.Textbox(interactive=False, visible=False, lines=1, max_lines=1)
|
950 |
-
# model2 = gr.Textbox(interactive=False, visible=False, lines=1, max_lines=1)
|
951 |
-
# # with gr.Group():
|
952 |
-
# # with gr.Row():
|
953 |
-
# # prevmodel1 = gr.Textbox(interactive=False, show_label=False, container=False, value="Vote to reveal model A")
|
954 |
-
# # prevmodel2 = gr.Textbox(interactive=False, show_label=False, container=False, value="Vote to reveal model B", text_align="right")
|
955 |
-
# # with gr.Row():
|
956 |
-
# # aud1 = gr.Audio(interactive=False, show_label=False, show_download_button=False, show_share_button=False, waveform_options={'waveform_progress_color': '#3C82F6'})
|
957 |
-
# # aud2 = gr.Audio(interactive=False, show_label=False, show_download_button=False, show_share_button=False, waveform_options={'waveform_progress_color': '#3C82F6'})
|
958 |
-
# with gr.Group():
|
959 |
-
# with gr.Row():
|
960 |
-
# with gr.Column():
|
961 |
-
# with gr.Group():
|
962 |
-
# prevmodel1 = gr.Textbox(interactive=False, show_label=False, container=False, value="Vote to reveal model A", lines=1, max_lines=1)
|
963 |
-
# aud1 = gr.Audio(interactive=False, show_label=False, show_download_button=False, show_share_button=False, waveform_options={'waveform_progress_color': '#3C82F6'})
|
964 |
-
# with gr.Column():
|
965 |
-
# with gr.Group():
|
966 |
-
# prevmodel2 = gr.Textbox(interactive=False, show_label=False, container=False, value="Vote to reveal model B", text_align="right", lines=1, max_lines=1)
|
967 |
-
# aud2 = gr.Audio(interactive=False, show_label=False, show_download_button=False, show_share_button=False, waveform_options={'waveform_progress_color': '#3C82F6'})
|
968 |
-
|
969 |
-
|
970 |
-
# with gr.Row():
|
971 |
-
# abetter = gr.Button("A is Better", variant='primary', scale=4)
|
972 |
-
# # skipbtn = gr.Button("Skip", scale=1)
|
973 |
-
# bbetter = gr.Button("B is Better", variant='primary', scale=4)
|
974 |
-
# with gr.Row():
|
975 |
-
# bothbad = gr.Button("Both are Bad", scale=2)
|
976 |
-
# skipbtn = gr.Button("Skip", scale=1)
|
977 |
-
# bothgood = gr.Button("Both are Good", scale=2)
|
978 |
-
# outputs = [aud1, aud2, model1, model2, useridstate, prevmodel1, prevmodel2]
|
979 |
-
# abetter.click(a_is_better, outputs=outputs, inputs=[model1, model2, useridstate])
|
980 |
-
# bbetter.click(b_is_better, outputs=outputs, inputs=[model1, model2, useridstate])
|
981 |
-
# skipbtn.click(b_is_better, outputs=outputs, inputs=[model1, model2, useridstate])
|
982 |
-
|
983 |
-
# bothbad.click(both_bad, outputs=outputs, inputs=[model1, model2, useridstate])
|
984 |
-
# bothgood.click(both_good, outputs=outputs, inputs=[model1, model2, useridstate])
|
985 |
-
|
986 |
-
# vote.load(reload, outputs=[aud1, aud2, model1, model2])
|
987 |
def doloudnorm(path):
|
988 |
data, rate = sf.read(path)
|
989 |
meter = pyln.Meter(rate)
|
@@ -1241,30 +1156,6 @@ def synthandreturn(text, request: gr.Request):
|
|
1241 |
False, #aplayed
|
1242 |
False, #bplayed
|
1243 |
)
|
1244 |
-
# return (
|
1245 |
-
# text,
|
1246 |
-
# "Synthesize",
|
1247 |
-
# gr.update(visible=True), # r2
|
1248 |
-
# mdl1, # model1
|
1249 |
-
# mdl2, # model2
|
1250 |
-
# # 'Vote to reveal model A', # prevmodel1
|
1251 |
-
# gr.update(visible=True, value=router.predict(
|
1252 |
-
# text,
|
1253 |
-
# AVAILABLE_MODELS[mdl1],
|
1254 |
-
# api_name="/synthesize"
|
1255 |
-
# )), # aud1
|
1256 |
-
# # 'Vote to reveal model B', # prevmodel2
|
1257 |
-
# gr.update(visible=True, value=router.predict(
|
1258 |
-
# text,
|
1259 |
-
# AVAILABLE_MODELS[mdl2],
|
1260 |
-
# api_name="/synthesize"
|
1261 |
-
# )), # aud2
|
1262 |
-
# gr.update(visible=True, interactive=True),
|
1263 |
-
# gr.update(visible=True, interactive=True),
|
1264 |
-
# gr.update(visible=False),
|
1265 |
-
# gr.update(visible=False),
|
1266 |
-
# gr.update(visible=False), #nxt round btn
|
1267 |
-
# )
|
1268 |
|
1269 |
def unlock_vote(btn_index, aplayed, bplayed):
|
1270 |
# sample played
|
@@ -1493,7 +1384,6 @@ with gr.Blocks() as vote:
|
|
1493 |
elem_id='arena-next-round',
|
1494 |
visible=False
|
1495 |
)
|
1496 |
-
# outputs = [text, btn, r2, model1, model2, prevmodel1, aud1, prevmodel2, aud2, abetter, bbetter]
|
1497 |
outputs = [
|
1498 |
text,
|
1499 |
btn,
|
@@ -1560,16 +1450,7 @@ with gr.Blocks() as vote:
|
|
1560 |
inputs=[gr.State(value=1), aplayed, bplayed],
|
1561 |
)\
|
1562 |
.then(None, js="() => "+ unblur_js)
|
1563 |
-
|
1564 |
-
# None,
|
1565 |
-
# js="() => {console.log(new Date().getTime().toString()+'input')}",
|
1566 |
-
# )
|
1567 |
-
# aud1.change(
|
1568 |
-
# None,
|
1569 |
-
# js="() => {console.log(new Date().getTime().toString()+'change')}",
|
1570 |
-
# )
|
1571 |
-
|
1572 |
-
# nxt_outputs = [prevmodel1, prevmodel2, abetter, bbetter]
|
1573 |
nxt_outputs = [abetter, bbetter, prevmodel1, prevmodel2, nxtroundbtn]
|
1574 |
abetter\
|
1575 |
.click(a_is_better, outputs=nxt_outputs, inputs=[model1, model2, useridstate, text])\
|
|
|
492 |
|
493 |
Vote to help the community find the best available text-to-speech model!
|
494 |
""".strip()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
495 |
INSTR = """
|
496 |
## 🗳️ Vote
|
497 |
|
|
|
674 |
'speecht5': 'https://github.com/microsoft/SpeechT5',
|
675 |
'metavoice': 'https://github.com/metavoiceio/metavoice-src',
|
676 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
677 |
def model_license(name):
|
678 |
print(name)
|
679 |
for k, v in AVAILABLE_MODELS.items():
|
|
|
865 |
return reload(model1, model2, userid)
|
866 |
def reload(chosenmodel1=None, chosenmodel2=None, userid=None, chose_a=False, chose_b=False):
|
867 |
# Select random splits
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
868 |
chosenmodel1 = make_link_to_space(chosenmodel1)
|
869 |
chosenmodel2 = make_link_to_space(chosenmodel2)
|
870 |
out = [
|
|
|
899 |
reloadbtn.click(get_leaderboard, inputs=[reveal_prelim], outputs=[df])
|
900 |
# 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.")
|
901 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
902 |
def doloudnorm(path):
|
903 |
data, rate = sf.read(path)
|
904 |
meter = pyln.Meter(rate)
|
|
|
1156 |
False, #aplayed
|
1157 |
False, #bplayed
|
1158 |
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1159 |
|
1160 |
def unlock_vote(btn_index, aplayed, bplayed):
|
1161 |
# sample played
|
|
|
1384 |
elem_id='arena-next-round',
|
1385 |
visible=False
|
1386 |
)
|
|
|
1387 |
outputs = [
|
1388 |
text,
|
1389 |
btn,
|
|
|
1450 |
inputs=[gr.State(value=1), aplayed, bplayed],
|
1451 |
)\
|
1452 |
.then(None, js="() => "+ unblur_js)
|
1453 |
+
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1454 |
nxt_outputs = [abetter, bbetter, prevmodel1, prevmodel2, nxtroundbtn]
|
1455 |
abetter\
|
1456 |
.click(a_is_better, outputs=nxt_outputs, inputs=[model1, model2, useridstate, text])\
|