Update app.py
Browse files
app.py
CHANGED
@@ -27,7 +27,7 @@ def infer(audio, openai_api_key):
|
|
27 |
|
28 |
portrait_link = talking_face("wise_woman_portrait.png", audio_response, fn_index=0)
|
29 |
|
30 |
-
return gr.Textbox.update(value=whisper_result, visible=True), portrait_link, gr.Textbox.update(value=gpt_response[1], visible=True), gr.update(visible=True), gr.update(visible=True)
|
31 |
|
32 |
def try_api(message, openai_api_key):
|
33 |
|
@@ -82,7 +82,7 @@ def call_api(message, openai_api_key):
|
|
82 |
return str(response.choices[0].text).split("\n",2)[2]
|
83 |
|
84 |
def clean_components():
|
85 |
-
return gr.Audio.update(value=None), gr.HTML.update(visible=False), gr.Textbox.update(visible=False), gr.update(visible=False)
|
86 |
|
87 |
title = """
|
88 |
<div style="text-align: center; max-width: 500px; margin: 0 auto;">
|
@@ -122,14 +122,15 @@ with gr.Blocks(css="style.css") as demo:
|
|
122 |
error_handler = gr.HTML(visible=False, show_label=False, elem_id="error_handler")
|
123 |
|
124 |
with gr.Column(elem_id="col-container-2"):
|
125 |
-
with gr.
|
126 |
-
|
127 |
-
|
|
|
128 |
with gr.Row():
|
129 |
clean_btn = gr.Button(value="Clean", visible=False)
|
130 |
send_btn = gr.Button("Send my request !")
|
131 |
|
132 |
-
clean_btn.click(clean_components, inputs=[], outputs=[record_input, error_handler, whisper_tr, clean_btn])
|
133 |
send_btn.click(infer, inputs=[record_input, openai_api_key], outputs=[whisper_tr, gpt_response, error_handler, share_group, clean_btn])
|
134 |
share_button.click(None, [], [], _js=share_js)
|
135 |
|
|
|
27 |
|
28 |
portrait_link = talking_face("wise_woman_portrait.png", audio_response, fn_index=0)
|
29 |
|
30 |
+
return gr.Textbox.update(value=whisper_result, visible=True), portrait_link, gr.Textbox.update(value=gpt_response[1], visible=True), gr.update(visible=True), gr.Button.update(visible=True)
|
31 |
|
32 |
def try_api(message, openai_api_key):
|
33 |
|
|
|
82 |
return str(response.choices[0].text).split("\n",2)[2]
|
83 |
|
84 |
def clean_components():
|
85 |
+
return gr.Audio.update(value=None), gr.HTML.update(visible=False), gr.Textbox.update(visible=False), gr.Video.update(value=None), gr.Button.update(visible=False)
|
86 |
|
87 |
title = """
|
88 |
<div style="text-align: center; max-width: 500px; margin: 0 auto;">
|
|
|
122 |
error_handler = gr.HTML(visible=False, show_label=False, elem_id="error_handler")
|
123 |
|
124 |
with gr.Column(elem_id="col-container-2"):
|
125 |
+
with gr.Group():
|
126 |
+
with gr.Row():
|
127 |
+
record_input = gr.Audio(source="microphone",type="filepath", label="Audio input", show_label=True, elem_id="record_btn")
|
128 |
+
openai_api_key = gr.Textbox(max_lines=1, type="password", label="Your OpenAI API Key", placeholder="sk-123abc...")
|
129 |
with gr.Row():
|
130 |
clean_btn = gr.Button(value="Clean", visible=False)
|
131 |
send_btn = gr.Button("Send my request !")
|
132 |
|
133 |
+
clean_btn.click(clean_components, inputs=[], outputs=[record_input, error_handler, whisper_tr, gpt_response, clean_btn])
|
134 |
send_btn.click(infer, inputs=[record_input, openai_api_key], outputs=[whisper_tr, gpt_response, error_handler, share_group, clean_btn])
|
135 |
share_button.click(None, [], [], _js=share_js)
|
136 |
|