Spaces:
Sleeping
Sleeping
Niki Zhang
commited on
Update app.py
Browse files
app.py
CHANGED
|
@@ -21,7 +21,7 @@ import easyocr
|
|
| 21 |
import tts
|
| 22 |
|
| 23 |
|
| 24 |
-
|
| 25 |
|
| 26 |
article = """
|
| 27 |
<div style='margin:20px auto;'>
|
|
@@ -112,12 +112,15 @@ def init_openai_api_key(api_key=""):
|
|
| 112 |
print(text_refiner)
|
| 113 |
openai_available = text_refiner is not None
|
| 114 |
if openai_available:
|
| 115 |
-
|
|
|
|
|
|
|
|
|
|
| 116 |
else:
|
| 117 |
return [gr.update(visible=False)]*7 + [gr.update(visible=True)]*2 + [text_refiner, visual_chatgpt, 'Your OpenAI API Key is not available']
|
| 118 |
|
| 119 |
def init_wo_openai_api_key():
|
| 120 |
-
return [gr.update(visible=False)]*4 + [gr.update(visible=True)]+ [gr.update(visible=False)]+[gr.update(visible=True)]+[gr.update(visible=False)]*2 + [None, None, None]
|
| 121 |
|
| 122 |
def get_click_prompt(chat_input, click_state, click_mode):
|
| 123 |
inputs = json.loads(chat_input)
|
|
@@ -494,7 +497,7 @@ def create_ui():
|
|
| 494 |
input_mask_state = gr.State(np.zeros((1, 1)))
|
| 495 |
input_points_state = gr.State([])
|
| 496 |
input_labels_state = gr.State([])
|
| 497 |
-
|
| 498 |
|
| 499 |
gr.Markdown(title)
|
| 500 |
gr.Markdown(description)
|
|
@@ -611,7 +614,7 @@ def create_ui():
|
|
| 611 |
use_mic = gr.Checkbox(label="Check to use Microphone as Reference", value=False)
|
| 612 |
agree = gr.Checkbox(label="Agree", value=True)
|
| 613 |
output_waveform = gr.Video(label="Waveform Visual")
|
| 614 |
-
output_audio = gr.
|
| 615 |
|
| 616 |
with gr.Row():
|
| 617 |
submit_tts = gr.Button(value="Submit", interactive=True)
|
|
@@ -638,11 +641,11 @@ def create_ui():
|
|
| 638 |
|
| 639 |
openai_api_key.submit(init_openai_api_key, inputs=[openai_api_key],
|
| 640 |
outputs=[modules_need_gpt0, modules_need_gpt1, modules_need_gpt2, modules_need_gpt3, modules_not_need_gpt,
|
| 641 |
-
modules_not_need_gpt2, tts_interface,module_key_input ,module_notification_box, text_refiner, visual_chatgpt, notification_box
|
| 642 |
enable_chatGPT_button.click(init_openai_api_key, inputs=[openai_api_key],
|
| 643 |
outputs=[modules_need_gpt0, modules_need_gpt1, modules_need_gpt2, modules_need_gpt3,
|
| 644 |
modules_not_need_gpt,
|
| 645 |
-
modules_not_need_gpt2, tts_interface,module_key_input,module_notification_box, text_refiner, visual_chatgpt, notification_box
|
| 646 |
disable_chatGPT_button.click(init_wo_openai_api_key,
|
| 647 |
outputs=[modules_need_gpt0, modules_need_gpt1, modules_need_gpt2, modules_need_gpt3,
|
| 648 |
modules_not_need_gpt,
|
|
@@ -733,6 +736,7 @@ def create_ui():
|
|
| 733 |
return [gr.update(visible=True)]*2+[gr.update(visible=False)]*2
|
| 734 |
else:
|
| 735 |
print("no gpt")
|
|
|
|
| 736 |
return [gr.update(visible=False)]+[gr.update(visible=True)]+[gr.update(visible=False)]*2
|
| 737 |
|
| 738 |
def on_base_selected():
|
|
@@ -790,12 +794,8 @@ def create_ui():
|
|
| 790 |
show_progress=False, queue=True
|
| 791 |
)
|
| 792 |
|
| 793 |
-
# def update_output_audio():
|
| 794 |
-
# return gr.update(autoplay=True)
|
| 795 |
-
|
| 796 |
-
output_audio.change(update_output_audio,outputs=[output_audio])
|
| 797 |
|
| 798 |
-
|
| 799 |
|
| 800 |
|
| 801 |
return iface
|
|
@@ -804,4 +804,4 @@ def create_ui():
|
|
| 804 |
if __name__ == '__main__':
|
| 805 |
iface = create_ui()
|
| 806 |
iface.queue(concurrency_count=5, api_open=False, max_size=10)
|
| 807 |
-
iface.launch(server_name="0.0.0.0", enable_queue=True)
|
|
|
|
| 21 |
import tts
|
| 22 |
|
| 23 |
|
| 24 |
+
gpt_state = 0
|
| 25 |
|
| 26 |
article = """
|
| 27 |
<div style='margin:20px auto;'>
|
|
|
|
| 112 |
print(text_refiner)
|
| 113 |
openai_available = text_refiner is not None
|
| 114 |
if openai_available:
|
| 115 |
+
|
| 116 |
+
global gpt_state
|
| 117 |
+
gpt_state=1
|
| 118 |
+
return [gr.update(visible=True)]+[gr.update(visible=False)]+[gr.update(visible=True)]*3+[gr.update(visible=False)]+ [gr.update(visible=True)]+ [gr.update(visible=False)]*2 + [text_refiner, visual_chatgpt, None]
|
| 119 |
else:
|
| 120 |
return [gr.update(visible=False)]*7 + [gr.update(visible=True)]*2 + [text_refiner, visual_chatgpt, 'Your OpenAI API Key is not available']
|
| 121 |
|
| 122 |
def init_wo_openai_api_key():
|
| 123 |
+
return [gr.update(visible=False)]*4 + [gr.update(visible=True)]+ [gr.update(visible=False)]+[gr.update(visible=True)]+[gr.update(visible=False)]*2 + [None, None, None]
|
| 124 |
|
| 125 |
def get_click_prompt(chat_input, click_state, click_mode):
|
| 126 |
inputs = json.loads(chat_input)
|
|
|
|
| 497 |
input_mask_state = gr.State(np.zeros((1, 1)))
|
| 498 |
input_points_state = gr.State([])
|
| 499 |
input_labels_state = gr.State([])
|
| 500 |
+
|
| 501 |
|
| 502 |
gr.Markdown(title)
|
| 503 |
gr.Markdown(description)
|
|
|
|
| 614 |
use_mic = gr.Checkbox(label="Check to use Microphone as Reference", value=False)
|
| 615 |
agree = gr.Checkbox(label="Agree", value=True)
|
| 616 |
output_waveform = gr.Video(label="Waveform Visual")
|
| 617 |
+
output_audio = gr.HTML(label="Synthesised Audio")
|
| 618 |
|
| 619 |
with gr.Row():
|
| 620 |
submit_tts = gr.Button(value="Submit", interactive=True)
|
|
|
|
| 641 |
|
| 642 |
openai_api_key.submit(init_openai_api_key, inputs=[openai_api_key],
|
| 643 |
outputs=[modules_need_gpt0, modules_need_gpt1, modules_need_gpt2, modules_need_gpt3, modules_not_need_gpt,
|
| 644 |
+
modules_not_need_gpt2, tts_interface,module_key_input ,module_notification_box, text_refiner, visual_chatgpt, notification_box])
|
| 645 |
enable_chatGPT_button.click(init_openai_api_key, inputs=[openai_api_key],
|
| 646 |
outputs=[modules_need_gpt0, modules_need_gpt1, modules_need_gpt2, modules_need_gpt3,
|
| 647 |
modules_not_need_gpt,
|
| 648 |
+
modules_not_need_gpt2, tts_interface,module_key_input,module_notification_box, text_refiner, visual_chatgpt, notification_box])
|
| 649 |
disable_chatGPT_button.click(init_wo_openai_api_key,
|
| 650 |
outputs=[modules_need_gpt0, modules_need_gpt1, modules_need_gpt2, modules_need_gpt3,
|
| 651 |
modules_not_need_gpt,
|
|
|
|
| 736 |
return [gr.update(visible=True)]*2+[gr.update(visible=False)]*2
|
| 737 |
else:
|
| 738 |
print("no gpt")
|
| 739 |
+
print("gpt_state",gpt_state)
|
| 740 |
return [gr.update(visible=False)]+[gr.update(visible=True)]+[gr.update(visible=False)]*2
|
| 741 |
|
| 742 |
def on_base_selected():
|
|
|
|
| 794 |
show_progress=False, queue=True
|
| 795 |
)
|
| 796 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 797 |
|
| 798 |
+
|
| 799 |
|
| 800 |
|
| 801 |
return iface
|
|
|
|
| 804 |
if __name__ == '__main__':
|
| 805 |
iface = create_ui()
|
| 806 |
iface.queue(concurrency_count=5, api_open=False, max_size=10)
|
| 807 |
+
iface.launch(server_name="0.0.0.0", enable_queue=True)
|