fix dash mark in transcript

This commit is contained in:
an-lee
2024-03-29 06:44:48 +08:00
parent 8df6a9b9aa
commit 98d3fa4b99
2 changed files with 30 additions and 15 deletions

View File

@@ -193,22 +193,26 @@ const SelectedTabContent = (props: {
<div className="font-serif text-lg font-semibold tracking-tight">
{word.text}
</div>
<div className="text-sm text-serif text-muted-foreground">
<span
className={`mr-2 font-code ${i === 0 ? "before:content-['/']" : ""
}
{
word.timeline.length > 0 && (
<div className="text-sm text-serif text-muted-foreground">
<span
className={`mr-2 font-code ${i === 0 ? "before:content-['/']" : ""
}
${i === selectedIndices.length - 1
? "after:content-['/']"
: ""
}`}
>
{word.timeline
.map((t) =>
t.timeline.map((s) => convertIpaToNormal(s.text)).join("")
)
.join("")}
</span>
</div>
? "after:content-['/']"
: ""
}`}
>
{word.timeline
.map((t) =>
t.timeline.map((s) => convertIpaToNormal(s.text)).join("")
)
.join("")}
</span>
</div>
)
}
</div>
);
})}

View File

@@ -118,6 +118,17 @@ export const useTranscriptions = (media: AudioType | VideoType) => {
const match = word?.match(/-|%/);
if (!match) return;
if (word === '-') {
sentence.timeline.splice(j, 0, {
type: 'token',
text: '-',
startTime: sentence.timeline[j - 1].endTime,
endTime: token.startTime,
timeline: [],
})
return;
}
for (let k = j + 1; k <= sentence.timeline.length - 1; k++) {
if (word.includes(sentence.timeline[k].text.toLowerCase())) {
let connector = "";