Skip to content

Commit

Permalink
歌声合成系のe2eテストを追加
Browse files Browse the repository at this point in the history
  • Loading branch information
Hiroshiba committed Aug 17, 2024
1 parent eb68867 commit 45408c1
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 0 deletions.
4 changes: 4 additions & 0 deletions test/e2e/__snapshots__/test_sing.ambr
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# serializer version: 1
# name: test_スコアとキャラクターIDから音声を合成できる
'MD5:1c385210acba238994604a8cee96aee3'
# ---
39 changes: 39 additions & 0 deletions test/e2e/test_sing.py
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())

0 comments on commit 45408c1

Please sign in to comment.