ankban commited on
Commit
96fa1dc
·
verified ·
1 Parent(s): 981c6f0

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +8 -2
app.py CHANGED
@@ -5,6 +5,7 @@ import whisper
5
  from gtts import gTTS
6
  import subprocess
7
  import openai
 
8
 
9
  # Use writable cache for Hugging Face
10
  os.environ["XDG_CACHE_HOME"] = "/tmp/.cache"
@@ -43,9 +44,12 @@ def convert_to_wav(input_file):
43
  return output_wav
44
 
45
  # Call GPT to analyze transcript
 
 
46
  def generate_feedback_with_llm(transcript):
47
  prompt = PROMPT_TEMPLATE.format(transcript=transcript.strip())
48
- response = openai.ChatCompletion.create(
 
49
  model="gpt-3.5-turbo",
50
  temperature=0.7,
51
  messages=[
@@ -53,7 +57,9 @@ def generate_feedback_with_llm(transcript):
53
  {"role": "user", "content": prompt}
54
  ]
55
  )
56
- return response.choices[0].message["content"]
 
 
57
 
58
  # Main function
59
  def tutor_feedback(audio_file):
 
5
  from gtts import gTTS
6
  import subprocess
7
  import openai
8
+ from openai import OpenAI
9
 
10
  # Use writable cache for Hugging Face
11
  os.environ["XDG_CACHE_HOME"] = "/tmp/.cache"
 
44
  return output_wav
45
 
46
  # Call GPT to analyze transcript
47
+ client = OpenAI(api_key=os.getenv("OPENAI_API_KEY"))
48
+
49
  def generate_feedback_with_llm(transcript):
50
  prompt = PROMPT_TEMPLATE.format(transcript=transcript.strip())
51
+
52
+ response = client.chat.completions.create(
53
  model="gpt-3.5-turbo",
54
  temperature=0.7,
55
  messages=[
 
57
  {"role": "user", "content": prompt}
58
  ]
59
  )
60
+
61
+ return response.choices[0].message.content
62
+
63
 
64
  # Main function
65
  def tutor_feedback(audio_file):