Skip to content

Commit

Permalink
fix: 불필요 주석 제거
Browse files Browse the repository at this point in the history
  • Loading branch information
cjy3458 committed Aug 25, 2024
1 parent 8d79bdf commit 534c0bb
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 8 deletions.
6 changes: 2 additions & 4 deletions src/components/tales/readTale/ReadTale.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,20 +20,18 @@ const ReadTale = () => {

const selectSentence = (index: number) => {
if (selectedIndex === index) {
// 선택된 문장을 다시 클릭하면 하이라이트 해제 및 음성 중단
setSelectedIndex(null);
window.speechSynthesis.cancel();
setIsSpeaking(false);
} else {
// 새로운 문장 선택 시 이전 음성 취소, 새로운 문장 하이라이트 및 읽기
setSelectedIndex(index);

if (data) {
const textToSpeak = data.story.split("\n")[index];
speakText(
textToSpeak,
() => setIsSpeaking(false), // onEnd callback
() => setIsSpeaking(false) // onPause callback
() => setIsSpeaking(false),
() => setIsSpeaking(false)
);
setIsSpeaking(true);
}
Expand Down
7 changes: 3 additions & 4 deletions src/utils/speechUtil.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ export const speakText = (
utterance.lang = langCode;
utterance.rate = 0.6;

// 현재 재생 중인 모든 음성 중지
window.speechSynthesis.cancel();

if (onEnd) {
Expand All @@ -47,13 +46,13 @@ export const toggleSpeech = (
setIsSpeaking(false);
} else {
if (window.speechSynthesis.speaking) {
window.speechSynthesis.cancel(); // 현재 재생 중인 음성 취소
window.speechSynthesis.cancel();
}

speakText(
text,
() => setIsSpeaking(false), // onEnd callback
() => setIsSpeaking(false) // onPause callback
() => setIsSpeaking(false),
() => setIsSpeaking(false)
);
setIsSpeaking(true);
}
Expand Down

0 comments on commit 534c0bb

Please sign in to comment.