-
Notifications
You must be signed in to change notification settings - Fork 1
/
tlabs.py
51 lines (34 loc) · 1.26 KB
/
tlabs.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
from twelvelabs import TwelveLabs
from twelvelabs.models.task import Task
import os
api_key = os.environ.get("TLABS")
client = TwelveLabs(api_key = api_key)
def upload_video(index_id, video_url, transcription_url=None):
print("INSIDE UPLOAD VIDEO FUNCTION")
task = client.task.external_provider(
index_id = index_id,
url = video_url
)
print(f"Task id={task.id}")
return task.id
def get_transcript(index_id, video_id):
print("INSIDE GET TRANSCRIPT FUNCTION")
transcriptions = client.index.video.transcription(
index_id = index_id,
id = video_id
)
transcription_list = []
start_points = []
end_points = []
for transcription in transcriptions:
print(
f"value={transcription.value} start={transcription.start} end={transcription.end}"
)
transcription_list.append(transcription.value)
start_points.append(transcription.start)
end_points.append(transcription.end)
return transcription_list, start_points, end_points
def transcript(index_id, video_url):
print("INSIDE TRANSCRIPT FUNCTION")
# video_id = upload_video(index_id, video_url)
transcription_list, start_points, end_points = get_transcript(index_id, video_id=None)