Skip to content

Commit 7fa4849

Browse files
Fix: 読点周りを修正
1 parent 2211390 commit 7fa4849

File tree

3 files changed

+26
-27
lines changed

3 files changed

+26
-27
lines changed

main.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,13 +27,16 @@ if (store.enginePath != undefined) {
2727
store.enginePath = undefined;
2828
} else {
2929
console.log(`Starting the engine at ${store.enginePath}...`);
30-
new Deno.Command(
30+
const process = new Deno.Command(
3131
store.enginePath,
3232
{
3333
stdout: "inherit",
3434
stderr: "inherit",
3535
},
3636
).spawn();
37+
self.addEventListener("unload", () => {
38+
process.kill();
39+
});
3740
}
3841
} else {
3942
console.log("No engine path, not starting the engine.");

providers/synthesis.ts

Lines changed: 20 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -83,38 +83,33 @@ const prosodyToAccentPhrases = (prosody: Prosody) => {
8383
const accentPhrasesToProsody = (accentPhrases: AccentPhrase[]) => {
8484
return accentPhrases.map((accentPhrase) => {
8585
const detail = [];
86-
let hasPause = false;
8786

8887
accentPhrase.moras.forEach((mora, i) => {
89-
if (mora.text === "、") {
90-
hasPause = true;
88+
let phoneme;
89+
if (mora.consonant && mora.consonant.length > 0) {
90+
phoneme = `${mora.consonant}-${mora.vowel}`;
9191
} else {
92-
let phoneme;
93-
if (mora.consonant && mora.consonant.length > 0) {
94-
phoneme = `${mora.consonant}-${mora.vowel}`;
95-
} else {
96-
phoneme = mora.vowel;
97-
}
98-
99-
let accent = 0;
100-
if (
101-
i === accentPhrase.accent - 1 ||
102-
(i !== 0 && i <= accentPhrase.accent - 1)
103-
) {
104-
accent = 1;
105-
}
92+
phoneme = mora.vowel;
93+
}
10694

107-
detail.push({
108-
hira: wanakana.toHiragana(
109-
mora.text,
110-
),
111-
phoneme,
112-
accent,
113-
});
95+
let accent = 0;
96+
if (
97+
i === accentPhrase.accent - 1 ||
98+
(i !== 0 && i <= accentPhrase.accent - 1)
99+
) {
100+
accent = 1;
114101
}
102+
103+
detail.push({
104+
hira: wanakana.toHiragana(
105+
mora.text,
106+
),
107+
phoneme,
108+
accent,
109+
});
115110
});
116111

117-
if (hasPause) {
112+
if (accentPhrase.pause_mora) {
118113
detail.push({
119114
hira: "、",
120115
phoneme: "_",

store.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,5 +45,6 @@ export const getOrAppendSpeaker = async (
4545
};
4646

4747
export const saveStore = async () => {
48-
await Deno.writeTextFile(filePath, JSON.stringify(store));
48+
await Deno.writeTextFile(filePath + ".tmp", JSON.stringify(store));
49+
await Deno.rename(filePath + ".tmp", filePath);
4950
};

0 commit comments

Comments
 (0)