From 98d3fa4b99d487d733437f4c08d9a00249d7ee2d Mon Sep 17 00:00:00 2001 From: an-lee Date: Fri, 29 Mar 2024 06:44:48 +0800 Subject: [PATCH] fix dash mark in transcript --- .../components/medias/media-caption-tabs.tsx | 34 +++++++++++-------- .../src/renderer/hooks/use-transcriptions.tsx | 11 ++++++ 2 files changed, 30 insertions(+), 15 deletions(-) diff --git a/enjoy/src/renderer/components/medias/media-caption-tabs.tsx b/enjoy/src/renderer/components/medias/media-caption-tabs.tsx index 2da381d7..baaab66e 100644 --- a/enjoy/src/renderer/components/medias/media-caption-tabs.tsx +++ b/enjoy/src/renderer/components/medias/media-caption-tabs.tsx @@ -193,22 +193,26 @@ const SelectedTabContent = (props: {
{word.text}
-
- 0 && ( +
+ - {word.timeline - .map((t) => - t.timeline.map((s) => convertIpaToNormal(s.text)).join("") - ) - .join("")} - -
+ ? "after:content-['/']" + : "" + }`} + > + {word.timeline + .map((t) => + t.timeline.map((s) => convertIpaToNormal(s.text)).join("") + ) + .join("")} +
+
+ ) + } ); })} diff --git a/enjoy/src/renderer/hooks/use-transcriptions.tsx b/enjoy/src/renderer/hooks/use-transcriptions.tsx index 2d07276d..3972c3b9 100644 --- a/enjoy/src/renderer/hooks/use-transcriptions.tsx +++ b/enjoy/src/renderer/hooks/use-transcriptions.tsx @@ -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 = "";