TTS for ko_text when ko with abbrev

This commit is contained in:
polv committed 2026-09-07 21:31:43 +07:00
1 parent 0c628cc3f5
commit 5c25d24073
4 files changed
+157 -8

No files matched your search

@@ -1,5 +1,9 @@
<template> <template>
<component :is="lang !== 'ko' || v.audio ? 'span' : TTS" ref="stts"> <component
:is="lang !== 'ko' || v.audio ? 'span' : TTS"
ref="stts"
:text="v.ko_text"
>
<span <span
v-for="(seg, i) in v[lang].split('**')" v-for="(seg, i) in v[lang].split('**')"
:key="i" :key="i"
+12 -6
View File
@@ -24,31 +24,36 @@ defineExpose({
playAudio, playAudio,
}); });
const { lang = "ko-KR" } = defineProps<{ const { lang = "ko-KR", text } = defineProps<{
class?: string; class?: string;
lang?: string; lang?: string;
text?: string;
}>(); }>();
const mainEl = useTemplateRef("main"); const mainEl = useTemplateRef("main");
const audioEl = useTemplateRef("audio"); const audioEl = useTemplateRef("audio");
function getMainText() { function getMainText() {
if (text) return text;
if (!mainEl.value) return ""; if (!mainEl.value) return "";
return mainEl.value.innerText return mainEl.value.innerText
.replace(/[*]/gu, " ") .replace(/[*]/gu, " ")
.replace(/[\p{Ps}\p{Pe}]/gu, ""); .replace(/[\p{Ps}\p{Pe}]/gu, "")
.trim();
} }
async function playAudio() { async function playAudio() {
if (!mainEl.value) return; const mainText = getMainText();
if (!mainText) return;
if (navigator.platform === "Win32" || !(await playAudioTTSPlugin())) { if (navigator.platform === "Win32" || !(await playAudioTTSPlugin())) {
if (!audioEl.value) return; if (!audioEl.value) return;
const url = new URL("/api/tts", location.origin); const url = new URL("/api/tts", location.origin);
url.searchParams.set("voice", "glow-speak:ko_kss"); url.searchParams.set("voice", "glow-speak:ko_kss");
url.searchParams.set("text", getMainText()); url.searchParams.set("text", mainText);
audioEl.value.src = url.href; audioEl.value.src = url.href;
audioEl.value.currentTime = 0; audioEl.value.currentTime = 0;
@@ -57,7 +62,8 @@ async function playAudio() {
} }
async function playAudioTTSPlugin(): Promise<boolean> { async function playAudioTTSPlugin(): Promise<boolean> {
if (!mainEl.value) return false; const mainText = getMainText();
if (!mainText) return false;
const voices = await getVoices(lang); const voices = await getVoices(lang);
if (!voices.length) return false; if (!voices.length) return false;
@@ -69,7 +75,7 @@ async function playAudioTTSPlugin(): Promise<boolean> {
const v = voices[Math.floor(Math.random() * voices.length)]; const v = voices[Math.floor(Math.random() * voices.length)];
console.log(JSON.stringify(v)); console.log(JSON.stringify(v));
await speak({ await speak({
text: getMainText(), text: mainText,
language: null, language: null,
rate: null, rate: null,
volume: null, volume: null,
+1
View File
@@ -2,6 +2,7 @@ import * as z from "zod";
export const Voc = z.object({ export const Voc = z.object({
ko: z.string(), ko: z.string(),
ko_text: z.string().optional(),
audio: z.string().optional(), audio: z.string().optional(),
en: z.string(), en: z.string(),
get usage() { get usage() {
+139 -1
View File
@@ -739,6 +739,134 @@ vocabulary:
examples: examples:
- ko: "**미적분**은 정말 어려워요" - ko: "**미적분**은 정말 어려워요"
en: "**Calculus** is really difficult" en: "**Calculus** is really difficult"
sentence:
being_a_teacher:
- ko: 저는 선생님이에요
en: I am a teacher
- ko: 저는 영어회화 선생님이에요
en: I am an English conversation teacher
- ko: 저는 영어 선생님이에요
en: I am an English teacher
- ko: 저는 곧 선생님이 될 것입니다
en: I will become a teacher soon
- ko: 저는 선생님이 되고 싶어요
en: I want to be/become a teacher
- ko: 저는 언젠가 선생님이 되고 싶어요
en: I want to become a teacher someday
- ko: 담임선생님은 누구예요?
en: Who is your homeroom teacher?
- ko: 저는 한국에서 영어 회화선생님이에요
en: I am an English conversation teacher in Korea
- ko: 무슨 과목을 가르쳐요?
en: What subject do you teach?
- ko: 선생님이 왜 되고 싶었어요?
en: Why did you want to become a teacher?
- ko: 이 학교에서 언제부터 일했어요?
en: Since when have you been at this school?
- ko: 이 학교 일을 어떻게 구했어요?
en: How did you find this position (at this school)?
- ko: 학교에서 몇 시에 퇴근해요?
en: What time do you leave school?
- ko: 집에 몇 시에 가요?
en: What time will you go home?
- ko: 1주일에 수업을 몇 개 가르쳐요?
en: How many classes do you teach per week?
- ko: 하루에 (보통) 수업을 몇 개 가르쳐요?
en: How many classes do you (usually) teach per day?
- ko: 이 사람은 우리 학교(의) 영어 원어민 선생님이에요
en: This person is our school’s native English teacher
- ko: 교장선생님은 선생님들에게 존경 받아요
en: The principal is respected by the teachers
- ko: 학생들은 수업 시간 동안 자고 있었어요
en: The students were sleeping during class
- ko: 그 사람이 선생님인지 아닌지 몰라요
en: I don’t know if that person is a teacher or not
- ko: 내가 선생님이면 학생들을 잘 가르칠 거야
en: If/When I am a teacher, I would teach students well
- ko: 만약 제가 선생님이라면 학생들에게 존경을 받고 싶을 거에요
en: If I were a teacher, I would want to be respected by students
- ko: 이렇게 많은 내용을 학생들에게 가르치려고 고생을 많이 했어요
en: I worked hard/suffered in order to teach that much content to the students
being_a_student:
- ko: 몇 반이에요?
en: What class are you in?
- ko: 몇 학년이에요?
en: What grade are you in?
- ko: 저는 1-2이에요
notes: ("일학년-이반")
ko_text: 저는 일학년-이반이에요
en: I am in class 1-2
- ko: 저는 3학년이에요
en: I’m in third grade
- ko: 저는 내년에 수능을 봐 야 돼요
en: I need to write 수능 next year
- ko: 저는 심심해요
en: I’m bored
- ko: 오늘 수업 시간 동안 뭐 할 거에요?
en: What are we going to do during class today?
- ko: 그 학생은 수업에 집중을 못 해요
en: That student can’t concentrate during class
- ko: 제일 좋아하는 선생님이 누구예요?
en: Who is your favorite teacher?
- ko: 제일 좋아하는 과목이 뭐예요?
en: What is your favorite subject?
- ko: 다음 수업은 뭐에요?
en: What is the next class?
- ko: 저는 학교에 친구가 없어요
en: I have no friends at school
- ko: 저는 학교에 친구가 많아요
en: I have a lot of friends at school
- ko: 선생님, 어디 가세요?
en: Teacher, where are you going?
- ko: 저는 그 학생이 어느 대학교를 다니는 지 기억 안 나요
en: I don’t remember which university that student attends
- ko: 그 학생이 학교에서 왕따인 것 같아
en: That student is probably an outcast at school
- ko: 너는 고등학생 같이 보여
en: You look like a high school student
- ko: 초등학생과 같아요
en: You’re like an elementary school student
--- ---
# (Theme) Unit 1: #1 – School # (Theme) Unit 1: #1 – School
@@ -901,8 +1029,14 @@ Now let’s look at some specific sentences that you may find useful in a school
## Sentences ## Sentences
<VocabQuiz fm-key="sentence" />
### Being a teacher ### Being a teacher
---
<VocabQuiz fm-key="sentence" category="being_a_teacher" />
저는 선생님이에요 = <span class="md spoiler">I am a teacher</span> 저는 선생님이에요 = <span class="md spoiler">I am a teacher</span>
저는 영어회화 선생님이에요 = <span class="md spoiler">I am an English conversation teacher</span> 저는 영어회화 선생님이에요 = <span class="md spoiler">I am an English conversation teacher</span>
@@ -951,11 +1085,15 @@ Now let’s look at some specific sentences that you may find useful in a school
### Being a student ### Being a student
---
<VocabQuiz fm-key="sentence" category="being_a_student" />
몇 반이에요? = <span class="md spoiler">What class are you in?</span> 몇 반이에요? = <span class="md spoiler">What class are you in?</span>
몇 학년이에요? = <span class="md spoiler">What grade are you in?</span> 몇 학년이에요? = <span class="md spoiler">What grade are you in?</span>
저는 1-2이에요 (“일학년-이반) = <span class="md spoiler">I am in class 1-2</span> 저는 1-2이에요 (<span class="md spoiler">일학년-이반</span>) = <span class="md spoiler">I am in class 1-2</span>
저는 3학년이에요 = <span class="md spoiler">I’m in third grade</span> 저는 3학년이에요 = <span class="md spoiler">I’m in third grade</span>