Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -196,82 +196,54 @@ def natural_vote1_last_response(
|
|
196 |
request: gr.Request
|
197 |
):
|
198 |
print(f"Very Natural (voted). ip: {get_ip(request)}")
|
199 |
-
|
200 |
-
"Very Natural", request
|
201 |
-
)
|
202 |
-
return (disable_btn,) * 4
|
203 |
|
204 |
def natural_vote2_last_response(
|
205 |
request: gr.Request
|
206 |
):
|
207 |
print(f"Somewhat Awkward (voted). ip: {get_ip(request)}")
|
208 |
-
|
209 |
-
"Somewhat Awkward", request
|
210 |
-
)
|
211 |
-
return (disable_btn,) * 4
|
212 |
|
213 |
def natural_vote3_last_response(
|
214 |
request: gr.Request
|
215 |
):
|
216 |
print(f"Very Awkward (voted). ip: {get_ip(request)}")
|
217 |
-
|
218 |
-
"Very Awkward", request
|
219 |
-
)
|
220 |
-
return (disable_btn,) * 4
|
221 |
|
222 |
def natural_vote4_last_response(
|
223 |
request: gr.Request
|
224 |
):
|
225 |
print(f"Unnatural (voted). ip: {get_ip(request)}")
|
226 |
-
|
227 |
-
"Unnatural", request
|
228 |
-
)
|
229 |
-
return (disable_btn,) * 4
|
230 |
|
231 |
def relevant_vote1_last_response(
|
232 |
request: gr.Request
|
233 |
):
|
234 |
print(f"Highly Relevant (voted). ip: {get_ip(request)}")
|
235 |
-
|
236 |
-
"Highly Relevant", request
|
237 |
-
)
|
238 |
-
return (disable_btn,) * 4
|
239 |
|
240 |
def relevant_vote2_last_response(
|
241 |
request: gr.Request
|
242 |
):
|
243 |
print(f"Partially Relevant (voted). ip: {get_ip(request)}")
|
244 |
-
|
245 |
-
"Partially Relevant", request
|
246 |
-
)
|
247 |
-
return (disable_btn,) * 4
|
248 |
|
249 |
def relevant_vote3_last_response(
|
250 |
request: gr.Request
|
251 |
):
|
252 |
print(f"Slightly Irrelevant (voted). ip: {get_ip(request)}")
|
253 |
-
|
254 |
-
"Slightly Irrelevant", request
|
255 |
-
)
|
256 |
-
return (disable_btn,) * 4
|
257 |
|
258 |
def relevant_vote4_last_response(
|
259 |
request: gr.Request
|
260 |
):
|
261 |
print(f"Completely Irrelevant (voted). ip: {get_ip(request)}")
|
262 |
-
|
263 |
-
"Completely Irrelevant", request
|
264 |
-
)
|
265 |
-
return (disable_btn,) * 4
|
266 |
|
267 |
import json
|
268 |
import time
|
269 |
|
270 |
-
|
271 |
-
print("file error")
|
272 |
-
with open("save_dict.json", 'w') as f:
|
273 |
-
json.dump([], f)
|
274 |
-
print(os.path.abspath("save_dict.json"))
|
275 |
def transcribe(stream, new_chunk):
|
276 |
sr, y = new_chunk
|
277 |
global text_str
|
@@ -397,7 +369,7 @@ with gr.Blocks(
|
|
397 |
state = gr.State()
|
398 |
with gr.Row():
|
399 |
feedback_btn = gr.Button(
|
400 |
-
value="Please
|
401 |
)
|
402 |
with gr.Row():
|
403 |
natural_btn1 = gr.Button(
|
@@ -443,18 +415,21 @@ with gr.Blocks(
|
|
443 |
relevant_btn3,
|
444 |
relevant_btn4,
|
445 |
]
|
446 |
-
|
|
|
|
|
|
|
447 |
output_audio.play(
|
448 |
flash_buttons, [], btn_list
|
449 |
)
|
450 |
-
natural_btn1.click(natural_vote1_last_response,[],natural_btn_list)
|
451 |
-
natural_btn2.click(natural_vote2_last_response,[],natural_btn_list)
|
452 |
-
natural_btn3.click(natural_vote3_last_response,[],natural_btn_list)
|
453 |
-
natural_btn4.click(natural_vote4_last_response,[],natural_btn_list)
|
454 |
-
relevant_btn1.click(relevant_vote1_last_response,[],relevant_btn_list)
|
455 |
-
relevant_btn2.click(relevant_vote2_last_response,[],relevant_btn_list)
|
456 |
-
relevant_btn3.click(relevant_vote3_last_response,[],relevant_btn_list)
|
457 |
-
relevant_btn4.click(relevant_vote4_last_response,[],relevant_btn_list)
|
458 |
# with demo:
|
459 |
# start_button = gr.Button("Record Screen 🔴")
|
460 |
# video_component = gr.Video(interactive=True, show_share_button=True, include_audio=True)
|
|
|
196 |
request: gr.Request
|
197 |
):
|
198 |
print(f"Very Natural (voted). ip: {get_ip(request)}")
|
199 |
+
return ("Very Natural",)+(disable_btn,) * 4
|
|
|
|
|
|
|
200 |
|
201 |
def natural_vote2_last_response(
|
202 |
request: gr.Request
|
203 |
):
|
204 |
print(f"Somewhat Awkward (voted). ip: {get_ip(request)}")
|
205 |
+
return ("Somewhat Awkward",)+(disable_btn,) * 4
|
|
|
|
|
|
|
206 |
|
207 |
def natural_vote3_last_response(
|
208 |
request: gr.Request
|
209 |
):
|
210 |
print(f"Very Awkward (voted). ip: {get_ip(request)}")
|
211 |
+
return ("Very Awkward",)+(disable_btn,) * 4
|
|
|
|
|
|
|
212 |
|
213 |
def natural_vote4_last_response(
|
214 |
request: gr.Request
|
215 |
):
|
216 |
print(f"Unnatural (voted). ip: {get_ip(request)}")
|
217 |
+
return ("Unnatural",)+(disable_btn,) * 4
|
|
|
|
|
|
|
218 |
|
219 |
def relevant_vote1_last_response(
|
220 |
request: gr.Request
|
221 |
):
|
222 |
print(f"Highly Relevant (voted). ip: {get_ip(request)}")
|
223 |
+
return ("Highly Relevant",)+(disable_btn,) * 4
|
|
|
|
|
|
|
224 |
|
225 |
def relevant_vote2_last_response(
|
226 |
request: gr.Request
|
227 |
):
|
228 |
print(f"Partially Relevant (voted). ip: {get_ip(request)}")
|
229 |
+
return ("Partially Relevant",)+(disable_btn,) * 4
|
|
|
|
|
|
|
230 |
|
231 |
def relevant_vote3_last_response(
|
232 |
request: gr.Request
|
233 |
):
|
234 |
print(f"Slightly Irrelevant (voted). ip: {get_ip(request)}")
|
235 |
+
return ("Slightly Irrelevant",)+(disable_btn,) * 4
|
|
|
|
|
|
|
236 |
|
237 |
def relevant_vote4_last_response(
|
238 |
request: gr.Request
|
239 |
):
|
240 |
print(f"Completely Irrelevant (voted). ip: {get_ip(request)}")
|
241 |
+
return ("Completely Irrelevant",)+(disable_btn,) * 4
|
|
|
|
|
|
|
242 |
|
243 |
import json
|
244 |
import time
|
245 |
|
246 |
+
|
|
|
|
|
|
|
|
|
247 |
def transcribe(stream, new_chunk):
|
248 |
sr, y = new_chunk
|
249 |
global text_str
|
|
|
369 |
state = gr.State()
|
370 |
with gr.Row():
|
371 |
feedback_btn = gr.Button(
|
372 |
+
value="Please provide your feedback after each system response below.", visible=True, interactive=False, elem_id="button"
|
373 |
)
|
374 |
with gr.Row():
|
375 |
natural_btn1 = gr.Button(
|
|
|
415 |
relevant_btn3,
|
416 |
relevant_btn4,
|
417 |
]
|
418 |
+
natural_response = gr.Textbox(label="natural_response",visible=False,interactive=False)
|
419 |
+
diversity_response = gr.Textbox(label="diversity_response",visible=False,interactive=False)
|
420 |
+
callback.setup([user_audio, output_asr_text, output_text, output_audio,natural_response,diversity_response],"flagged_data_points")
|
421 |
+
user_audio.stream(transcribe, inputs=[state, user_audio], outputs=[state, output_asr_text, output_text, output_audio]).then(lambda *args: callback.flag(list(args)),[user_audio,output_asr_text, output_text, output_audio], None,preprocess=False)
|
422 |
output_audio.play(
|
423 |
flash_buttons, [], btn_list
|
424 |
)
|
425 |
+
natural_btn1.click(natural_vote1_last_response,[], outputs=[natural_response]+natural_btn_list).then(lambda *args: callback.flag(list(args)),[natural_response], None,preprocess=False)
|
426 |
+
natural_btn2.click(natural_vote2_last_response,[],[natural_response]+natural_btn_list).then(lambda *args: callback.flag(list(args)),[natural_response], None,preprocess=False)
|
427 |
+
natural_btn3.click(natural_vote3_last_response,[],[natural_response]+natural_btn_list).then(lambda *args: callback.flag(list(args)),natural_response, None,preprocess=False)
|
428 |
+
natural_btn4.click(natural_vote4_last_response,[],[natural_response]+natural_btn_list).then(lambda *args: callback.flag(list(args)),[natural_response], None,preprocess=False)
|
429 |
+
relevant_btn1.click(relevant_vote1_last_response,[],[diversity_response]+relevant_btn_list).then(lambda *args: callback.flag(list(args)),[diversity_response], None,preprocess=False)
|
430 |
+
relevant_btn2.click(relevant_vote2_last_response,[],[diversity_response]+relevant_btn_list).then(lambda *args: callback.flag(list(args)),[diversity_response], None,preprocess=False)
|
431 |
+
relevant_btn3.click(relevant_vote3_last_response,[],[diversity_response]+relevant_btn_list).then(lambda *args: callback.flag(list(args)),[diversity_response], None,preprocess=False)
|
432 |
+
relevant_btn4.click(relevant_vote4_last_response,[],[diversity_response]+relevant_btn_list).then(lambda *args: callback.flag(list(args)),[diversity_response], None,preprocess=False)
|
433 |
# with demo:
|
434 |
# start_button = gr.Button("Record Screen 🔴")
|
435 |
# video_component = gr.Video(interactive=True, show_share_button=True, include_audio=True)
|