Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -23,9 +23,24 @@ def predict(question_choice, audio):
|
|
23 |
# Generate the system message based on the chosen question
|
24 |
strategy, explanation = HongWenData.strategy_text["TREES"]
|
25 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
26 |
# Reference to the picture description from HongWenData.py
|
27 |
picture_description = HongWenData.description
|
28 |
|
|
|
|
|
|
|
|
|
|
|
|
|
29 |
# Construct the conversation with the system and user's message
|
30 |
conversation = [
|
31 |
{
|
@@ -33,8 +48,7 @@ def predict(question_choice, audio):
|
|
33 |
"content": f"""
|
34 |
You are an expert English Language Teacher in a Singapore Primary school, directly guiding a Primary 6 student in Singapore.
|
35 |
The student is answering the question: '{question_choice}'.
|
36 |
-
|
37 |
-
{picture_description}
|
38 |
Point out areas they did well and where they can improve, following the {strategy}.
|
39 |
Encourage the use of sophisticated vocabulary and expressions.
|
40 |
For the second and third questions, the picture is not relevant, so the student should not refer to it in their response.
|
@@ -50,7 +64,7 @@ def predict(question_choice, audio):
|
|
50 |
model='gpt-3.5-turbo',
|
51 |
messages=conversation,
|
52 |
temperature=0.6,
|
53 |
-
max_tokens=1000, # Limiting the response to
|
54 |
stream=True
|
55 |
)
|
56 |
|
|
|
23 |
# Generate the system message based on the chosen question
|
24 |
strategy, explanation = HongWenData.strategy_text["TREES"]
|
25 |
|
26 |
+
def predict(question_choice, audio):
|
27 |
+
# Transcribe the audio using Whisper
|
28 |
+
with open(audio, "rb") as audio_file:
|
29 |
+
transcript = openai.Audio.transcribe("whisper-1", audio_file)
|
30 |
+
message = transcript["text"] # This is the transcribed message from the audio input
|
31 |
+
|
32 |
+
# Generate the system message based on the chosen question
|
33 |
+
strategy, explanation = HongWenData.strategy_text["TREES"]
|
34 |
+
|
35 |
# Reference to the picture description from HongWenData.py
|
36 |
picture_description = HongWenData.description
|
37 |
|
38 |
+
# Determine whether to include the picture description based on the question choice
|
39 |
+
picture_description_inclusion = f"""
|
40 |
+
For the first question, ensure your feedback refers to the picture description provided:
|
41 |
+
{picture_description}
|
42 |
+
""" if question_choice == HongWenData.questions[0] else ""
|
43 |
+
|
44 |
# Construct the conversation with the system and user's message
|
45 |
conversation = [
|
46 |
{
|
|
|
48 |
"content": f"""
|
49 |
You are an expert English Language Teacher in a Singapore Primary school, directly guiding a Primary 6 student in Singapore.
|
50 |
The student is answering the question: '{question_choice}'.
|
51 |
+
{picture_description_inclusion}
|
|
|
52 |
Point out areas they did well and where they can improve, following the {strategy}.
|
53 |
Encourage the use of sophisticated vocabulary and expressions.
|
54 |
For the second and third questions, the picture is not relevant, so the student should not refer to it in their response.
|
|
|
64 |
model='gpt-3.5-turbo',
|
65 |
messages=conversation,
|
66 |
temperature=0.6,
|
67 |
+
max_tokens=1000, # Limiting the response to 1000 tokens
|
68 |
stream=True
|
69 |
)
|
70 |
|