-
Notifications
You must be signed in to change notification settings - Fork 206
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* refactor: TTS系 single_api テスト追加 * fix: モーラ生成 util と lint * fix: lint * fix: path * fix: lint * fix: テストスキップ形式
- Loading branch information
Showing
7 changed files
with
168 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,12 @@ | ||
""" | ||
/accent_phrases API のテスト | ||
""" | ||
|
||
from fastapi.testclient import TestClient | ||
|
||
|
||
def test_post_accent_phrases_200(client: TestClient) -> None: | ||
response = client.post( | ||
"/accent_phrases", params={"text": "テストです", "speaker": 0} | ||
) | ||
assert response.status_code == 200 |
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,21 @@ | ||
""" | ||
/audio_query_from_preset API のテスト | ||
""" | ||
|
||
import pytest | ||
from fastapi.testclient import TestClient | ||
|
||
|
||
@pytest.mark.skip(reason="200の前提として別APIを要するプリセット登録が必要だから") | ||
def test_post_audio_query_from_preset_200(client: TestClient) -> None: | ||
response = client.post( | ||
"/audio_query_from_preset", params={"text": "テストです", "preset_id": 0} | ||
) | ||
assert response.status_code == 200 | ||
|
||
|
||
def test_post_audio_query_from_preset_422(client: TestClient) -> None: | ||
response = client.post( | ||
"/audio_query_from_preset", params={"text": "テストです", "preset_id": 404} | ||
) | ||
assert response.status_code == 422 |
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,24 @@ | ||
""" | ||
/mora_data API のテスト | ||
""" | ||
|
||
from test.e2e.single_api.utils import gen_mora | ||
|
||
from fastapi.testclient import TestClient | ||
|
||
|
||
def test_post_mora_data_200(client: TestClient) -> None: | ||
accent_phrases = [ | ||
{ | ||
"moras": [ | ||
gen_mora("テ", "t", 2.3, "e", 0.8, 3.3), | ||
gen_mora("ス", "s", 2.1, "U", 0.3, 0.0), | ||
gen_mora("ト", "t", 2.3, "o", 1.8, 4.1), | ||
], | ||
"accent": 1, | ||
"pause_mora": None, | ||
"is_interrogative": False, | ||
} | ||
] | ||
response = client.post("/mora_data", params={"speaker": 0}, json=accent_phrases) | ||
assert response.status_code == 200 |
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,24 @@ | ||
""" | ||
/mora_length API のテスト | ||
""" | ||
|
||
from test.e2e.single_api.utils import gen_mora | ||
|
||
from fastapi.testclient import TestClient | ||
|
||
|
||
def test_post_mora_length_200(client: TestClient) -> None: | ||
accent_phrases = [ | ||
{ | ||
"moras": [ | ||
gen_mora("テ", "t", 2.3, "e", 0.8, 3.3), | ||
gen_mora("ス", "s", 2.1, "U", 0.3, 0.0), | ||
gen_mora("ト", "t", 2.3, "o", 1.8, 4.1), | ||
], | ||
"accent": 1, | ||
"pause_mora": None, | ||
"is_interrogative": False, | ||
} | ||
] | ||
response = client.post("/mora_length", params={"speaker": 0}, json=accent_phrases) | ||
assert response.status_code == 200 |
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,24 @@ | ||
""" | ||
/mora_pitch API のテスト | ||
""" | ||
|
||
from test.e2e.single_api.utils import gen_mora | ||
|
||
from fastapi.testclient import TestClient | ||
|
||
|
||
def test_post_mora_pitch_200(client: TestClient) -> None: | ||
accent_phrases = [ | ||
{ | ||
"moras": [ | ||
gen_mora("テ", "t", 2.3, "e", 0.8, 3.3), | ||
gen_mora("ス", "s", 2.1, "U", 0.3, 0.0), | ||
gen_mora("ト", "t", 2.3, "o", 1.8, 4.1), | ||
], | ||
"accent": 1, | ||
"pause_mora": None, | ||
"is_interrogative": False, | ||
} | ||
] | ||
response = client.post("/mora_pitch", params={"speaker": 0}, json=accent_phrases) | ||
assert response.status_code == 200 |
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,35 @@ | ||
""" | ||
/synthesis API のテスト | ||
""" | ||
|
||
from test.e2e.single_api.utils import gen_mora | ||
|
||
from fastapi.testclient import TestClient | ||
|
||
|
||
def test_post_synthesis_200(client: TestClient) -> None: | ||
query = { | ||
"accent_phrases": [ | ||
{ | ||
"moras": [ | ||
gen_mora("テ", "t", 2.3, "e", 0.8, 3.3), | ||
gen_mora("ス", "s", 2.1, "U", 0.3, 0.0), | ||
gen_mora("ト", "t", 2.3, "o", 1.8, 4.1), | ||
], | ||
"accent": 1, | ||
"pause_mora": None, | ||
"is_interrogative": False, | ||
} | ||
], | ||
"speedScale": 1.0, | ||
"pitchScale": 1.0, | ||
"intonationScale": 1.0, | ||
"volumeScale": 1.0, | ||
"prePhonemeLength": 0.1, | ||
"postPhonemeLength": 0.1, | ||
"outputSamplingRate": 24000, | ||
"outputStereo": False, | ||
"kana": "テ'_スト", | ||
} | ||
response = client.post("/synthesis", params={"speaker": 0}, json=query) | ||
assert response.status_code == 200 |
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,28 @@ | ||
from typing import TypedDict | ||
|
||
|
||
class MoraForTest(TypedDict): | ||
text: str | ||
consonant: str | ||
consonant_length: float | ||
vowel: str | ||
vowel_length: float | ||
pitch: float | ||
|
||
|
||
def gen_mora( | ||
text: str, | ||
consonant: str, | ||
consonant_length: float, | ||
vowel: str, | ||
vowel_length: float, | ||
pitch: float, | ||
) -> MoraForTest: | ||
return { | ||
"text": text, | ||
"consonant": consonant, | ||
"consonant_length": consonant_length, | ||
"vowel": vowel, | ||
"vowel_length": vowel_length, | ||
"pitch": pitch, | ||
} |