Spaces:
Running
Running
Commit ·
fa786d6
1
Parent(s): b4a700a
v2 with Blocks
Browse files
app.py
CHANGED
|
@@ -40,65 +40,116 @@ def calculate_times(input_url, input_text, ms_before, ms_after):
|
|
| 40 |
)
|
| 41 |
for start, stop in non_silent_parts
|
| 42 |
]
|
|
|
|
| 43 |
lines = input_text.splitlines()
|
| 44 |
if len(lines) != len(segments):
|
| 45 |
-
|
|
|
|
|
|
|
| 46 |
else:
|
| 47 |
-
df = pd.DataFrame({"text": [], "start": [], "stop": [], "file": []})
|
| 48 |
res = []
|
| 49 |
for i in range(len(segments)):
|
| 50 |
line = lines[i].rstrip()
|
| 51 |
res.append(f"{line}\t{segments[i][0]}\t{segments[i][1]}\t{input_url}")
|
| 52 |
df.loc[len(df.index)] = [line, segments[i][0], segments[i][1], input_url]
|
| 53 |
-
|
| 54 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 55 |
|
|
|
|
|
|
|
|
|
|
| 56 |
|
| 57 |
-
|
| 58 |
-
|
| 59 |
-
|
| 60 |
-
|
| 61 |
-
|
| 62 |
-
|
| 63 |
-
|
| 64 |
-
|
| 65 |
-
|
| 66 |
-
|
| 67 |
-
|
| 68 |
-
|
| 69 |
-
|
| 70 |
-
|
| 71 |
-
|
| 72 |
-
|
| 73 |
-
|
| 74 |
-
|
| 75 |
-
|
| 76 |
-
|
| 77 |
-
|
| 78 |
-
|
| 79 |
-
|
| 80 |
-
|
| 81 |
-
|
| 82 |
-
|
| 83 |
-
|
| 84 |
-
|
| 85 |
-
|
| 86 |
-
|
| 87 |
-
|
| 88 |
-
|
| 89 |
-
|
| 90 |
-
|
| 91 |
-
|
| 92 |
-
|
| 93 |
-
|
| 94 |
-
|
| 95 |
-
|
| 96 |
-
|
| 97 |
-
|
| 98 |
-
|
| 99 |
-
|
| 100 |
-
|
| 101 |
-
|
| 102 |
-
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 103 |
|
| 104 |
app.launch()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 40 |
)
|
| 41 |
for start, stop in non_silent_parts
|
| 42 |
]
|
| 43 |
+
df = pd.DataFrame({"text": [], "start": [], "stop": [], "file": []})
|
| 44 |
lines = input_text.splitlines()
|
| 45 |
if len(lines) != len(segments):
|
| 46 |
+
msg = f"DETECTED CLIPS AND INPUT LINES DO NOT MATCH!\n\nYou are expecting {len(lines)} clips BUT {len(segments)} segments have been found in the video file.\n\nPlease, review the list of clips or transcribe the audio to check the clips.\n\nUSEFUL FREE TOOLS:\n\nTranscribe audio to VTT file\nhttps://replicate.com/openai/whisper\n\nVTT file viewer\nhttps://www.happyscribe.com/subtitle-tools/online-subtitle-editor/free"
|
| 47 |
+
df.loc[len(df.index)] = ["", "", "", ""]
|
| 48 |
+
return msg, None, df
|
| 49 |
else:
|
|
|
|
| 50 |
res = []
|
| 51 |
for i in range(len(segments)):
|
| 52 |
line = lines[i].rstrip()
|
| 53 |
res.append(f"{line}\t{segments[i][0]}\t{segments[i][1]}\t{input_url}")
|
| 54 |
df.loc[len(df.index)] = [line, segments[i][0], segments[i][1], input_url]
|
| 55 |
+
df.to_csv(
|
| 56 |
+
"clips.tsv",
|
| 57 |
+
sep="\t",
|
| 58 |
+
encoding="utf-8",
|
| 59 |
+
index=False,
|
| 60 |
+
header=False,
|
| 61 |
+
quoting=csv.QUOTE_NONE,
|
| 62 |
+
)
|
| 63 |
+
return "\n".join(res), "clips.tsv", df
|
| 64 |
+
|
| 65 |
+
|
| 66 |
+
def load_video(input_url):
|
| 67 |
+
if input_url:
|
| 68 |
+
return input_url
|
| 69 |
+
return None
|
| 70 |
+
|
| 71 |
|
| 72 |
+
css = """
|
| 73 |
+
.required {background-color: #FFCCCB !important, font-size: 24px !important}
|
| 74 |
+
"""
|
| 75 |
|
| 76 |
+
|
| 77 |
+
with gr.Blocks(title="Start and stop times", css=css) as app:
|
| 78 |
+
gr.Markdown(
|
| 79 |
+
"""# Start and stop times generator
|
| 80 |
+
Please, fill the Video URL and Clip texts textboxes and click the Run button"""
|
| 81 |
+
)
|
| 82 |
+
with gr.Row():
|
| 83 |
+
with gr.Column(scale=3):
|
| 84 |
+
text1 = gr.Textbox(
|
| 85 |
+
lines=1,
|
| 86 |
+
placeholder="Video URL...",
|
| 87 |
+
label="Video URL",
|
| 88 |
+
elem_classes=["required"],
|
| 89 |
+
)
|
| 90 |
+
text2 = gr.Textbox(
|
| 91 |
+
lines=5,
|
| 92 |
+
max_lines=10,
|
| 93 |
+
placeholder="List of clip texts...",
|
| 94 |
+
label="Clip texts",
|
| 95 |
+
elem_classes=["required"],
|
| 96 |
+
)
|
| 97 |
+
slider1 = gr.Slider(
|
| 98 |
+
minimum=0,
|
| 99 |
+
maximum=1000,
|
| 100 |
+
step=50,
|
| 101 |
+
value=0,
|
| 102 |
+
label="Milliseconds BEFORE each clip",
|
| 103 |
+
)
|
| 104 |
+
slider2 = gr.Slider(
|
| 105 |
+
minimum=0,
|
| 106 |
+
maximum=1000,
|
| 107 |
+
step=50,
|
| 108 |
+
value=500,
|
| 109 |
+
label="Milliseconds AFTER each clip",
|
| 110 |
+
)
|
| 111 |
+
btn_submit = gr.Button(value="Run", variant="primary", size="sm")
|
| 112 |
+
video = gr.Video(
|
| 113 |
+
format="mp4", label="Video file", show_label=True, interactive=False
|
| 114 |
+
)
|
| 115 |
+
with gr.Column(scale=5):
|
| 116 |
+
file = gr.File(
|
| 117 |
+
label="Clips", show_label=True, file_count=1, interactive=False
|
| 118 |
+
)
|
| 119 |
+
lines = gr.Textbox(
|
| 120 |
+
lines=10, label="Clips", interactive=False, show_copy_button=True
|
| 121 |
+
)
|
| 122 |
+
data = gr.Dataframe(
|
| 123 |
+
label="Clips",
|
| 124 |
+
headers=["text", "start", "stop", "file"],
|
| 125 |
+
datatype=["str", "str", "str", "str"],
|
| 126 |
+
row_count=0,
|
| 127 |
+
)
|
| 128 |
+
# with gr.Row():
|
| 129 |
+
# with gr.Column(scale=3):
|
| 130 |
+
|
| 131 |
+
btn_submit.click(
|
| 132 |
+
calculate_times,
|
| 133 |
+
inputs=[text1, text2, slider1, slider2],
|
| 134 |
+
outputs=[lines, file, data],
|
| 135 |
+
)
|
| 136 |
+
# with gr.Column(scale=5):
|
| 137 |
+
# pass
|
| 138 |
+
text1.blur(load_video, inputs=[text1], outputs=[video])
|
| 139 |
|
| 140 |
app.launch()
|
| 141 |
+
|
| 142 |
+
# examples=[
|
| 143 |
+
# [
|
| 144 |
+
# "https://simulation-temporary-test.s3.amazonaws.com/SanofiFluCoach.mp4",
|
| 145 |
+
# 'Are you ready to jump into a practice? Just say "Lets Practice"\nIf you\'d like to return to the menu, say "Main Menu"\nMain Menu\nPlease say or click one of the choices above\nWelcome back.\nGreat to have you back.\nIt\'s a pleasure to have you back\nWelcome home.\nWould you like to hop on another call? Or do you need to hop off?\nYou can also just return to the main menu.\nDo you have time for another practice?\nLooks like you didn\'t make it all the way through the call.\nYou\'ll need to start over next time, but it will only take a few minutes.\nYou can choose to do it again now, or you can return to the main menu.\nYou hung up on that call in a hurry.\nDo you want to try again now or return to the main menu?\nAre you ready to view your results?\nYour results are ready. Let\'s take a look. Say or click "show my results"\nThe results are in. Say or click "show my results" to take a look.\nReady to see how you did? Say or click "show my results" to check it out.\nYour results are now available. Say or click "show my results"\nWell, I think those were fair questions, and you\'re likely to face those from other HCP\'s as well. So it pays off to be ready. Let\'s see how you did. Click Show my results\nWere you ready for those questions? By exercising your response muscles, you\'ll be even more ready next time questions like these come up.\nDo you want an overview of Simulator? Or, tips on how-to practice?',
|
| 146 |
+
# 0,
|
| 147 |
+
# 0,
|
| 148 |
+
# ],
|
| 149 |
+
# [
|
| 150 |
+
# "https://simulation-temporary-test.s3.amazonaws.com/SanofiVisAidAvatarPoppy.mp4",
|
| 151 |
+
# "Let's get started! You will soon be connected to Dr. Poppy Thompson, an AI physician who is interested in this new drug. Be prepared to discuss all areas of the Beyfortus Visual Aid and to answer any questions she might have. I will give you a few moments to prepare. When you are ready to start the call, just say \"Let's Go\".\nHi, great to see you! I understand you are here to talk to me about your new RSV product. Why don't you jump in? What is it, and what is it for?\nThat's interesting. Why do all infants need protection against RSV?\nUnderstood, so will the protection offered by Beyfortus last for the entire RSV season?\nTell me about the clinical trials – can you give me a broad overview of what was measured?\nThanks, can we dive deeper into Trial 4? What were the results of the primary endpoints, what do I need to take away here?\nI noticed that Beyfortus didn't meet the secondary endpoint of hospitalization in Trial 4. Can you please elaborate on that?\nThanks, let's also take a closer look at Trial three. What were the results of the primary endpoints, what do I need to take-away here?\nThat all sounds great, but is Beyfortus safe? Were there any adverse reactions?\nSo, I know RSV is seasonal, and Beyfortus offers 5 months of protection. How can I fit this into my immunization schedule?\nWhat do I need to know from an administration standpoint?\nThinking through some of the practical considerations, how is Beyfortus administered? How is Beyfortus stored, and what is its shelf-life?\nThanks for your time today – it's definitely very interesting.\nThis has been so helpful. I really appreciate your time today. I do think this makes sense – let's determine next steps to make sure we're protecting all infants from RSV by using Beyfortus. Take care!",
|
| 152 |
+
# 0,
|
| 153 |
+
# 0,
|
| 154 |
+
# ],
|
| 155 |
+
# ]
|
clip.tsv
DELETED
|
@@ -1,25 +0,0 @@
|
|
| 1 |
-
text start stop file
|
| 2 |
-
"Are you ready to jump into a practice? Just say ""Lets Practice""" 00:01.682 00:06.345 https://simulation-temporary-test.s3.amazonaws.com/SanofiFluCoach.mp4
|
| 3 |
-
"If you'd like to return to the menu, say ""Main Menu""" 00:07.971 00:11.447 https://simulation-temporary-test.s3.amazonaws.com/SanofiFluCoach.mp4
|
| 4 |
-
Main Menu 00:14.068 00:15.249 https://simulation-temporary-test.s3.amazonaws.com/SanofiFluCoach.mp4
|
| 5 |
-
Please say or click one of the choices above 00:17.854 00:20.734 https://simulation-temporary-test.s3.amazonaws.com/SanofiFluCoach.mp4
|
| 6 |
-
Welcome back. 00:35.360 00:36.649 https://simulation-temporary-test.s3.amazonaws.com/SanofiFluCoach.mp4
|
| 7 |
-
Great to have you back. 00:38.279 00:39.907 https://simulation-temporary-test.s3.amazonaws.com/SanofiFluCoach.mp4
|
| 8 |
-
It's a pleasure to have you back 00:41.518 00:43.535 https://simulation-temporary-test.s3.amazonaws.com/SanofiFluCoach.mp4
|
| 9 |
-
Welcome home. 00:45.152 00:46.459 https://simulation-temporary-test.s3.amazonaws.com/SanofiFluCoach.mp4
|
| 10 |
-
Would you like to hop on another call? Or do you need to hop off? 00:48.062 00:52.462 https://simulation-temporary-test.s3.amazonaws.com/SanofiFluCoach.mp4
|
| 11 |
-
You can also just return to the main menu. 00:54.091 00:57.062 https://simulation-temporary-test.s3.amazonaws.com/SanofiFluCoach.mp4
|
| 12 |
-
Do you have time for another practice? 00:58.667 01:01.102 https://simulation-temporary-test.s3.amazonaws.com/SanofiFluCoach.mp4
|
| 13 |
-
Looks like you didn't make it all the way through the call. 01:02.719 01:05.812 https://simulation-temporary-test.s3.amazonaws.com/SanofiFluCoach.mp4
|
| 14 |
-
You'll need to start over next time, but it will only take a few minutes. 01:07.434 01:12.056 https://simulation-temporary-test.s3.amazonaws.com/SanofiFluCoach.mp4
|
| 15 |
-
You can choose to do it again now, or you can return to the main menu. 01:13.679 01:18.176 https://simulation-temporary-test.s3.amazonaws.com/SanofiFluCoach.mp4
|
| 16 |
-
You hung up on that call in a hurry. 01:19.786 01:22.415 https://simulation-temporary-test.s3.amazonaws.com/SanofiFluCoach.mp4
|
| 17 |
-
Do you want to try again now or return to the main menu? 01:24.011 01:27.793 https://simulation-temporary-test.s3.amazonaws.com/SanofiFluCoach.mp4
|
| 18 |
-
Are you ready to view your results? 01:29.402 01:31.850 https://simulation-temporary-test.s3.amazonaws.com/SanofiFluCoach.mp4
|
| 19 |
-
"Your results are ready. Let's take a look. Say or click ""show my results""" 01:33.471 01:39.547 https://simulation-temporary-test.s3.amazonaws.com/SanofiFluCoach.mp4
|
| 20 |
-
"The results are in. Say or click ""show my results"" to take a look." 01:41.181 01:46.691 https://simulation-temporary-test.s3.amazonaws.com/SanofiFluCoach.mp4
|
| 21 |
-
"Ready to see how you did? Say or click ""show my results"" to check it out." 01:48.299 01:54.026 https://simulation-temporary-test.s3.amazonaws.com/SanofiFluCoach.mp4
|
| 22 |
-
"Your results are now available. Say or click ""show my results""" 01:55.649 02:00.789 https://simulation-temporary-test.s3.amazonaws.com/SanofiFluCoach.mp4
|
| 23 |
-
Well, I think those were fair questions, and you're likely to face those from other HCP's as well. So it pays off to be ready. Let's see how you did. Click Show my results 02:02.394 02:14.834 https://simulation-temporary-test.s3.amazonaws.com/SanofiFluCoach.mp4
|
| 24 |
-
Were you ready for those questions? By exercising your response muscles, you'll be even more ready next time questions like these come up. 02:16.455 02:24.626 https://simulation-temporary-test.s3.amazonaws.com/SanofiFluCoach.mp4
|
| 25 |
-
Do you want an overview of Simulator? Or, tips on how-to practice? 02:26.242 02:31.856 https://simulation-temporary-test.s3.amazonaws.com/SanofiFluCoach.mp4
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
clips.tsv
DELETED
|
@@ -1,24 +0,0 @@
|
|
| 1 |
-
Are you ready to jump into a practice? Just say "Lets Practice" 00:01.682 00:06.345 https://simulation-temporary-test.s3.amazonaws.com/SanofiFluCoach.mp4
|
| 2 |
-
If you'd like to return to the menu, say "Main Menu" 00:07.971 00:11.447 https://simulation-temporary-test.s3.amazonaws.com/SanofiFluCoach.mp4
|
| 3 |
-
Main Menu 00:14.068 00:15.249 https://simulation-temporary-test.s3.amazonaws.com/SanofiFluCoach.mp4
|
| 4 |
-
Please say or click one of the choices above 00:17.854 00:20.734 https://simulation-temporary-test.s3.amazonaws.com/SanofiFluCoach.mp4
|
| 5 |
-
Welcome back. 00:35.360 00:36.649 https://simulation-temporary-test.s3.amazonaws.com/SanofiFluCoach.mp4
|
| 6 |
-
Great to have you back. 00:38.279 00:39.907 https://simulation-temporary-test.s3.amazonaws.com/SanofiFluCoach.mp4
|
| 7 |
-
It's a pleasure to have you back 00:41.518 00:43.535 https://simulation-temporary-test.s3.amazonaws.com/SanofiFluCoach.mp4
|
| 8 |
-
Welcome home. 00:45.152 00:46.459 https://simulation-temporary-test.s3.amazonaws.com/SanofiFluCoach.mp4
|
| 9 |
-
Would you like to hop on another call? Or do you need to hop off? 00:48.062 00:52.462 https://simulation-temporary-test.s3.amazonaws.com/SanofiFluCoach.mp4
|
| 10 |
-
You can also just return to the main menu. 00:54.091 00:57.062 https://simulation-temporary-test.s3.amazonaws.com/SanofiFluCoach.mp4
|
| 11 |
-
Do you have time for another practice? 00:58.667 01:01.102 https://simulation-temporary-test.s3.amazonaws.com/SanofiFluCoach.mp4
|
| 12 |
-
Looks like you didn't make it all the way through the call. 01:02.719 01:05.812 https://simulation-temporary-test.s3.amazonaws.com/SanofiFluCoach.mp4
|
| 13 |
-
You'll need to start over next time, but it will only take a few minutes. 01:07.434 01:12.056 https://simulation-temporary-test.s3.amazonaws.com/SanofiFluCoach.mp4
|
| 14 |
-
You can choose to do it again now, or you can return to the main menu. 01:13.679 01:18.176 https://simulation-temporary-test.s3.amazonaws.com/SanofiFluCoach.mp4
|
| 15 |
-
You hung up on that call in a hurry. 01:19.786 01:22.415 https://simulation-temporary-test.s3.amazonaws.com/SanofiFluCoach.mp4
|
| 16 |
-
Do you want to try again now or return to the main menu? 01:24.011 01:27.793 https://simulation-temporary-test.s3.amazonaws.com/SanofiFluCoach.mp4
|
| 17 |
-
Are you ready to view your results? 01:29.402 01:31.850 https://simulation-temporary-test.s3.amazonaws.com/SanofiFluCoach.mp4
|
| 18 |
-
Your results are ready. Let's take a look. Say or click "show my results" 01:33.471 01:39.547 https://simulation-temporary-test.s3.amazonaws.com/SanofiFluCoach.mp4
|
| 19 |
-
The results are in. Say or click "show my results" to take a look. 01:41.181 01:46.691 https://simulation-temporary-test.s3.amazonaws.com/SanofiFluCoach.mp4
|
| 20 |
-
Ready to see how you did? Say or click "show my results" to check it out. 01:48.299 01:54.026 https://simulation-temporary-test.s3.amazonaws.com/SanofiFluCoach.mp4
|
| 21 |
-
Your results are now available. Say or click "show my results" 01:55.649 02:00.789 https://simulation-temporary-test.s3.amazonaws.com/SanofiFluCoach.mp4
|
| 22 |
-
Well, I think those were fair questions, and you're likely to face those from other HCP's as well. So it pays off to be ready. Let's see how you did. Click Show my results 02:02.394 02:14.834 https://simulation-temporary-test.s3.amazonaws.com/SanofiFluCoach.mp4
|
| 23 |
-
Were you ready for those questions? By exercising your response muscles, you'll be even more ready next time questions like these come up. 02:16.455 02:24.626 https://simulation-temporary-test.s3.amazonaws.com/SanofiFluCoach.mp4
|
| 24 |
-
Do you want an overview of Simulator? Or, tips on how-to practice? 02:26.242 02:31.856 https://simulation-temporary-test.s3.amazonaws.com/SanofiFluCoach.mp4
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|