Skip to content

Commit

Permalink
sing系のテストも追加
Browse files Browse the repository at this point in the history
  • Loading branch information
Hiroshiba committed Nov 8, 2024
1 parent b536c2b commit 57337a3
Show file tree
Hide file tree
Showing 4 changed files with 147 additions and 1 deletion.
1 change: 0 additions & 1 deletion src/mock/engineMock/talkModelMock.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ async function createOrGetTokenizer() {

return new Promise<Tokenizer<IpadicFeatures>>((resolve, reject) => {
// ブラウザのときはCDNから辞書を取得し、Nodeのときはローカルから取得する
console.log(window);
const isBrowser = global == undefined;
const dicPath = isBrowser
? `https://cdn.jsdelivr.net/npm/kuromoji@${packageJson.devDependencies.kuromoji}/dict`
Expand Down
Binary file not shown.
110 changes: 110 additions & 0 deletions tests/unit/mock/engineMock/__snapshots__/index.spec.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,116 @@ exports[`mock > audioQueryAudioQueryPost 1`] = `
}
`;

exports[`mock > frameSynthesisFrameSynthesisPost 1`] = `"6f4e9484167d90b681365f9bd81a4cc55ec4e77d078943b4d2381e4f0940ed61"`;

exports[`mock > singFrameAudioQuerySingFrameAudioQueryPost 1`] = `
{
"f0": [
0,
0,
0,
0,
0,
0,
0,
0,
0,
46.17422889791779,
46.08055781881967,
46.08055781881967,
46.16797823967303,
46.18048040243588,
46.18048040243588,
82.27312267254713,
82.21745071316357,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
],
"outputSamplingRate": 24000,
"outputStereo": false,
"phonemes": [
{
"frameLength": 9,
"noteId": "a",
"phoneme": "pau",
},
{
"frameLength": 1,
"noteId": "b",
"phoneme": "t",
},
{
"frameLength": 2,
"noteId": "b",
"phoneme": "e",
},
{
"frameLength": 1,
"noteId": "c",
"phoneme": "s",
},
{
"frameLength": 2,
"noteId": "c",
"phoneme": "u",
},
{
"frameLength": 1,
"noteId": "d",
"phoneme": "t",
},
{
"frameLength": 1,
"noteId": "d",
"phoneme": "o",
},
{
"frameLength": 10,
"noteId": "e",
"phoneme": "pau",
},
],
"volume": [
0.7635414345273557,
0.7635414345273557,
0.7635414345273557,
0.7635414345273557,
0.7635414345273557,
0.7635414345273557,
0.7635414345273557,
0.7635414345273557,
0.7635414345273557,
0.7732211475542967,
0.7702900494608796,
0.7702900494608796,
0.7730257409255916,
0.7734165541957456,
0.7734165541957456,
0.7737647610411076,
0.7727873601766926,
0.7635414345273557,
0.7635414345273557,
0.7635414345273557,
0.7635414345273557,
0.7635414345273557,
0.7635414345273557,
0.7635414345273557,
0.7635414345273557,
0.7635414345273557,
0.7635414345273557,
],
"volumeScale": 1,
}
`;

exports[`mock > synthesisSynthesisPost 1`] = `"680a0b3cb0e937d56e3f99304de0d352599439502443bae11828bf875be13bc4"`;

exports[`mock > versionVersionGet 1`] = `"mock"`;
37 changes: 37 additions & 0 deletions tests/unit/mock/engineMock/index.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,4 +28,41 @@ describe("mock", () => {
});
expect(await hash(await response.arrayBuffer())).toMatchSnapshot();
});

it("singFrameAudioQuerySingFrameAudioQueryPost", async () => {
const response = await mock.singFrameAudioQuerySingFrameAudioQueryPost({
speaker: 0,
score: {
notes: [
{ id: "a", key: undefined, frameLength: 10, lyric: "" },
{ id: "b", key: 30, frameLength: 3, lyric: "て" },
{ id: "c", key: 30, frameLength: 3, lyric: "す" },
{ id: "d", key: 40, frameLength: 1, lyric: "と" },
{ id: "e", key: undefined, frameLength: 10, lyric: "" },
],
},
});
expect(response).toMatchSnapshot();
});

it("frameSynthesisFrameSynthesisPost", async () => {
const frameAudioQuery =
await mock.singFrameAudioQuerySingFrameAudioQueryPost({
speaker: 0,
score: {
notes: [
{ id: "a", key: undefined, frameLength: 10, lyric: "" },
{ id: "b", key: 30, frameLength: 3, lyric: "て" },
{ id: "c", key: 30, frameLength: 3, lyric: "す" },
{ id: "d", key: 40, frameLength: 1, lyric: "と" },
{ id: "e", key: undefined, frameLength: 10, lyric: "" },
],
},
});
const response = await mock.frameSynthesisFrameSynthesisPost({
frameAudioQuery,
speaker: 0,
});
expect(await hash(await response.arrayBuffer())).toMatchSnapshot();
});
});

0 comments on commit 57337a3

Please sign in to comment.