Skip to content

Commit

Permalink
refactor: rename transcript to transcription in VideoClipRecord and u…
Browse files Browse the repository at this point in the history
…pdate related logic in Edit component
  • Loading branch information
saebyn committed Dec 25, 2024
1 parent 318298d commit cc7f9e6
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 3 deletions.
28 changes: 26 additions & 2 deletions src/resources/episodes/Edit.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -180,13 +180,27 @@ ${record.description}
Here is the transcript:
`;

let elapsedTime = 0;

const transcriptionSegments = videoClips.flatMap(
(videoClip: VideoClipRecord): Array<TranscriptSegment> => {
if (!videoClip.transcript) {
if (!videoClip.transcription) {
return [];
}

return videoClip.transcript.segments;
const startOffset = elapsedTime;

if (videoClip.metadata?.format.duration === undefined) {
throw new Error('Duration is undefined');
}

elapsedTime += videoClip.metadata.format.duration;

return videoClip.transcription.segments.map((segment) => ({
...segment,
start: segment.start + startOffset,
end: segment.end + startOffset,
}));
},
);

Expand All @@ -196,6 +210,16 @@ ${record.description}

let episodeStart: null | number = null;

console.log('transcriptionSegments', transcriptionSegments);

console.log('tracks', {
start: parseIntoSeconds(record.tracks[0].start),
end: parseIntoSeconds(record.tracks[0].end),
res: transcriptionSegments.filter((segment) =>
transcriptSegmentOverlaps(segment, record),
),
});

const transcript = transcriptionSegments
.filter((segment) => transcriptSegmentOverlaps(segment, record))
.map((segment: TranscriptSegment) => {
Expand Down
2 changes: 1 addition & 1 deletion src/types/dataProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ export interface VideoClipRecord extends RaRecord {
* The list of detected silence intervals in the video clip.
*/
silence?: Array<{ start: number; end: number }>;
transcript?: {
transcription?: {
language: string;
text: string;
segments: Array<TranscriptSegment>;
Expand Down

0 comments on commit cc7f9e6

Please sign in to comment.