heliosbrahma commited on
Commit
252bb6e
·
1 Parent(s): d2f1c12

Update main.py

Browse files
Files changed (1) hide show
  1. main.py +4 -5
main.py CHANGED
@@ -4,6 +4,7 @@ import openai
4
  from TTS.api import TTS
5
  import subprocess
6
 
 
7
  model_name = TTS.list_models()[9]
8
  tts = TTS(model_name)
9
  model = whisper.load_model('medium')
@@ -14,8 +15,8 @@ def run_ffmpeg_command():
14
  print(result.stdout)
15
 
16
 
17
- def voice_chat(api_key, user_voice):
18
- openai.api_key = str(api_key)
19
  messages = [
20
  {"role": "system", "content": "You are a kind helpful assistant."},
21
  ]
@@ -42,9 +43,7 @@ gr.Interface(
42
  Just communicate your queries in speech format and this app will take care of the rest.',
43
  fn=voice_chat,
44
  inputs=[
45
- gr.Textbox(label="OpenAI API Key"),
46
- gr.Audio(source="microphone", label="Input Voice", type="filepath")
47
-
48
  ],
49
  outputs=[
50
  gr.Textbox(label="Summarized Answer"),
 
4
  from TTS.api import TTS
5
  import subprocess
6
 
7
+ OPENAI_API_KEY = os.environ.get("OPENAI_API_KEY")
8
  model_name = TTS.list_models()[9]
9
  tts = TTS(model_name)
10
  model = whisper.load_model('medium')
 
15
  print(result.stdout)
16
 
17
 
18
+ def voice_chat(user_voice):
19
+ openai.api_key = OPENAI_API_KEY
20
  messages = [
21
  {"role": "system", "content": "You are a kind helpful assistant."},
22
  ]
 
43
  Just communicate your queries in speech format and this app will take care of the rest.',
44
  fn=voice_chat,
45
  inputs=[
46
+ gr.Audio(source="microphone", label="Input Voice", type="filepath")
 
 
47
  ],
48
  outputs=[
49
  gr.Textbox(label="Summarized Answer"),