Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -96,8 +96,8 @@ def updateCategoryOptions(resultIndex):
|
|
| 96 |
#st.info(f"Updating result {resultIndex}")
|
| 97 |
#st.info(f"In update: {st.session_state.categorySelect}")
|
| 98 |
# Handle
|
| 99 |
-
|
| 100 |
-
speakerNames =
|
| 101 |
|
| 102 |
# Handle speaker category sidebars
|
| 103 |
unusedSpeakers = copy.deepcopy(speakerNames)
|
|
@@ -223,7 +223,7 @@ def analyze(inFileName):
|
|
| 223 |
st.session_state.summaries[currFileIndex]["speakers_times"] = speakers_times
|
| 224 |
|
| 225 |
df2_dict = {
|
| 226 |
-
"values":[100*t/
|
| 227 |
"names":df4_dict["names"]
|
| 228 |
}
|
| 229 |
df2 = pd.DataFrame(df2_dict)
|
|
@@ -397,6 +397,7 @@ try:
|
|
| 397 |
st.session_state.resetResult = False
|
| 398 |
currFileIndex = file_names.index(currFile)
|
| 399 |
if len(st.session_state.results) > currFileIndex and len(st.session_state.summaries) > currFileIndex and len(st.session_state.results[currFileIndex]) > 0:
|
|
|
|
| 400 |
# Handle
|
| 401 |
currSpeakerList, currAnnotation, currTotalTime = st.session_state.results[currFileIndex]
|
| 402 |
speakerNames = currAnnotation.labels()
|
|
@@ -413,6 +414,7 @@ try:
|
|
| 413 |
on_change=updateCategoryOptions,
|
| 414 |
args=(currFileIndex,))
|
| 415 |
st.sidebar.button(f"Remove {category}",key=f"remove_{category}",on_click=removeCategory,args=(i,))
|
|
|
|
| 416 |
|
| 417 |
|
| 418 |
newCategory = st.sidebar.text_input('Add category', key='categoryInput',on_change=addCategory)
|
|
@@ -429,6 +431,7 @@ try:
|
|
| 429 |
for sp in unusedSpeakers:
|
| 430 |
extraNames.append(sp)
|
| 431 |
extraValues.append(su.sumTimes(currAnnotation.subset([sp])))
|
|
|
|
| 432 |
|
| 433 |
df4_dict = {
|
| 434 |
"names": nameList+extraNames,
|
|
@@ -491,6 +494,7 @@ try:
|
|
| 491 |
st.plotly_chart(fig2, use_container_width=True)
|
| 492 |
st.plotly_chart(fig3_1, use_container_width=True)
|
| 493 |
st.plotly_chart(fig3, use_container_width=True)
|
|
|
|
| 494 |
|
| 495 |
fig_la = px.timeline(speakers_dataFrame, x_start="Start", x_end="Finish", y="Resource", color="Resource")
|
| 496 |
fig_la.update_yaxes(autorange="reversed")
|
|
@@ -533,12 +537,14 @@ try:
|
|
| 533 |
])
|
| 534 |
)
|
| 535 |
st.plotly_chart(fig2_la, use_container_width=True)
|
|
|
|
| 536 |
except ValueError:
|
| 537 |
pass
|
| 538 |
|
| 539 |
if len(st.session_state.results) > 0:
|
|
|
|
| 540 |
with st.spinner(text='Processing summary results...'):
|
| 541 |
-
fileNames =
|
| 542 |
results = []
|
| 543 |
indices = []
|
| 544 |
for i, resultTuple in enumerate(st.session_state.results):
|
|
@@ -546,6 +552,7 @@ if len(st.session_state.results) > 0:
|
|
| 546 |
fileNames.append(resultTuple[0])
|
| 547 |
results.append(resultTuple[1])
|
| 548 |
indices.append(i)
|
|
|
|
| 549 |
if len(indices) > 1:
|
| 550 |
|
| 551 |
df6_dict = {
|
|
@@ -553,14 +560,15 @@ if len(st.session_state.results) > 0:
|
|
| 553 |
}
|
| 554 |
allCategories = copy.deepcopy(st.session_state.categories)
|
| 555 |
for i in indices:
|
| 556 |
-
|
| 557 |
categorySelections = st.session_state["categorySelect"][i]
|
| 558 |
-
catSummary,extraCats = calcCategories(
|
| 559 |
st.session_state.summaries[i]["categories"] = (catSummary,extraCats)
|
| 560 |
for extra in extraCats:
|
| 561 |
df6_dict[extra] = []
|
| 562 |
if extra not in allCategories:
|
| 563 |
allCategories.append(extra)
|
|
|
|
| 564 |
|
| 565 |
for category in st.session_state.categories:
|
| 566 |
df6_dict[category] = []
|
|
@@ -568,17 +576,18 @@ if len(st.session_state.results) > 0:
|
|
| 568 |
summary, extras = st.session_state.summaries[i]["categories"]
|
| 569 |
theseCategories = st.session_state.categories + extras
|
| 570 |
for j, timeSlots in enumerate(summary):
|
| 571 |
-
df6_dict[theseCategories[j]].append(sumTimes([t for _,t in timeSlots])/st.session_state.results[i][
|
| 572 |
for category in allCategories:
|
| 573 |
if category not in theseCategories:
|
| 574 |
df6_dict[category].append(0)
|
| 575 |
df6 = pd.DataFrame(df6_dict)
|
| 576 |
summFig = px.bar(df6, x="files", y=allCategories)
|
| 577 |
st.plotly_chart(summFig, use_container_width=True)
|
|
|
|
| 578 |
|
| 579 |
voiceNames = ["No Voice","One Voice","Multi Voice"]
|
| 580 |
df7_dict = {
|
| 581 |
-
"files":
|
| 582 |
}
|
| 583 |
for category in voiceNames:
|
| 584 |
df7_dict[category] = []
|
|
|
|
| 96 |
#st.info(f"Updating result {resultIndex}")
|
| 97 |
#st.info(f"In update: {st.session_state.categorySelect}")
|
| 98 |
# Handle
|
| 99 |
+
_, currAnnotation, _ = st.session_state.results[currFileIndex]
|
| 100 |
+
speakerNames = currAnnotation.labels()
|
| 101 |
|
| 102 |
# Handle speaker category sidebars
|
| 103 |
unusedSpeakers = copy.deepcopy(speakerNames)
|
|
|
|
| 223 |
st.session_state.summaries[currFileIndex]["speakers_times"] = speakers_times
|
| 224 |
|
| 225 |
df2_dict = {
|
| 226 |
+
"values":[100*t/currTotalTime for t in df4_dict["values"]],
|
| 227 |
"names":df4_dict["names"]
|
| 228 |
}
|
| 229 |
df2 = pd.DataFrame(df2_dict)
|
|
|
|
| 397 |
st.session_state.resetResult = False
|
| 398 |
currFileIndex = file_names.index(currFile)
|
| 399 |
if len(st.session_state.results) > currFileIndex and len(st.session_state.summaries) > currFileIndex and len(st.session_state.results[currFileIndex]) > 0:
|
| 400 |
+
st.info("Displaying current file results")
|
| 401 |
# Handle
|
| 402 |
currSpeakerList, currAnnotation, currTotalTime = st.session_state.results[currFileIndex]
|
| 403 |
speakerNames = currAnnotation.labels()
|
|
|
|
| 414 |
on_change=updateCategoryOptions,
|
| 415 |
args=(currFileIndex,))
|
| 416 |
st.sidebar.button(f"Remove {category}",key=f"remove_{category}",on_click=removeCategory,args=(i,))
|
| 417 |
+
st.info("Displaying current file results1")
|
| 418 |
|
| 419 |
|
| 420 |
newCategory = st.sidebar.text_input('Add category', key='categoryInput',on_change=addCategory)
|
|
|
|
| 431 |
for sp in unusedSpeakers:
|
| 432 |
extraNames.append(sp)
|
| 433 |
extraValues.append(su.sumTimes(currAnnotation.subset([sp])))
|
| 434 |
+
st.info("Displaying current file results2")
|
| 435 |
|
| 436 |
df4_dict = {
|
| 437 |
"names": nameList+extraNames,
|
|
|
|
| 494 |
st.plotly_chart(fig2, use_container_width=True)
|
| 495 |
st.plotly_chart(fig3_1, use_container_width=True)
|
| 496 |
st.plotly_chart(fig3, use_container_width=True)
|
| 497 |
+
st.info("Displaying current file results3")
|
| 498 |
|
| 499 |
fig_la = px.timeline(speakers_dataFrame, x_start="Start", x_end="Finish", y="Resource", color="Resource")
|
| 500 |
fig_la.update_yaxes(autorange="reversed")
|
|
|
|
| 537 |
])
|
| 538 |
)
|
| 539 |
st.plotly_chart(fig2_la, use_container_width=True)
|
| 540 |
+
st.info("Displaying current file results4")
|
| 541 |
except ValueError:
|
| 542 |
pass
|
| 543 |
|
| 544 |
if len(st.session_state.results) > 0:
|
| 545 |
+
st.info("In full summary results")
|
| 546 |
with st.spinner(text='Processing summary results...'):
|
| 547 |
+
fileNames = st.session_state.file_names
|
| 548 |
results = []
|
| 549 |
indices = []
|
| 550 |
for i, resultTuple in enumerate(st.session_state.results):
|
|
|
|
| 552 |
fileNames.append(resultTuple[0])
|
| 553 |
results.append(resultTuple[1])
|
| 554 |
indices.append(i)
|
| 555 |
+
st.info("In full summary results1")
|
| 556 |
if len(indices) > 1:
|
| 557 |
|
| 558 |
df6_dict = {
|
|
|
|
| 560 |
}
|
| 561 |
allCategories = copy.deepcopy(st.session_state.categories)
|
| 562 |
for i in indices:
|
| 563 |
+
currSpeakerList, currAnnotation, currTotalTime = st.session_state.results[i]
|
| 564 |
categorySelections = st.session_state["categorySelect"][i]
|
| 565 |
+
catSummary,extraCats = calcCategories(currAnnotation,categorySelections)
|
| 566 |
st.session_state.summaries[i]["categories"] = (catSummary,extraCats)
|
| 567 |
for extra in extraCats:
|
| 568 |
df6_dict[extra] = []
|
| 569 |
if extra not in allCategories:
|
| 570 |
allCategories.append(extra)
|
| 571 |
+
st.info("In full summary results2")
|
| 572 |
|
| 573 |
for category in st.session_state.categories:
|
| 574 |
df6_dict[category] = []
|
|
|
|
| 576 |
summary, extras = st.session_state.summaries[i]["categories"]
|
| 577 |
theseCategories = st.session_state.categories + extras
|
| 578 |
for j, timeSlots in enumerate(summary):
|
| 579 |
+
df6_dict[theseCategories[j]].append(sumTimes([t for _,t in timeSlots])/st.session_state.results[i][2])
|
| 580 |
for category in allCategories:
|
| 581 |
if category not in theseCategories:
|
| 582 |
df6_dict[category].append(0)
|
| 583 |
df6 = pd.DataFrame(df6_dict)
|
| 584 |
summFig = px.bar(df6, x="files", y=allCategories)
|
| 585 |
st.plotly_chart(summFig, use_container_width=True)
|
| 586 |
+
st.info("In full summary results3")
|
| 587 |
|
| 588 |
voiceNames = ["No Voice","One Voice","Multi Voice"]
|
| 589 |
df7_dict = {
|
| 590 |
+
"files":fileNames,
|
| 591 |
}
|
| 592 |
for category in voiceNames:
|
| 593 |
df7_dict[category] = []
|