-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* feat: PWA 적용 * feat: Toast 알람시 TTS 기능 추가 * feat: 서버 주소 변경
- Loading branch information
Showing
4 changed files
with
76 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
// @ts-ignore | ||
|
||
export const getSpeech = (text: string) => { | ||
let voices: any[] = []; | ||
|
||
const setVoiceList = () => { | ||
voices = window.speechSynthesis.getVoices(); | ||
}; | ||
setVoiceList(); | ||
|
||
window.speechSynthesis.onvoiceschanged = setVoiceList; | ||
|
||
const speech = (text: string) => { | ||
const lang = "ko-KR"; | ||
const utterThis = new SpeechSynthesisUtterance(text); | ||
|
||
utterThis.lang = lang; | ||
|
||
const kor_voice = voices.find( | ||
(elem) => elem.lang == lang || elem.lang === lang.replace("-", "_") | ||
); | ||
|
||
if (kor_voice) { | ||
utterThis.voice = kor_voice; | ||
} else { | ||
return; | ||
} | ||
|
||
window.speechSynthesis.speak(utterThis); | ||
}; | ||
|
||
speech(text); | ||
}; |