Spaces:
Running
Running
autoplay; aud1 red color
Browse files
app.py
CHANGED
@@ -194,6 +194,7 @@ HF_SPACES = {
|
|
194 |
# 'styletts2/styletts2': '0#0', #API disabled
|
195 |
# 'Manmay/tortoise-tts': '/predict#0', #Cannot skip text-from-file parameter
|
196 |
# 'pytorch/Tacotron2': '0#0', #old gradio
|
|
|
197 |
}
|
198 |
|
199 |
# for zero-shot TTS - voice sample of Scarlett Johanson
|
@@ -1053,8 +1054,8 @@ def synthandreturn(text):
|
|
1053 |
gr.update(visible=True), # r2
|
1054 |
mdl1, # model1
|
1055 |
mdl2, # model2
|
1056 |
-
gr.update(visible=True, value=results[mdl1k]), # aud1
|
1057 |
-
gr.update(visible=True, value=results[mdl2k]), # aud2
|
1058 |
gr.update(visible=True, interactive=False), #abetter
|
1059 |
gr.update(visible=True, interactive=False), #bbetter
|
1060 |
gr.update(visible=False), #prevmodel1
|
@@ -1090,18 +1091,30 @@ def synthandreturn(text):
|
|
1090 |
# )
|
1091 |
|
1092 |
def unlock_vote(btn_index, aplayed, bplayed):
|
|
|
1093 |
# sample played
|
1094 |
if btn_index == 0:
|
1095 |
aplayed = True
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1096 |
if btn_index == 1:
|
1097 |
bplayed = True
|
1098 |
|
1099 |
# both audio samples played
|
1100 |
if bool(aplayed) and bool(bplayed):
|
1101 |
print('Both audio samples played, voting unlocked')
|
1102 |
-
return [gr.update(interactive=True), gr.update(interactive=True), True, True]
|
1103 |
|
1104 |
-
return [gr.update(), gr.update(), aplayed, bplayed]
|
1105 |
|
1106 |
|
1107 |
def cachedsent(request: gr.Request):
|
@@ -1143,8 +1156,8 @@ def cachedsent(request: gr.Request):
|
|
1143 |
gr.update(visible=True), # r2
|
1144 |
pair[0].modelName, # model1
|
1145 |
pair[1].modelName, # model2
|
1146 |
-
gr.update(visible=True, value=pair[0].filename), # aud1
|
1147 |
-
gr.update(visible=True, value=pair[1].filename), # aud2
|
1148 |
gr.update(visible=True, interactive=False), #abetter
|
1149 |
gr.update(visible=True, interactive=False), #bbetter
|
1150 |
gr.update(visible=False), #prevmodel1
|
@@ -1165,8 +1178,8 @@ def clear_stuff():
|
|
1165 |
gr.update(visible=False), # r2
|
1166 |
'', # model1
|
1167 |
'', # model2
|
1168 |
-
gr.update(visible=False), # aud1
|
1169 |
-
gr.update(visible=False), # aud2
|
1170 |
gr.update(visible=False, interactive=False), #abetter
|
1171 |
gr.update(visible=False, interactive=False), #bbetter
|
1172 |
gr.update(visible=False), #prevmodel1
|
@@ -1201,12 +1214,26 @@ with gr.Blocks() as vote:
|
|
1201 |
with gr.Row(visible=False) as r2:
|
1202 |
with gr.Column():
|
1203 |
with gr.Group():
|
1204 |
-
aud1 = gr.Audio(
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1205 |
abetter = gr.Button("A is better", variant='primary', interactive=False)
|
1206 |
prevmodel1 = gr.HTML(show_label=False, value="Vote to reveal model A", visible=False)
|
1207 |
with gr.Column():
|
1208 |
with gr.Group():
|
1209 |
-
aud2 = gr.Audio(
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1210 |
bbetter = gr.Button("B is better", variant='primary', interactive=False)
|
1211 |
prevmodel2 = gr.HTML(show_label=False, value="Vote to reveal model B", visible=False)
|
1212 |
nxtroundbtn = gr.Button('Next round', visible=False)
|
@@ -1247,8 +1274,9 @@ with gr.Blocks() as vote:
|
|
1247 |
cachedt.click(disable, outputs=[cachedt, abetter, bbetter]).then(cachedsent, outputs=[*outputs, cachedt]).then(enable, outputs=[btn, gr.State(), gr.State()])
|
1248 |
|
1249 |
# Allow interaction with the vote buttons only when both audio samples have finished playing
|
1250 |
-
aud1.stop(unlock_vote, outputs=[abetter, bbetter, aplayed, bplayed], inputs=[gr.State(value=0), aplayed, bplayed])
|
1251 |
-
|
|
|
1252 |
|
1253 |
# nxt_outputs = [prevmodel1, prevmodel2, abetter, bbetter]
|
1254 |
nxt_outputs = [abetter, bbetter, prevmodel1, prevmodel2, nxtroundbtn]
|
|
|
194 |
# 'styletts2/styletts2': '0#0', #API disabled
|
195 |
# 'Manmay/tortoise-tts': '/predict#0', #Cannot skip text-from-file parameter
|
196 |
# 'pytorch/Tacotron2': '0#0', #old gradio
|
197 |
+
# 'fishaudio/fish-speech-1': '/inference_wrapper#0', heavy hallucinations
|
198 |
}
|
199 |
|
200 |
# for zero-shot TTS - voice sample of Scarlett Johanson
|
|
|
1054 |
gr.update(visible=True), # r2
|
1055 |
mdl1, # model1
|
1056 |
mdl2, # model2
|
1057 |
+
gr.update(visible=True, value=results[mdl1k], interactive=False, autoplay=True), # aud1
|
1058 |
+
gr.update(visible=True, value=results[mdl2k], interactive=False, autoplay=False), # aud2
|
1059 |
gr.update(visible=True, interactive=False), #abetter
|
1060 |
gr.update(visible=True, interactive=False), #bbetter
|
1061 |
gr.update(visible=False), #prevmodel1
|
|
|
1091 |
# )
|
1092 |
|
1093 |
def unlock_vote(btn_index, aplayed, bplayed):
|
1094 |
+
aud2 = gr.update()
|
1095 |
# sample played
|
1096 |
if btn_index == 0:
|
1097 |
aplayed = True
|
1098 |
+
# autoplay the other once
|
1099 |
+
if not bplayed:
|
1100 |
+
# other options added just to get autoplay to work
|
1101 |
+
aud2 = gr.update(
|
1102 |
+
autoplay=True,
|
1103 |
+
interactive=True,
|
1104 |
+
sources=[],
|
1105 |
+
show_download_button=False,
|
1106 |
+
show_share_button=False,
|
1107 |
+
editable=False
|
1108 |
+
)
|
1109 |
if btn_index == 1:
|
1110 |
bplayed = True
|
1111 |
|
1112 |
# both audio samples played
|
1113 |
if bool(aplayed) and bool(bplayed):
|
1114 |
print('Both audio samples played, voting unlocked')
|
1115 |
+
return [gr.update(interactive=True), gr.update(interactive=True), True, True, aud2]
|
1116 |
|
1117 |
+
return [gr.update(), gr.update(), aplayed, bplayed, aud2]
|
1118 |
|
1119 |
|
1120 |
def cachedsent(request: gr.Request):
|
|
|
1156 |
gr.update(visible=True), # r2
|
1157 |
pair[0].modelName, # model1
|
1158 |
pair[1].modelName, # model2
|
1159 |
+
gr.update(visible=True, value=pair[0].filename, interactive=False, autoplay=True), # aud1
|
1160 |
+
gr.update(visible=True, value=pair[1].filename, interactive=False, autoplay=False), # aud2
|
1161 |
gr.update(visible=True, interactive=False), #abetter
|
1162 |
gr.update(visible=True, interactive=False), #bbetter
|
1163 |
gr.update(visible=False), #prevmodel1
|
|
|
1178 |
gr.update(visible=False), # r2
|
1179 |
'', # model1
|
1180 |
'', # model2
|
1181 |
+
gr.update(visible=False, autoplay=False), # aud1
|
1182 |
+
gr.update(visible=False, autoplay=False), # aud2
|
1183 |
gr.update(visible=False, interactive=False), #abetter
|
1184 |
gr.update(visible=False, interactive=False), #bbetter
|
1185 |
gr.update(visible=False), #prevmodel1
|
|
|
1214 |
with gr.Row(visible=False) as r2:
|
1215 |
with gr.Column():
|
1216 |
with gr.Group():
|
1217 |
+
aud1 = gr.Audio(
|
1218 |
+
interactive=False,
|
1219 |
+
show_label=False,
|
1220 |
+
show_download_button=False,
|
1221 |
+
show_share_button=False,
|
1222 |
+
waveform_options={'waveform_progress_color': '#EF4444'}
|
1223 |
+
# var(--color-red-500)'}); gradio only accepts HEX and CSS color
|
1224 |
+
)
|
1225 |
abetter = gr.Button("A is better", variant='primary', interactive=False)
|
1226 |
prevmodel1 = gr.HTML(show_label=False, value="Vote to reveal model A", visible=False)
|
1227 |
with gr.Column():
|
1228 |
with gr.Group():
|
1229 |
+
aud2 = gr.Audio(
|
1230 |
+
interactive=False,
|
1231 |
+
show_label=False,
|
1232 |
+
show_download_button=False,
|
1233 |
+
show_share_button=False,
|
1234 |
+
waveform_options={'waveform_progress_color': '#3C82F6'}
|
1235 |
+
# var(--secondary-500)'}); gradio only accepts HEX and CSS color
|
1236 |
+
)
|
1237 |
bbetter = gr.Button("B is better", variant='primary', interactive=False)
|
1238 |
prevmodel2 = gr.HTML(show_label=False, value="Vote to reveal model B", visible=False)
|
1239 |
nxtroundbtn = gr.Button('Next round', visible=False)
|
|
|
1274 |
cachedt.click(disable, outputs=[cachedt, abetter, bbetter]).then(cachedsent, outputs=[*outputs, cachedt]).then(enable, outputs=[btn, gr.State(), gr.State()])
|
1275 |
|
1276 |
# Allow interaction with the vote buttons only when both audio samples have finished playing
|
1277 |
+
aud1.stop(unlock_vote, outputs=[abetter, bbetter, aplayed, bplayed, aud2], inputs=[gr.State(value=0), aplayed, bplayed])
|
1278 |
+
# autoplay if unplayed
|
1279 |
+
aud2.stop(unlock_vote, outputs=[abetter, bbetter, aplayed, bplayed, gr.State()], inputs=[gr.State(value=1), aplayed, bplayed])
|
1280 |
|
1281 |
# nxt_outputs = [prevmodel1, prevmodel2, abetter, bbetter]
|
1282 |
nxt_outputs = [abetter, bbetter, prevmodel1, prevmodel2, nxtroundbtn]
|