Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -1,4 +1,4 @@
|
|
1 |
-
import
|
2 |
import gradio as gr
|
3 |
import os, json
|
4 |
from loguru import logger
|
@@ -24,7 +24,7 @@ translate_token_id = all_special_ids[-6]
|
|
24 |
def get_api():
|
25 |
api = None
|
26 |
try:
|
27 |
-
api =
|
28 |
# api.refresh_auth()
|
29 |
except:
|
30 |
api = None
|
@@ -144,14 +144,14 @@ start_work = """async() => {
|
|
144 |
}"""
|
145 |
|
146 |
|
147 |
-
with gr.Blocks(title='Talk to
|
148 |
-
gr.Markdown("## Talk to
|
149 |
gr.HTML("<p>You can duplicate this space and use your own session token: <a style='display:inline-block' href='https://huggingface.co/spaces/yizhangliu/chatGPT?duplicate=true'><img src='https://img.shields.io/badge/-Duplicate%20Space-blue?labelColor=white&style=flat&logo=data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAAP5JREFUOE+lk7FqAkEURY+ltunEgFXS2sZGIbXfEPdLlnxJyDdYB62sbbUKpLbVNhyYFzbrrA74YJlh9r079973psed0cvUD4A+4HoCjsA85X0Dfn/RBLBgBDxnQPfAEJgBY+A9gALA4tcbamSzS4xq4FOQAJgCDwV2CPKV8tZAJcAjMMkUe1vX+U+SMhfAJEHasQIWmXNN3abzDwHUrgcRGmYcgKe0bxrblHEB4E/pndMazNpSZGcsZdBlYJcEL9Afo75molJyM2FxmPgmgPqlWNLGfwZGG6UiyEvLzHYDmoPkDDiNm9JR9uboiONcBXrpY1qmgs21x1QwyZcpvxt9NS09PlsPAAAAAElFTkSuQmCC&logoWidth=14' alt='Duplicate Space'></a></p>")
|
150 |
gr.HTML("<p> Instruction on how to get session token can be seen in video <a style='display:inline-block' href='https://www.youtube.com/watch?v=TdNSj_qgdFk'><font style='color:blue;weight:bold;'>here</font></a>. Add your session token by going to settings and add under secrets. </p>")
|
151 |
with gr.Group(elem_id="page_1", visible=True) as page_1:
|
152 |
with gr.Box():
|
153 |
with gr.Row():
|
154 |
-
start_button = gr.Button("Let's talk to
|
155 |
start_button.click(fn=None, inputs=[], outputs=[], _js=start_work)
|
156 |
|
157 |
with gr.Group(elem_id="page_2", visible=False) as page_2:
|
@@ -176,6 +176,8 @@ with gr.Blocks(title='Talk to AI-DHD') as demo:
|
|
176 |
rounded=(True, True, True, True),
|
177 |
width=100
|
178 |
)
|
|
|
|
|
179 |
|
180 |
translate_btn.click(fn=translate_or_transcribe,
|
181 |
inputs=[prompt_input_audio,whisper_task],
|
@@ -187,5 +189,13 @@ with gr.Blocks(title='Talk to AI-DHD') as demo:
|
|
187 |
inputs=[api,prompt_input, chat_history],
|
188 |
outputs=[api,chatbot, chat_history],
|
189 |
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
190 |
|
191 |
demo.launch(debug = True)
|
|
|
1 |
+
from pyChatGPT import ChatGPT
|
2 |
import gradio as gr
|
3 |
import os, json
|
4 |
from loguru import logger
|
|
|
24 |
def get_api():
|
25 |
api = None
|
26 |
try:
|
27 |
+
api = ChatGPT(session_token)
|
28 |
# api.refresh_auth()
|
29 |
except:
|
30 |
api = None
|
|
|
144 |
}"""
|
145 |
|
146 |
|
147 |
+
with gr.Blocks(title='Talk to chatGPT') as demo:
|
148 |
+
gr.Markdown("## Talk to chatGPT with your voice in your native language ! ##")
|
149 |
gr.HTML("<p>You can duplicate this space and use your own session token: <a style='display:inline-block' href='https://huggingface.co/spaces/yizhangliu/chatGPT?duplicate=true'><img src='https://img.shields.io/badge/-Duplicate%20Space-blue?labelColor=white&style=flat&logo=data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAAP5JREFUOE+lk7FqAkEURY+ltunEgFXS2sZGIbXfEPdLlnxJyDdYB62sbbUKpLbVNhyYFzbrrA74YJlh9r079973psed0cvUD4A+4HoCjsA85X0Dfn/RBLBgBDxnQPfAEJgBY+A9gALA4tcbamSzS4xq4FOQAJgCDwV2CPKV8tZAJcAjMMkUe1vX+U+SMhfAJEHasQIWmXNN3abzDwHUrgcRGmYcgKe0bxrblHEB4E/pndMazNpSZGcsZdBlYJcEL9Afo75molJyM2FxmPgmgPqlWNLGfwZGG6UiyEvLzHYDmoPkDDiNm9JR9uboiONcBXrpY1qmgs21x1QwyZcpvxt9NS09PlsPAAAAAElFTkSuQmCC&logoWidth=14' alt='Duplicate Space'></a></p>")
|
150 |
gr.HTML("<p> Instruction on how to get session token can be seen in video <a style='display:inline-block' href='https://www.youtube.com/watch?v=TdNSj_qgdFk'><font style='color:blue;weight:bold;'>here</font></a>. Add your session token by going to settings and add under secrets. </p>")
|
151 |
with gr.Group(elem_id="page_1", visible=True) as page_1:
|
152 |
with gr.Box():
|
153 |
with gr.Row():
|
154 |
+
start_button = gr.Button("Let's talk to chatGPT!", elem_id="start-btn", visible=True)
|
155 |
start_button.click(fn=None, inputs=[], outputs=[], _js=start_work)
|
156 |
|
157 |
with gr.Group(elem_id="page_2", visible=False) as page_2:
|
|
|
176 |
rounded=(True, True, True, True),
|
177 |
width=100
|
178 |
)
|
179 |
+
|
180 |
+
|
181 |
|
182 |
translate_btn.click(fn=translate_or_transcribe,
|
183 |
inputs=[prompt_input_audio,whisper_task],
|
|
|
189 |
inputs=[api,prompt_input, chat_history],
|
190 |
outputs=[api,chatbot, chat_history],
|
191 |
)
|
192 |
+
gr.HTML('''
|
193 |
+
<p>Note: Please be aware that audio records from iOS devices will not be decoded as expected by Gradio. For the best experience, record your voice from a computer instead of your smartphone ;)</p>
|
194 |
+
<div class="footer">
|
195 |
+
<p>Whisper Model by <a href="https://github.com/openai/whisper" style="text-decoration: underline;" target="_blank">OpenAI</a> -
|
196 |
+
<a href="https://chat.openai.com/chat" target="_blank">chatGPT</a> by <a href="https://openai.com/" style="text-decoration: underline;" target="_blank">OpenAI</a>
|
197 |
+
</p>
|
198 |
+
</div>
|
199 |
+
''')
|
200 |
|
201 |
demo.launch(debug = True)
|