hyuan5040 commited on
Commit
5ea5efd
1 Parent(s): da8a0d7

add openai

Browse files
Files changed (1) hide show
  1. app.py +23 -0
app.py CHANGED
@@ -1,6 +1,26 @@
1
  import tempfile
2
  import gradio as gr
 
3
  from neon_tts_plugin_coqui import CoquiTTS
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
4
  LANGUAGES = list(CoquiTTS.langs.keys())
5
  default_lang = "en"
6
  import telnetlib
@@ -77,6 +97,9 @@ def chat_hf(audio, custom_token, language):
77
  #api.refresh_auth() # refresh the authorization token
78
  #api.reset_conversation() # reset the conversation
79
  #gpt_response = resp['message']
 
 
 
80
 
81
  # to voice
82
  with tempfile.NamedTemporaryFile(suffix=".wav", delete=False) as fp:
 
1
  import tempfile
2
  import gradio as gr
3
+ import openai
4
  from neon_tts_plugin_coqui import CoquiTTS
5
+
6
+ def Question(Ask_Question):
7
+ # pass the generated text to audio
8
+ openai.api_key = "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"
9
+ # Set up the model and prompt
10
+ model_engine = "text-davinci-003"
11
+ #prompt = "who is alon musk?"
12
+ # Generate a response
13
+ completion = openai.Completion.create(
14
+ engine=model_engine,
15
+ prompt=Ask_Question,
16
+ max_tokens=1024,
17
+ n=1,
18
+ stop=None,
19
+ temperature=0.5,)
20
+ response = completion.choices[0].text
21
+ #out_result=resp['message']
22
+ return response
23
+
24
  LANGUAGES = list(CoquiTTS.langs.keys())
25
  default_lang = "en"
26
  import telnetlib
 
97
  #api.refresh_auth() # refresh the authorization token
98
  #api.reset_conversation() # reset the conversation
99
  #gpt_response = resp['message']
100
+
101
+ ## call openai
102
+ gpt_response = Question(whisper_text)
103
 
104
  # to voice
105
  with tempfile.NamedTemporaryFile(suffix=".wav", delete=False) as fp: