NikilDGr8 commited on
Commit
f1f0624
1 Parent(s): 85f4493

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +16 -2
app.py CHANGED
@@ -1,11 +1,14 @@
1
  import gradio as gr
2
  import assemblyai as aai
3
  from transformers import pipeline
4
- import pandas as pd
5
  import os
 
6
 
7
  # Add your AssemblyAI API key as Environment Variable
8
  aai.settings.api_key = os.environ['Assembly']
 
 
 
9
 
10
  # Initialize question answering pipeline
11
  question_answerer = pipeline("question-answering", model='distilbert-base-cased-distilled-squad')
@@ -104,6 +107,9 @@ def fill_textboxes(context):
104
  answers.append(answer)
105
  return answers
106
 
 
 
 
107
  # Main Gradio app function
108
  def main(audio):
109
  context = transcribe_audio(audio)
@@ -120,7 +126,15 @@ def main(audio):
120
  def save_answers(*args):
121
  answers_dict = {oral_health_assessment_form[i]: args[i] for i in range(len(oral_health_assessment_form))}
122
  print("Saved answers:", answers_dict)
123
- return f"Saved answers: {answers_dict}"
 
 
 
 
 
 
 
 
124
 
125
  # Create the Gradio interface
126
  with gr.Blocks() as demo:
 
1
  import gradio as gr
2
  import assemblyai as aai
3
  from transformers import pipeline
 
4
  import os
5
+ from supabase import create_client, Client
6
 
7
  # Add your AssemblyAI API key as Environment Variable
8
  aai.settings.api_key = os.environ['Assembly']
9
+ url: str = os.environ['DBUrl']
10
+ key: str = os.environ['DBkey']
11
+
12
 
13
  # Initialize question answering pipeline
14
  question_answerer = pipeline("question-answering", model='distilbert-base-cased-distilled-squad')
 
107
  answers.append(answer)
108
  return answers
109
 
110
+ # Supabase configuration
111
+ supabase: Client = create_client(url, key)
112
+
113
  # Main Gradio app function
114
  def main(audio):
115
  context = transcribe_audio(audio)
 
126
  def save_answers(*args):
127
  answers_dict = {oral_health_assessment_form[i]: args[i] for i in range(len(oral_health_assessment_form))}
128
  print("Saved answers:", answers_dict)
129
+
130
+ # Insert data into Supabase
131
+ try:
132
+ response = supabase.table('oral_health_assessments').insert(answers_dict).execute()
133
+ print("Data inserted into Supabase:", response.data)
134
+ return f"Saved answers: {answers_dict}"
135
+ except Exception as e:
136
+ print(f"Error inserting data into Supabase: {e}")
137
+ return f"Error saving answers: {e}"
138
 
139
  # Create the Gradio interface
140
  with gr.Blocks() as demo: