simonraj commited on
Commit
26406a8
·
1 Parent(s): 9392133

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +9 -9
app.py CHANGED
@@ -1,8 +1,8 @@
1
- #app.py
2
  import gradio as gr
3
  import openai
4
  import os
5
- import HongWenData # Importing the HongWenData module
6
  import base64
7
 
8
  OPENAI_API_KEY = os.getenv("OPENAI_API_KEY")
@@ -12,7 +12,7 @@ def image_to_base64(img_path):
12
  with open(img_path, "rb") as img_file:
13
  return base64.b64encode(img_file.read()).decode('utf-8')
14
 
15
- img_base64 = image_to_base64("HongWenSBC.JPG")
16
  img_html = f'<img src="data:image/jpg;base64,{img_base64}" alt="SBC6" width="300" style="display: block; margin: auto;"/>'
17
 
18
  def predict(question_choice, audio):
@@ -22,16 +22,17 @@ def predict(question_choice, audio):
22
  message = transcript["text"] # This is the transcribed message from the audio input
23
 
24
  # Generate the system message based on the chosen question
25
- strategy, explanation = HongWenData.strategy_text["TREES"]
26
 
27
- # Reference to the picture description from HongWenData.py
28
- picture_description = HongWenData.description
29
 
30
  # Determine whether to include the picture description based on the question choice
31
  picture_description_inclusion = f"""
32
  For the first question, ensure your feedback refers to the picture description provided:
33
  {picture_description}
34
- """ if question_choice == HongWenData.questions[0] else ""
 
35
 
36
  # Construct the conversation with the system and user's message
37
  conversation = [
@@ -70,7 +71,7 @@ def predict(question_choice, audio):
70
  iface = gr.Interface(
71
  fn=predict,
72
  inputs=[
73
- gr.Radio(HongWenData.questions, label="Choose a question", default=HongWenData.questions[0]), # Dropdown for question choice
74
  gr.inputs.Audio(source="microphone", type="filepath") # Audio input
75
  ],
76
  outputs=gr.inputs.Textbox(), # Using inputs.Textbox as an output to make it editable
@@ -85,4 +86,3 @@ iface = gr.Interface(
85
  )
86
 
87
  iface.queue(max_size=99, concurrency_count=40).launch(debug=True)
88
-
 
1
+ # app.py
2
  import gradio as gr
3
  import openai
4
  import os
5
+ import CantonmentPriData # Importing the CantonmentPriData module
6
  import base64
7
 
8
  OPENAI_API_KEY = os.getenv("OPENAI_API_KEY")
 
12
  with open(img_path, "rb") as img_file:
13
  return base64.b64encode(img_file.read()).decode('utf-8')
14
 
15
+ img_base64 = image_to_base64("CantonmentPriSBC.JPG")
16
  img_html = f'<img src="data:image/jpg;base64,{img_base64}" alt="SBC6" width="300" style="display: block; margin: auto;"/>'
17
 
18
  def predict(question_choice, audio):
 
22
  message = transcript["text"] # This is the transcribed message from the audio input
23
 
24
  # Generate the system message based on the chosen question
25
+ strategy, explanation = CantonmentPriData.strategy_text["TREES"] # Updated line
26
 
27
+ # Reference to the picture description from CantonmentPriData.py
28
+ picture_description = CantonmentPriData.description # Updated line
29
 
30
  # Determine whether to include the picture description based on the question choice
31
  picture_description_inclusion = f"""
32
  For the first question, ensure your feedback refers to the picture description provided:
33
  {picture_description}
34
+ """ if question_choice == CantonmentPriData.questions[0] else "" # Updated line
35
+
36
 
37
  # Construct the conversation with the system and user's message
38
  conversation = [
 
71
  iface = gr.Interface(
72
  fn=predict,
73
  inputs=[
74
+ gr.Radio(CantonmentPriData.questions, label="Choose a question", default=CantonmentPriData.questions[0]), # Updated line
75
  gr.inputs.Audio(source="microphone", type="filepath") # Audio input
76
  ],
77
  outputs=gr.inputs.Textbox(), # Using inputs.Textbox as an output to make it editable
 
86
  )
87
 
88
  iface.queue(max_size=99, concurrency_count=40).launch(debug=True)