Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -3,7 +3,6 @@ import assemblyai as aai
|
|
3 |
from transformers import pipeline
|
4 |
import pandas as pd
|
5 |
import os
|
6 |
-
from bs4 import BeautifulSoup
|
7 |
|
8 |
# Replace with your AssemblyAI API key
|
9 |
aai.settings.api_key = "62acec891bb04c339ec059b738bedac6"
|
@@ -126,20 +125,8 @@ def main(audio):
|
|
126 |
return table_html
|
127 |
|
128 |
# Function to handle submit button and store table data in dictionary
|
129 |
-
def submit_table_data(
|
130 |
-
|
131 |
-
soup = BeautifulSoup(html_table, 'html.parser')
|
132 |
-
tabledata = {}
|
133 |
-
|
134 |
-
# Iterate through the rows of the table
|
135 |
-
rows = soup.find_all('tr')
|
136 |
-
for row in rows:
|
137 |
-
cells = row.find_all('td')
|
138 |
-
if len(cells) == 2:
|
139 |
-
question = cells[0].text.strip()
|
140 |
-
answer = cells[1].find('input')['value']
|
141 |
-
tabledata[question] = answer
|
142 |
-
|
143 |
print("Submitted Table Data: ", tabledata)
|
144 |
return f"Data submitted successfully! {tabledata}"
|
145 |
|
@@ -154,8 +141,10 @@ with gr.Blocks() as demo:
|
|
154 |
transcribe_button = gr.Button("Transcribe and Generate Form")
|
155 |
submit_button = gr.Button("Submit")
|
156 |
|
|
|
|
|
157 |
transcribe_button.click(fn=main, inputs=audio_input, outputs=output_html)
|
158 |
-
submit_button.click(fn=submit_table_data, inputs=
|
159 |
|
160 |
# Launch the app
|
161 |
demo.launch()
|
|
|
3 |
from transformers import pipeline
|
4 |
import pandas as pd
|
5 |
import os
|
|
|
6 |
|
7 |
# Replace with your AssemblyAI API key
|
8 |
aai.settings.api_key = "62acec891bb04c339ec059b738bedac6"
|
|
|
125 |
return table_html
|
126 |
|
127 |
# Function to handle submit button and store table data in dictionary
|
128 |
+
def submit_table_data(answers):
|
129 |
+
tabledata = dict(zip(oral_health_assessment_form, answers))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
130 |
print("Submitted Table Data: ", tabledata)
|
131 |
return f"Data submitted successfully! {tabledata}"
|
132 |
|
|
|
141 |
transcribe_button = gr.Button("Transcribe and Generate Form")
|
142 |
submit_button = gr.Button("Submit")
|
143 |
|
144 |
+
output_textboxes = [gr.Textbox(label=question) for question in oral_health_assessment_form]
|
145 |
+
|
146 |
transcribe_button.click(fn=main, inputs=audio_input, outputs=output_html)
|
147 |
+
submit_button.click(fn=submit_table_data, inputs=output_textboxes, outputs=gr.Textbox(label="Submit Status"))
|
148 |
|
149 |
# Launch the app
|
150 |
demo.launch()
|