Spaces:
Sleeping
Sleeping
Commit
Β·
03dfca2
1
Parent(s):
3c6f1cc
test
Browse files- {Pages/Functions β Functions}/auth_functions.py +0 -0
- {Pages/Functions β Functions}/caption_editor_functions.py +0 -0
- {Pages/Functions β Functions}/db_connection.py +0 -0
- {Pages/Functions β Functions}/video_player_functions.py +0 -0
- {Pages/Resources β Resources}/captions.jsonl +1 -1
- {Pages/Resources β Resources}/css.py +0 -0
- app.py +53 -18
- requirements.txt +1 -0
{Pages/Functions β Functions}/auth_functions.py
RENAMED
|
File without changes
|
{Pages/Functions β Functions}/caption_editor_functions.py
RENAMED
|
File without changes
|
{Pages/Functions β Functions}/db_connection.py
RENAMED
|
File without changes
|
{Pages/Functions β Functions}/video_player_functions.py
RENAMED
|
File without changes
|
{Pages/Resources β Resources}/captions.jsonl
RENAMED
|
@@ -11,5 +11,5 @@
|
|
| 11 |
{"clean_text":"test","start_time":0.0,"user_id":"admin","signer":39,"file":"1pXUgdCnVec","end_time":1.435,"url":"www.youtube.com\/watch?v=1pXUgdCnVec","text":"test"}
|
| 12 |
{"clean_text":"test","start_time":0.0,"user_id":"admin","signer":39,"file":"1pXUgdCnVec","end_time":1.435,"url":"www.youtube.com\/watch?v=1pXUgdCnVec","text":"test"}
|
| 13 |
{"clean_text":"test","start_time":0.0,"user_id":"admin","signer":39,"file":"1pXUgdCnVec","end_time":1.435,"url":"www.youtube.com\/watch?v=1pXUgdCnVec","text":"test"}
|
| 14 |
-
{"clean_text":"measure","start_time":
|
| 15 |
{"clean_text":"apple","start_time":1.71,"user_id":"admin","signer":20,"file":"tkMg8g8vVUo","end_time":2.0,"url":"www.youtube.com\/watch?v=tkMg8g8vVUo","text":"apple"}
|
|
|
|
| 11 |
{"clean_text":"test","start_time":0.0,"user_id":"admin","signer":39,"file":"1pXUgdCnVec","end_time":1.435,"url":"www.youtube.com\/watch?v=1pXUgdCnVec","text":"test"}
|
| 12 |
{"clean_text":"test","start_time":0.0,"user_id":"admin","signer":39,"file":"1pXUgdCnVec","end_time":1.435,"url":"www.youtube.com\/watch?v=1pXUgdCnVec","text":"test"}
|
| 13 |
{"clean_text":"test","start_time":0.0,"user_id":"admin","signer":39,"file":"1pXUgdCnVec","end_time":1.435,"url":"www.youtube.com\/watch?v=1pXUgdCnVec","text":"test"}
|
| 14 |
+
{"clean_text":"measure","start_time":1.0,"user_id":"admin","signer":20,"file":"tkMg8g8vVUo","end_time":1.435,"url":"www.youtube.com\/watch?v=tkMg8g8vVUo","text":"test"}
|
| 15 |
{"clean_text":"apple","start_time":1.71,"user_id":"admin","signer":20,"file":"tkMg8g8vVUo","end_time":2.0,"url":"www.youtube.com\/watch?v=tkMg8g8vVUo","text":"apple"}
|
{Pages/Resources β Resources}/css.py
RENAMED
|
File without changes
|
app.py
CHANGED
|
@@ -1,25 +1,60 @@
|
|
| 1 |
-
from fastapi import FastAPI
|
| 2 |
-
from fastapi.responses import HTMLResponse
|
| 3 |
import gradio as gr
|
| 4 |
-
from
|
| 5 |
-
from
|
| 6 |
-
from
|
| 7 |
|
| 8 |
-
|
| 9 |
-
|
| 10 |
-
REGISTRATION_PATH = "/registration"
|
| 11 |
|
| 12 |
-
index_html = f'''
|
| 13 |
-
<div>
|
| 14 |
-
<iframe src={MAIN_PATH} width=100% height=100% frameBorder="0"></iframe>
|
| 15 |
-
</div>
|
| 16 |
-
'''
|
| 17 |
|
|
|
|
|
|
|
|
|
|
| 18 |
|
| 19 |
-
@app.get("/", response_class=HTMLResponse)
|
| 20 |
-
def index():
|
| 21 |
-
return index_html
|
| 22 |
|
|
|
|
|
|
|
| 23 |
|
| 24 |
-
|
| 25 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
import gradio as gr
|
| 2 |
+
from .Functions.video_player_functions import youtube_link_to_id, get_video_embed_by_id, get_video_link_by_pointer
|
| 3 |
+
from .Functions.caption_editor_functions import get_captions_by_video_id, save_dataframe
|
| 4 |
+
from .Resources.css import css
|
| 5 |
|
| 6 |
+
next_video_pointer = 0
|
| 7 |
+
user = ""
|
|
|
|
| 8 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 9 |
|
| 10 |
+
def get_username(request: gr.Request):
|
| 11 |
+
global user
|
| 12 |
+
user = request.username
|
| 13 |
|
|
|
|
|
|
|
|
|
|
| 14 |
|
| 15 |
+
def save(df, video_id):
|
| 16 |
+
return save_dataframe(df, video_id, user)
|
| 17 |
|
| 18 |
+
|
| 19 |
+
def get_next_components():
|
| 20 |
+
global next_video_pointer
|
| 21 |
+
next_video_link = get_video_link_by_pointer(next_video_pointer)
|
| 22 |
+
next_video_pointer += 1
|
| 23 |
+
if next_video_link is None:
|
| 24 |
+
next_video_link = get_video_link_by_pointer(0)
|
| 25 |
+
next_video_pointer = 1
|
| 26 |
+
|
| 27 |
+
next_video_id = youtube_link_to_id(next_video_link)
|
| 28 |
+
|
| 29 |
+
next_video = get_video_embed_by_id(next_video_id)
|
| 30 |
+
next_captions = get_captions_by_video_id(next_video_id)
|
| 31 |
+
|
| 32 |
+
return next_video, next_captions, next_video_id
|
| 33 |
+
|
| 34 |
+
|
| 35 |
+
(start_video, start_captions, start_video_id) = get_next_components()
|
| 36 |
+
|
| 37 |
+
with gr.Blocks(css=css) as main_page:
|
| 38 |
+
gr.Markdown("## Caption Editor")
|
| 39 |
+
current_video_id = gr.Textbox(value=start_video_id, visible=False, interactive=False)
|
| 40 |
+
with gr.Row():
|
| 41 |
+
with gr.Column():
|
| 42 |
+
caption_editor = gr.DataFrame(interactive=True,
|
| 43 |
+
value=start_captions,
|
| 44 |
+
datatype=["number", "str", "number"],
|
| 45 |
+
row_count=(start_captions.shape[0], "fixed"),
|
| 46 |
+
col_count=(3, "fixed"), column_widths=["20%", "60%", "20%"])
|
| 47 |
+
save_button = gr.Button(value="Save")
|
| 48 |
+
save_result = gr.Markdown()
|
| 49 |
+
with gr.Column():
|
| 50 |
+
video_embed = gr.HTML(value=start_video)
|
| 51 |
+
next_video_button = gr.Button("Next")
|
| 52 |
+
|
| 53 |
+
next_video_button.click(fn=get_next_components,
|
| 54 |
+
outputs=[video_embed, caption_editor, current_video_id])
|
| 55 |
+
save_button.click(fn=save,
|
| 56 |
+
inputs=[caption_editor, current_video_id],
|
| 57 |
+
outputs=save_result)
|
| 58 |
+
main_page.load(get_username)
|
| 59 |
+
|
| 60 |
+
main_page.launch()
|
requirements.txt
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
firebase-admin
|