Skip to content

Commit f57171f

Browse files
authored
Merge pull request #27 from KWcapstone/25-feat-time-stamp-test
실시간 스크립트 생성
2 parents 8b10f2b + 6e6964e commit f57171f

File tree

6 files changed

+134
-202
lines changed

6 files changed

+134
-202
lines changed

src/views/meeting/components/MindMapComponent.tsx

Lines changed: 28 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -9,33 +9,50 @@ import UseSpeechToText from "@/views/meeting/components/UseSpeechToText";
99
import useRecordingTimer from "@/views/meeting/components/RecodingTimer";
1010

1111
// import
12-
1312
import { useEffect, useState } from "react";
1413

15-
const MindMapComponent = () => {
14+
interface scriptData {
15+
time: string;
16+
script: string;
17+
}
18+
19+
interface MindMapComponentProps {
20+
setScripts: React.Dispatch<React.SetStateAction<scriptData[]>>;
21+
}
22+
23+
const MindMapComponent = ({ setScripts }: MindMapComponentProps) => {
1624
const {
17-
transcript,
25+
// transcript,
1826
isRecording,
1927
isPaused,
2028
toggleListening,
2129
pauseRecording,
2230
resumeRecording,
31+
finalTranscript,
32+
resetTranscript,
2333
// audioUrl,
2434
} = UseSpeechToText();
25-
const { formattedTime, resetTimer } = useRecordingTimer(
26-
isRecording,
27-
isPaused
28-
);
35+
const { formattedTime } = useRecordingTimer(isRecording, isPaused);
2936

3037
useEffect(() => {
31-
if (transcript) {
32-
console.log("🎙️ 인식된 텍스트:", transcript);
38+
if (finalTranscript !== "") {
39+
console.log("🎙️ 시간", formattedTime);
40+
console.log("🎙️ 인식된 텍스트:", finalTranscript);
41+
setScripts((prev) => [
42+
...prev,
43+
{
44+
time: formattedTime,
45+
script: finalTranscript,
46+
},
47+
]);
3348
}
34-
}, [transcript]);
49+
50+
// 여기서 백엔드한테 보내기
51+
resetTranscript();
52+
}, [finalTranscript]);
3553

3654
const stopClick = () => {
3755
toggleListening();
38-
resetTimer();
3956
};
4057

4158
const [mode, setMode] = useState<string>("none");

src/views/meeting/components/RecodingTimer.tsx

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -24,24 +24,20 @@ const useRecordingTimer = (isRecording: boolean, isPaused: boolean) => {
2424
};
2525
}, [isRecording, isPaused]);
2626

27-
const resetTimer = () => {
28-
setElapsedTime(0);
29-
if (timerRef.current) {
30-
clearInterval(timerRef.current);
31-
timerRef.current = null;
32-
}
33-
};
34-
3527
const formatTime = (seconds: number) => {
3628
const mins = String(Math.floor(seconds / 60)).padStart(2, "0");
3729
const secs = String(seconds % 60).padStart(2, "0");
3830
return `${mins}:${secs}`;
3931
};
4032

33+
const timeStamp = (seconds: number) => {
34+
return formatTime(seconds);
35+
};
36+
4137
return {
4238
elapsedTime,
4339
formattedTime: formatTime(elapsedTime),
44-
resetTimer,
40+
timeStamp,
4541
};
4642
};
4743

0 commit comments

Comments
 (0)