Skip to content

Commit

Permalink
fix: merge segments for html view
Browse files Browse the repository at this point in the history
  • Loading branch information
thewh1teagle committed Nov 13, 2024
1 parent b35770f commit eead362
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
3 changes: 2 additions & 1 deletion desktop/src/components/HtmlView.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { useTranslation } from 'react-i18next'
import { Segment, formatTimestamp } from '~/lib/transcript'
import { Segment, formatTimestamp, mergeSpeakerSegments } from '~/lib/transcript'
import { NamedPath, formatSpeaker } from '~/lib/utils'
import { Preference } from '~/providers/Preference'

Expand All @@ -21,6 +21,7 @@ export function formatDuration(start: number, stop: number, direction: 'rtl' | '
}

export default function HTMLView({ segments, file, preference }: HTMLViewProps) {
segments = mergeSpeakerSegments(segments)
const { t } = useTranslation()
return (
<div
Expand Down
4 changes: 2 additions & 2 deletions desktop/src/lib/transcript.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,12 +45,12 @@ export function formatTimestamp(seconds: number, alwaysIncludeHours: boolean, de
return result
}

function mergeSpeakerSegments(segments: Segment[]) {
export function mergeSpeakerSegments(segments: Segment[]) {
let currentSpeaker: string | undefined
const newSegments: Segment[] = []
let currentSegment: Segment = { speaker: '', text: '', start: 0, stop: 0 }

if (segments?.[0].speaker) {
if (segments?.[0]?.speaker) {
for (const segment of segments) {
// First segment or speaker change
if (!currentSpeaker || segment.speaker !== currentSpeaker) {
Expand Down

0 comments on commit eead362

Please sign in to comment.