From 3c247dca781e64cde831b4acc30c9c7fe84fd358 Mon Sep 17 00:00:00 2001 From: Hiroshiba Date: Tue, 20 Aug 2024 02:54:38 +0900 Subject: [PATCH] =?UTF-8?q?Add:=20=E6=AD=8C=E5=A3=B0=E5=90=88=E6=88=90?= =?UTF-8?q?=E7=B3=BB=E3=81=AEe2e=E3=83=86=E3=82=B9=E3=83=88=E3=82=92?= =?UTF-8?q?=E8=BF=BD=E5=8A=A0=20(#1459)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 歌声合成系のe2eテストを追加 --- test/e2e/__snapshots__/test_sing.ambr | 4 +++ test/e2e/test_sing.py | 39 +++++++++++++++++++++++++++ 2 files changed, 43 insertions(+) create mode 100644 test/e2e/__snapshots__/test_sing.ambr create mode 100644 test/e2e/test_sing.py diff --git a/test/e2e/__snapshots__/test_sing.ambr b/test/e2e/__snapshots__/test_sing.ambr new file mode 100644 index 000000000..befdd6cca --- /dev/null +++ b/test/e2e/__snapshots__/test_sing.ambr @@ -0,0 +1,4 @@ +# serializer version: 1 +# name: test_スコアとキャラクターIDから音声を合成できる + 'MD5:1c385210acba238994604a8cee96aee3' +# --- diff --git a/test/e2e/test_sing.py b/test/e2e/test_sing.py new file mode 100644 index 000000000..dedd8351b --- /dev/null +++ b/test/e2e/test_sing.py @@ -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())