Skip to content

Commit

Permalink
Fix: 読点周りを修正
Browse files Browse the repository at this point in the history
  • Loading branch information
sevenc-nanashi committed Nov 23, 2023
1 parent 2211390 commit 7fa4849
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 27 deletions.
5 changes: 4 additions & 1 deletion main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,16 @@ if (store.enginePath != undefined) {
store.enginePath = undefined;
} else {
console.log(`Starting the engine at ${store.enginePath}...`);
new Deno.Command(
const process = new Deno.Command(
store.enginePath,
{
stdout: "inherit",
stderr: "inherit",
},
).spawn();
self.addEventListener("unload", () => {
process.kill();
});
}
} else {
console.log("No engine path, not starting the engine.");
Expand Down
45 changes: 20 additions & 25 deletions providers/synthesis.ts
Original file line number Diff line number Diff line change
Expand Up @@ -83,38 +83,33 @@ const prosodyToAccentPhrases = (prosody: Prosody) => {
const accentPhrasesToProsody = (accentPhrases: AccentPhrase[]) => {
return accentPhrases.map((accentPhrase) => {
const detail = [];
let hasPause = false;

accentPhrase.moras.forEach((mora, i) => {
if (mora.text === "、") {
hasPause = true;
let phoneme;
if (mora.consonant && mora.consonant.length > 0) {
phoneme = `${mora.consonant}-${mora.vowel}`;
} else {
let phoneme;
if (mora.consonant && mora.consonant.length > 0) {
phoneme = `${mora.consonant}-${mora.vowel}`;
} else {
phoneme = mora.vowel;
}

let accent = 0;
if (
i === accentPhrase.accent - 1 ||
(i !== 0 && i <= accentPhrase.accent - 1)
) {
accent = 1;
}
phoneme = mora.vowel;
}

detail.push({
hira: wanakana.toHiragana(
mora.text,
),
phoneme,
accent,
});
let accent = 0;
if (
i === accentPhrase.accent - 1 ||
(i !== 0 && i <= accentPhrase.accent - 1)
) {
accent = 1;
}

detail.push({
hira: wanakana.toHiragana(
mora.text,
),
phoneme,
accent,
});
});

if (hasPause) {
if (accentPhrase.pause_mora) {
detail.push({
hira: "、",
phoneme: "_",
Expand Down
3 changes: 2 additions & 1 deletion store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,5 +45,6 @@ export const getOrAppendSpeaker = async (
};

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

0 comments on commit 7fa4849

Please sign in to comment.