divakaivan commited on
Commit
1ede7b6
·
verified ·
1 Parent(s): c60aeeb

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +7 -6
app.py CHANGED
@@ -1,7 +1,8 @@
1
  from transformers import pipeline
2
  import gradio as gr
3
  from gtts import gTTS
4
- import openai
 
5
 
6
  # Load the Whisper model for speech-to-text
7
  pipe = pipeline(model="openai/whisper-small")
@@ -10,12 +11,12 @@ pipe = pipeline(model="openai/whisper-small")
10
  # text_pipe = pipeline("text2text-generation", model="google/flan-t5-base")
11
 
12
  def generate_gpt_response(text):
13
- response = openai.Completion.create(
14
- engine="text-davinci-003", # Use the appropriate GPT-3 engine
15
- prompt=text,
16
- max_tokens=150
17
  )
18
- return response.choices[0].text.strip()
 
19
 
20
  def transcribe(audio):
21
  # Transcribe the audio to text
 
1
  from transformers import pipeline
2
  import gradio as gr
3
  from gtts import gTTS
4
+ from openai import OpenAI
5
+ client = OpenAI()
6
 
7
  # Load the Whisper model for speech-to-text
8
  pipe = pipeline(model="openai/whisper-small")
 
11
  # text_pipe = pipeline("text2text-generation", model="google/flan-t5-base")
12
 
13
  def generate_gpt_response(text):
14
+ response = client.chat.completions.create(
15
+ model='gpt-3.5-turbo-0125',
16
+ messages=[{"role": "user", "content": text}]
 
17
  )
18
+
19
+ return response.choices[0].message.content
20
 
21
  def transcribe(audio):
22
  # Transcribe the audio to text