Skip to content

armgit / Cap

Public Imported from GitHub
0

Open source Loom alternative. Beautiful, shareable screen recordings.

feat: Remove special characters from transcription text

Richie McIlroy76622711b15d
diff --git a/apps/web/app/s/[videoId]/_components/ShareVideo.tsx b/apps/web/app/s/[videoId]/_components/ShareVideo.tsx
index 26ba5e0aa..69b8c08b9 100644
--- a/apps/web/app/s/[videoId]/_components/ShareVideo.tsx
+++ b/apps/web/app/s/[videoId]/_components/ShareVideo.tsx
@@ -13,7 +13,6 @@ import { LogoSpinner } from "@cap/ui";
import { userSelectProps } from "@cap/database/auth/session";
import { Tooltip } from "react-tooltip";
import { fromVtt, Subtitle } from "subtitles-parser-vtt";
-import { sub } from "date-fns";
declare global {
interface Window {
@@ -323,7 +322,10 @@ export const ShareVideo = ({
{currentSubtitle && currentSubtitle.text && subtitlesVisible && (
<div className="absolute bottom-0 w-full text-center transform transition p-1.5 lg:p-2.5 xl:p-3.5 -translate-y-16 z-10">
<div className="inline px-2 py-1 text-sm text-white bg-black bg-opacity-75 rounded-xl leading-7 md:text-lg md:leading-9 lg:text-2xl lg:leading-11 2xl:text-3xl 2xl:leading-13 xs:text-base box-decoration-break-clone xs:leading-8 xl:text-2.5xl">
- {currentSubtitle.text}
+ {currentSubtitle.text
+ .replace("- ", "")
+ .replace(".", "")
+ .replace(",", "")}
</div>
</div>
)}
@@ -419,53 +421,54 @@ export const ShareVideo = ({
</div>
<div className="flex justify-end space-x-2">
<div className="flex items-center justify-end space-x-2">
- {data.transcriptionStatus === "COMPLETE" && (
- <span className="inline-flex">
- <button
- aria-label="Disable subtitles"
- className=" inline-flex items-center text-sm font-medium transition ease-in-out duration-150 focus:outline-none border text-slate-100 border-transparent hover:text-white focus:border-white hover:bg-slate-100 hover:bg-opacity-10 active:bg-slate-100 active:bg-opacity-10 px-2 py-2 justify-center rounded-lg"
- tabIndex={0}
- type="button"
- onClick={() => setSubtitlesVisible(!subtitlesVisible)}
- >
- {subtitlesVisible ? (
- <svg
- xmlns="http://www.w3.org/2000/svg"
- fill="none"
- stroke="currentColor"
- strokeLinecap="round"
- strokeLinejoin="round"
- strokeWidth="2"
- className="w-auto h-6"
- viewBox="0 0 24 24"
- >
- <rect
- width="18"
- height="14"
- x="3"
- y="5"
- rx="2"
- ry="2"
- ></rect>
- <path d="M7 15h4m4 0h2M7 11h2m4 0h4"></path>
- </svg>
- ) : (
- <svg
- xmlns="http://www.w3.org/2000/svg"
- fill="none"
- stroke="currentColor"
- strokeLinecap="round"
- strokeLinejoin="round"
- strokeWidth="2"
- className="w-auto h-6"
- viewBox="0 0 24 24"
- >
- <path d="M10.5 5H19a2 2 0 012 2v8.5M17 11h-.5M19 19H5a2 2 0 01-2-2V7a2 2 0 012-2M2 2l20 20M7 11h4M7 15h2.5"></path>
- </svg>
- )}
- </button>
- </span>
- )}
+ {data.transcriptionStatus === "COMPLETE" &&
+ subtitles.length > 0 && (
+ <span className="inline-flex">
+ <button
+ aria-label="Disable subtitles"
+ className=" inline-flex items-center text-sm font-medium transition ease-in-out duration-150 focus:outline-none border text-slate-100 border-transparent hover:text-white focus:border-white hover:bg-slate-100 hover:bg-opacity-10 active:bg-slate-100 active:bg-opacity-10 px-2 py-2 justify-center rounded-lg"
+ tabIndex={0}
+ type="button"
+ onClick={() => setSubtitlesVisible(!subtitlesVisible)}
+ >
+ {subtitlesVisible ? (
+ <svg
+ xmlns="http://www.w3.org/2000/svg"
+ fill="none"
+ stroke="currentColor"
+ strokeLinecap="round"
+ strokeLinejoin="round"
+ strokeWidth="2"
+ className="w-auto h-6"
+ viewBox="0 0 24 24"
+ >
+ <rect
+ width="18"
+ height="14"
+ x="3"
+ y="5"
+ rx="2"
+ ry="2"
+ ></rect>
+ <path d="M7 15h4m4 0h2M7 11h2m4 0h4"></path>
+ </svg>
+ ) : (
+ <svg
+ xmlns="http://www.w3.org/2000/svg"
+ fill="none"
+ stroke="currentColor"
+ strokeLinecap="round"
+ strokeLinejoin="round"
+ strokeWidth="2"
+ className="w-auto h-6"
+ viewBox="0 0 24 24"
+ >
+ <path d="M10.5 5H19a2 2 0 012 2v8.5M17 11h-.5M19 19H5a2 2 0 01-2-2V7a2 2 0 012-2M2 2l20 20M7 11h4M7 15h2.5"></path>
+ </svg>
+ )}
+ </button>
+ </span>
+ )}
<span className="inline-flex">
<button
aria-label="Mute video"