add telemetry
Browse files
app.py
CHANGED
@@ -74,6 +74,7 @@ async def speech_to_text(video_file_path):
|
|
74 |
except Exception as e:
|
75 |
raise RuntimeError("Error converting video to audio")
|
76 |
|
|
|
77 |
last_time = time.time()
|
78 |
if API_BACKEND:
|
79 |
# Using Inference API https://huggingface.co/inference-api
|
@@ -124,7 +125,7 @@ async def speech_to_text(video_file_path):
|
|
124 |
raise RuntimeError("Error Running inference with local model", e)
|
125 |
|
126 |
|
127 |
-
def cut_timestamps_to_video(video_in, transcription, text_in, timestamps):
|
128 |
"""
|
129 |
Given original video input, text transcript + timestamps,
|
130 |
and edit ext cuts video segments into a single video
|
@@ -182,6 +183,7 @@ def cut_timestamps_to_video(video_in, transcription, text_in, timestamps):
|
|
182 |
for token in filtered]
|
183 |
|
184 |
total_cuts_since_reboot += 1
|
|
|
185 |
print("\n\ntotal_cuts_since_reboot: ", total_cuts_since_reboot, "\n\n")
|
186 |
return (tokens, output_video)
|
187 |
|
@@ -199,10 +201,21 @@ async def query_api(audio_bytes: bytes):
|
|
199 |
},
|
200 |
"options": {"use_gpu": False}
|
201 |
}).encode("utf-8")
|
202 |
-
|
203 |
async with aiohttp.ClientSession() as session:
|
204 |
async with session.post(API_URL, headers=headers, data=payload) as response:
|
205 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
206 |
|
207 |
# ---- Gradio Layout -----
|
208 |
video_in = gr.Video(label="Video file")
|
|
|
74 |
except Exception as e:
|
75 |
raise RuntimeError("Error converting video to audio")
|
76 |
|
77 |
+
ping("speech_to_text")
|
78 |
last_time = time.time()
|
79 |
if API_BACKEND:
|
80 |
# Using Inference API https://huggingface.co/inference-api
|
|
|
125 |
raise RuntimeError("Error Running inference with local model", e)
|
126 |
|
127 |
|
128 |
+
async def cut_timestamps_to_video(video_in, transcription, text_in, timestamps):
|
129 |
"""
|
130 |
Given original video input, text transcript + timestamps,
|
131 |
and edit ext cuts video segments into a single video
|
|
|
183 |
for token in filtered]
|
184 |
|
185 |
total_cuts_since_reboot += 1
|
186 |
+
ping("video_cuts")
|
187 |
print("\n\ntotal_cuts_since_reboot: ", total_cuts_since_reboot, "\n\n")
|
188 |
return (tokens, output_video)
|
189 |
|
|
|
201 |
},
|
202 |
"options": {"use_gpu": False}
|
203 |
}).encode("utf-8")
|
|
|
204 |
async with aiohttp.ClientSession() as session:
|
205 |
async with session.post(API_URL, headers=headers, data=payload) as response:
|
206 |
+
return await response.json()
|
207 |
+
|
208 |
+
|
209 |
+
def ping(name):
|
210 |
+
url = f'https://huggingface.co/api/telemetry/spaces/radames/edit-video-by-editing-text/{name}'
|
211 |
+
print("ping: ", url)
|
212 |
+
|
213 |
+
async def req():
|
214 |
+
async with aiohttp.ClientSession() as session:
|
215 |
+
async with session.get(url) as response:
|
216 |
+
print("pong: ", response.status)
|
217 |
+
asyncio.create_task(req())
|
218 |
+
|
219 |
|
220 |
# ---- Gradio Layout -----
|
221 |
video_in = gr.Video(label="Video file")
|