Skip to content

Commit f88f4d5

Browse files
committed
feat: add transcript params
1 parent b947eff commit f88f4d5

File tree

1 file changed

+45
-7
lines changed

1 file changed

+45
-7
lines changed

videodb/video.py

Lines changed: 45 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -124,23 +124,61 @@ def get_thumbnails(self) -> List[Image]:
124124
)
125125
return [Image(self._connection, **thumbnail) for thumbnail in thumbnails_data]
126126

127-
def _fetch_transcript(self, force: bool = False) -> None:
128-
if self.transcript and not force:
127+
def _fetch_transcript(
128+
self,
129+
start: int = None,
130+
end: int = None,
131+
segmenter: str = None,
132+
count: int = None,
133+
force: bool = None,
134+
) -> None:
135+
if (
136+
self.transcript
137+
and not start
138+
and not end
139+
and not segmenter
140+
and not count
141+
and not force
142+
):
129143
return
130144
transcript_data = self._connection.get(
131145
path=f"{ApiPath.video}/{self.id}/{ApiPath.transcription}",
132-
params={"force": "true" if force else "false"},
146+
params={
147+
"start": start,
148+
"end": end,
149+
"segmenter": segmenter,
150+
"count": count,
151+
"force": "true" if force else "false",
152+
},
133153
show_progress=True,
134154
)
135155
self.transcript = transcript_data.get("word_timestamps", [])
136156
self.transcript_text = transcript_data.get("text", "")
137157

138-
def get_transcript(self, force: bool = False) -> List[Dict]:
139-
self._fetch_transcript(force)
158+
def get_transcript(
159+
self,
160+
start: int = None,
161+
end: int = None,
162+
segmenter: str = None,
163+
count: int = None,
164+
force: bool = None,
165+
) -> List[Dict]:
166+
self._fetch_transcript(
167+
start=start, end=end, segmenter=segmenter, count=count, force=force
168+
)
140169
return self.transcript
141170

142-
def get_transcript_text(self, force: bool = False) -> str:
143-
self._fetch_transcript(force)
171+
def get_transcript_text(
172+
self,
173+
start: int = None,
174+
end: int = None,
175+
segmenter: str = None,
176+
count: int = None,
177+
force: bool = None,
178+
) -> str:
179+
self._fetch_transcript(
180+
start=start, end=end, segmenter=segmenter, count=count, force=force
181+
)
144182
return self.transcript_text
145183

146184
def index_spoken_words(

0 commit comments

Comments
 (0)