From 130c4f2bd9c67fe8a262f585aba26f7abc237722 Mon Sep 17 00:00:00 2001 From: Sergey Mankovsky Date: Mon, 17 Jun 2024 17:20:30 +0200 Subject: [PATCH] Bring back live transcription --- .../[transcriptId]/record/page.tsx | 41 ++++++++++++++++--- 1 file changed, 36 insertions(+), 5 deletions(-) diff --git a/www/app/[domain]/transcripts/[transcriptId]/record/page.tsx b/www/app/[domain]/transcripts/[transcriptId]/record/page.tsx index fa60ec56..a4840113 100644 --- a/www/app/[domain]/transcripts/[transcriptId]/record/page.tsx +++ b/www/app/[domain]/transcripts/[transcriptId]/record/page.tsx @@ -1,5 +1,5 @@ "use client"; -import React, { useEffect, useState } from "react"; +import { useEffect, useState } from "react"; import Recorder from "../../recorder"; import { TopicList } from "../../topicList"; import useTranscript from "../../useTranscript"; @@ -11,7 +11,8 @@ import { useRouter } from "next/navigation"; import Player from "../../player"; import useMp3 from "../../useMp3"; import WaveformLoading from "../../waveformLoading"; -import { Box, Grid } from "@chakra-ui/react"; +import { Box, Text, Grid } from "@chakra-ui/react"; +import LiveTrancription from "../../liveTranscription"; type TranscriptDetails = { params: { @@ -21,7 +22,7 @@ type TranscriptDetails = { const TranscriptRecord = (details: TranscriptDetails) => { const transcript = useTranscript(details.params.transcriptId); - + const [transcriptStarted, setTranscriptStarted] = useState(false); const useActiveTopic = useState(null); const webSockets = useWebSockets(details.params.transcriptId); @@ -34,6 +35,11 @@ const TranscriptRecord = (details: TranscriptDetails) => { webSockets.status.value || transcript.response?.status || "idle" ); + useEffect(() => { + if (!transcriptStarted && webSockets.transcriptTextLive.length !== 0) + setTranscriptStarted(true); + }, [webSockets.transcriptTextLive]); + useEffect(() => { //TODO HANDLE ERROR STATUS BETTER const newStatus = @@ -83,9 +89,17 @@ const TranscriptRecord = (details: TranscriptDetails) => { // todo: only start recording animation when you get "recorded" status )} - @@ -97,7 +111,24 @@ const TranscriptRecord = (details: TranscriptDetails) => { status={status} currentTranscriptText={webSockets.accumulatedText} /> - + + {!transcriptStarted ? ( + + + The conversation transcript will appear here shortly after you + start recording. + + + ) : ( + status === "recording" && ( + + ) + )} + + ); };