-
Notifications
You must be signed in to change notification settings - Fork 198
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
歌声合成系のe2eテストを追加
- Loading branch information
Showing
2 changed files
with
43 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
# serializer version: 1 | ||
# name: test_スコアとキャラクターIDから音声を合成できる | ||
'MD5:1c385210acba238994604a8cee96aee3' | ||
# --- |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
""" | ||
歌唱のテスト | ||
""" | ||
|
||
from test.utility import hash_wave_floats_from_wav_bytes | ||
|
||
from fastapi.testclient import TestClient | ||
from syrupy.assertion import SnapshotAssertion | ||
|
||
|
||
def test_スコアとキャラクターIDから音声を合成できる( | ||
client: TestClient, snapshot: SnapshotAssertion | ||
) -> None: | ||
# スコアとキャラクター ID から FrameAudioQuery を生成する | ||
score = { | ||
"notes": [ | ||
{"key": None, "frame_length": 10, "lyric": ""}, | ||
{"key": 30, "frame_length": 3, "lyric": "て"}, | ||
{"key": 30, "frame_length": 3, "lyric": "す"}, | ||
{"key": 40, "frame_length": 1, "lyric": "と"}, | ||
{"key": None, "frame_length": 10, "lyric": ""}, | ||
] | ||
} | ||
frame_audio_query_res = client.post( | ||
"/sing_frame_audio_query", params={"speaker": 0}, json=score | ||
) | ||
frame_audio_query = frame_audio_query_res.json() | ||
|
||
# FrameAudioQuery から音声波形を生成する | ||
frame_synthesis_res = client.post( | ||
"/frame_synthesis", params={"speaker": 0}, json=frame_audio_query | ||
) | ||
|
||
# リクエストが成功している | ||
assert frame_synthesis_res.status_code == 200 | ||
|
||
# FileResponse 内の .wav から抽出された音声波形が一致する | ||
assert frame_synthesis_res.headers["content-type"] == "audio/wav" | ||
assert snapshot == hash_wave_floats_from_wav_bytes(frame_synthesis_res.read()) |