Roland Ding commited on
Commit
175ac78
1 Parent(s): 9080e6d

Remove share =True in app.launch in app.py given

Browse files

the share=True is not used in any of the testing and deployment phases.
change the translation function to transcript to allow the communication
to stay in the same language.

Files changed (2) hide show
  1. app.py +1 -2
  2. supplier.py +6 -4
app.py CHANGED
@@ -32,7 +32,7 @@ with gr.Blocks() as chat_window:
32
  gr.Examples(BASE_SAMPLES,msg,label="Examples")
33
  audio = gr.Audio(sources="microphone",type="filepath")
34
 
35
- audio.change(translate,audio,msg,queue=False)
36
  msg.submit(send_chat,[msg,chatbot],[msg,chatbot])
37
  submit.click(send_chat,[msg,chatbot],[msg,chatbot],queue=False)
38
 
@@ -49,5 +49,4 @@ if __name__ == "__main__":
49
  auth=[ ("admin","hello world"),
50
  ("guest","p@55word")],
51
  server_port=8000,
52
- share=True,
53
  )
 
32
  gr.Examples(BASE_SAMPLES,msg,label="Examples")
33
  audio = gr.Audio(sources="microphone",type="filepath")
34
 
35
+ audio.change(transcript,audio,msg,queue=False)
36
  msg.submit(send_chat,[msg,chatbot],[msg,chatbot])
37
  submit.click(send_chat,[msg,chatbot],[msg,chatbot],queue=False)
38
 
 
49
  auth=[ ("admin","hello world"),
50
  ("guest","p@55word")],
51
  server_port=8000,
 
52
  )
supplier.py CHANGED
@@ -83,12 +83,14 @@ def run_tool(tool_call):
83
 
84
  return result
85
 
86
- def translate(file_path):
87
  if file_path:
88
  f = open(file_path,"rb")
89
- res = OPENAI_CLIENT.audio.translations.create(
90
  file=f,
91
- model="whisper-1")
 
 
92
  return res.text
93
  else:
94
  return ""
@@ -99,7 +101,7 @@ def text_to_audio(chat_messages):
99
  model="tts-1",
100
  voice=App_state["voice"],
101
  input=text,
102
-
103
  )
104
 
105
  return response.content
 
83
 
84
  return result
85
 
86
+ def transcript(file_path):
87
  if file_path:
88
  f = open(file_path,"rb")
89
+ res = OPENAI_CLIENT.audio.transcriptions.create(
90
  file=f,
91
+ model="whisper-1",
92
+ response_format='verbose_json'
93
+ )
94
  return res.text
95
  else:
96
  return ""
 
101
  model="tts-1",
102
  voice=App_state["voice"],
103
  input=text,
104
+
105
  )
106
 
107
  return response.content