Skip to content

Commit

Permalink
いろいろ更新
Browse files Browse the repository at this point in the history
  • Loading branch information
Hiroshiba committed Dec 27, 2024
1 parent aa88392 commit 3f24ec2
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 24 deletions.
19 changes: 13 additions & 6 deletions src/mock/engineMock/talkModelMock.ts
Original file line number Diff line number Diff line change
Expand Up @@ -181,17 +181,24 @@ export async function textToActtentPhrasesMock(text: string, styleId: number) {
let textPhrase = "";
for (const token of tokens) {
// 記号の場合は無音を入れて区切る
if (token.pos == "記号") {
if (textPhrase.length == 0) continue;

const accentPhrase = textToAccentPhraseMock(textPhrase);
accentPhrase.pauseMora = {
if (token.pos === "記号") {
const pauseMora = {
text: "、",
vowel: "pau",
vowelLength: 1 - 1 / (accentPhrases.length + 1),
pitch: 0,
};
accentPhrases.push(accentPhrase);

// テキストが空の場合は前のアクセント句に無音を追加、空でない場合は新しいアクセント句を追加
let accentPhrase: AccentPhrase;
if (textPhrase.length === 0) {
accentPhrase = accentPhrases[accentPhrases.length - 1];
} else {
accentPhrase = textToAccentPhraseMock(textPhrase);
accentPhrases.push(accentPhrase);
}
accentPhrase.pauseMora = pauseMora;

textPhrase = "";
continue;
}
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
38 changes: 20 additions & 18 deletions tests/e2e/browser/音声詳細.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,40 +14,40 @@ test("単体アクセント句の読み変更", async ({ page }) => {

const textField = page.getByRole("textbox", { name: "1行目" });
await textField.click();
await textField.fill("1234");
await textField.fill("あれもこれもそれもどれも");
await textField.press("Enter");

const inputs = Array.from({ length: 4 }, (_, i) =>
getNthAccentPhraseInput({ page, n: i }),
);

// 読点を追加
await page.getByText("", { exact: true }).click();
await inputs[0].fill("セン、");
await page.getByText("", { exact: true }).click();
await inputs[0].fill("アレモ、");
await inputs[0].press("Enter");
await page.waitForTimeout(100);
await expect(page.getByText("セン、")).toBeVisible();
await expect(page.getByText("アレモ、")).toBeVisible();

// 「,」が読点に変換される
await page.getByText("ヒャ", { exact: true }).click();
await inputs[1].fill("ニヒャク,");
await page.getByText("", { exact: true }).click();
await inputs[1].fill("コレモ,");
await inputs[1].press("Enter");
await page.waitForTimeout(100);
await expect(page.getByText("ニヒャク、")).toBeVisible();
await expect(page.getByText("コレモ、")).toBeVisible();

// 連続する読点を追加すると1つに集約される
await page.getByText("ジュ", { exact: true }).click();
await inputs[2].fill("サンジュウ,、,、");
await page.getByText("", { exact: true }).click();
await inputs[2].fill("ソレモ,、,、");
await inputs[2].press("Enter");
await page.waitForTimeout(100);
await expect(page.getByText("サンジュウ、")).toBeVisible();
await expect(page.getByText("ソレモ、")).toBeVisible();

// 最後のアクセント区間に読点をつけても無視される
await page.getByText("", { exact: true }).click();
await inputs[3].fill("ヨン,、,、");
await page.getByText("", { exact: true }).click();
await inputs[3].fill("ドレモ,、,、");
await inputs[3].press("Enter");
await page.waitForTimeout(100);
await expect(page.getByText("ヨン、")).not.toBeVisible();
await expect(page.getByText("ドレモ、")).not.toBeVisible();
});

test("詳細調整欄のコンテキストメニュー", async ({ page }) => {
Expand All @@ -56,17 +56,19 @@ test("詳細調整欄のコンテキストメニュー", async ({ page }) => {

// 削除
await page.getByRole("textbox", { name: "1行目" }).click();
await page.getByRole("textbox", { name: "1行目" }).fill("1234");
await page
.getByRole("textbox", { name: "1行目" })
.fill("あれもこれもそれもどれも");
await page.getByRole("textbox", { name: "1行目" }).press("Enter");
await page.getByText("サンジュウ").click({
await page.getByText("ソレモ").click({
button: "right",
});
await page
.getByRole("listitem")
.filter({ has: page.getByText("削除") })
.click();
await page.waitForTimeout(100);
await expect(page.getByText("サンジュウ")).not.toBeVisible();
await expect(page.getByText("ニヒャク")).toBeVisible();
await expect(page.getByText("ヨン")).toBeVisible();
await expect(page.getByText("ソレモ")).not.toBeVisible();
await expect(page.getByText("コレモ")).toBeVisible();
await expect(page.getByText("ドレモ")).toBeVisible();
});

0 comments on commit 3f24ec2

Please sign in to comment.