Skip to content

Commit

Permalink
追加:AudioQuery.pauseLengthのSkipJsonSchemaをなくす (#1430)
Browse files Browse the repository at this point in the history
* pauseLengthのSkipJsonSchemaをなくす

* nullのときの処理を追加

* デフォルト値追記

* python -m pytest --snapshot-update
  • Loading branch information
Hiroshiba authored Jun 26, 2024
1 parent f2bba11 commit ca83fa5
Show file tree
Hide file tree
Showing 4 changed files with 53 additions and 6 deletions.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,6 @@
# name: test_post_synthesis_200
'MD5:f7d42ce5787856549abc3d2d7561c06f'
# ---
# name: test_post_synthesis_old_audio_query_200
'MD5:f7d42ce5787856549abc3d2d7561c06f'
# ---
34 changes: 34 additions & 0 deletions test/e2e/single_api/tts_pipeline/test_synthesis.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,3 +41,37 @@ def test_post_synthesis_200(client: TestClient, snapshot: SnapshotAssertion) ->
# 音声波形が一致する
assert response.headers["content-type"] == "audio/wav"
assert snapshot == hash_wave_floats_from_wav_bytes(response.read())


def test_post_synthesis_old_audio_query_200(
client: TestClient, snapshot: SnapshotAssertion
) -> None:
"""古いバージョンの audio_query でもエラーなく合成できる"""
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,
}
response = client.post("/synthesis", params={"speaker": 0}, json=query)
assert response.status_code == 200

# 音声波形が一致する
assert response.headers["content-type"] == "audio/wav"
assert snapshot == hash_wave_floats_from_wav_bytes(response.read())
9 changes: 6 additions & 3 deletions voicevox_engine/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,13 @@ class AudioQuery(BaseModel):
volumeScale: float = Field(title="全体の音量")
prePhonemeLength: float = Field(title="音声の前の無音時間")
postPhonemeLength: float = Field(title="音声の後の無音時間")
pauseLength: float | SkipJsonSchema[None] = Field(
default=None, title="句読点などの無音時間"
pauseLength: float | None = Field(
default=None,
title="句読点などの無音時間。nullのときは無視される。デフォルト値はnull",
)
pauseLengthScale: float = Field(
default=1, title="句読点などの無音時間(倍率)。デフォルト値は1"
)
pauseLengthScale: float = Field(default=1, title="句読点などの無音時間(倍率)")
outputSamplingRate: int = Field(title="音声データの出力サンプリングレート")
outputStereo: bool = Field(title="音声データをステレオ出力するか否か")
kana: str | SkipJsonSchema[None] = Field(
Expand Down

0 comments on commit ca83fa5

Please sign in to comment.