Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -1,5 +1,6 @@
|
|
1 |
import os
|
2 |
import gradio as gr
|
|
|
3 |
from pipelines.pipeline import InferencePipeline
|
4 |
|
5 |
TITLE = """
|
@@ -64,6 +65,8 @@ CSS = """
|
|
64 |
}
|
65 |
"""
|
66 |
|
|
|
|
|
67 |
pipelines = {
|
68 |
"VSR(mediapipe)": InferencePipeline("./configs/LRS3_V_WER19.1.ini", device="cpu", face_track=True, detector="mediapipe"),
|
69 |
"ASR": InferencePipeline("./configs/LRS3_A_WER1.0.ini", device="cpu", face_track=True, detector="mediapipe"),
|
@@ -71,9 +74,15 @@ pipelines = {
|
|
71 |
}
|
72 |
|
73 |
def fn(pipeline_type, filename):
|
|
|
|
|
|
|
|
|
|
|
|
|
74 |
selected_pipeline_instance = pipelines[pipeline_type]
|
75 |
-
landmarks = selected_pipeline_instance.process_landmarks(
|
76 |
-
data = selected_pipeline_instance.dataloader.load_data(
|
77 |
transcript = selected_pipeline_instance.model.infer(data)
|
78 |
return transcript
|
79 |
|
|
|
1 |
import os
|
2 |
import gradio as gr
|
3 |
+
from uuid import uuid4
|
4 |
from pipelines.pipeline import InferencePipeline
|
5 |
|
6 |
TITLE = """
|
|
|
65 |
}
|
66 |
"""
|
67 |
|
68 |
+
FFMPEG_COMMAND = "-loglevel error -y -r 25 -pix_fmt yuv420p -f mp4"
|
69 |
+
|
70 |
pipelines = {
|
71 |
"VSR(mediapipe)": InferencePipeline("./configs/LRS3_V_WER19.1.ini", device="cpu", face_track=True, detector="mediapipe"),
|
72 |
"ASR": InferencePipeline("./configs/LRS3_A_WER1.0.ini", device="cpu", face_track=True, detector="mediapipe"),
|
|
|
74 |
}
|
75 |
|
76 |
def fn(pipeline_type, filename):
|
77 |
+
directory = "./tmp"
|
78 |
+
if not os.path.exists(directory):
|
79 |
+
os.makedirs(directory)
|
80 |
+
dst_filename = os.path.join(directory, str(uuid4())[:8]+".mp4")
|
81 |
+
command_string = f"ffmpeg -i {filename} {FFMPEG_COMMAND} {dst_filename}"
|
82 |
+
os.system(command_string)
|
83 |
selected_pipeline_instance = pipelines[pipeline_type]
|
84 |
+
landmarks = selected_pipeline_instance.process_landmarks(dst_filename, landmarks_filename=None)
|
85 |
+
data = selected_pipeline_instance.dataloader.load_data(dst_filename, landmarks)
|
86 |
transcript = selected_pipeline_instance.model.infer(data)
|
87 |
return transcript
|
88 |
|