AI-DHD commited on
Commit
d23ccd7
·
1 Parent(s): 0d26762

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +1 -13
app.py CHANGED
@@ -21,14 +21,7 @@ all_special_ids = whisper_model.tokenizer.all_special_ids
21
  transcribe_token_id = all_special_ids[-5]
22
  translate_token_id = all_special_ids[-6]
23
 
24
- def get_api():
25
- api = None
26
- try:
27
- api = ChatGPT(session_token)
28
- # api.refresh_auth()
29
- except:
30
- api = None
31
- return api
32
 
33
  def translate_or_transcribe(audio, task):
34
  whisper_model.model.config.forced_decoder_ids = [[2, transcribe_token_id if task=="Transcribe in Spoken Language" else translate_token_id]]
@@ -36,9 +29,6 @@ def translate_or_transcribe(audio, task):
36
  return text
37
 
38
  def get_response_from_chatbot(api,text):
39
- if api is None:
40
- return "Sorry, the chatGPT API has some issues. Please try again later"
41
- try:
42
  resp = api.send_message(text)
43
  api.refresh_auth()
44
  # api.reset_conversation()
@@ -146,8 +136,6 @@ start_work = """async() => {
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():
 
21
  transcribe_token_id = all_special_ids[-5]
22
  translate_token_id = all_special_ids[-6]
23
 
24
+ api = ChatGPT(session_token)
 
 
 
 
 
 
 
25
 
26
  def translate_or_transcribe(audio, task):
27
  whisper_model.model.config.forced_decoder_ids = [[2, transcribe_token_id if task=="Transcribe in Spoken Language" else translate_token_id]]
 
29
  return text
30
 
31
  def get_response_from_chatbot(api,text):
 
 
 
32
  resp = api.send_message(text)
33
  api.refresh_auth()
34
  # api.reset_conversation()
 
136
 
137
  with gr.Blocks(title='Talk to chatGPT') as demo:
138
  gr.Markdown("## Talk to chatGPT with your voice in your native language ! ##")
 
 
139
  with gr.Group(elem_id="page_1", visible=True) as page_1:
140
  with gr.Box():
141
  with gr.Row():