Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

話者ごとのスタイルの中のボイスサンプルやアイコンを必須じゃなくする #1052

Draft
wants to merge 9 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions engine_manifest_assets/downloadable_libraries.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
},
"speaker_info": {
"policy": "",
"icon": "",
"portrait": "",
"style_infos": [
{
Expand Down
37 changes: 22 additions & 15 deletions run.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
from voicevox_engine.engine_manifest.EngineManifest import EngineManifest
from voicevox_engine.engine_manifest.EngineManifestLoader import EngineManifestLoader
from voicevox_engine.library_manager import LibraryManager
from voicevox_engine.metas.Metas import StyleId
from voicevox_engine.metas.Metas import StyleId, StyleInfo
from voicevox_engine.metas.MetasStore import (
MetasStore,
construct_lookup,
Expand Down Expand Up @@ -885,6 +885,7 @@ def _speaker_info(
# speaker_info/
# {speaker_uuid_0}/
# policy.md
# icon.png
# portrait.png
# icons/
# {id_0}.png
Expand Down Expand Up @@ -921,6 +922,9 @@ def _speaker_info(
# speaker policy
policy_path = speaker_path / "policy.md"
policy = policy_path.read_text("utf-8")
# speaker icon
icon_path = speaker_path / "icon.png"
icon = b64encode_str(icon_path.read_bytes())
# speaker portrait
portrait_path = speaker_path / "portrait.png"
portrait = b64encode_str(portrait_path.read_bytes())
Expand All @@ -930,29 +934,31 @@ def _speaker_info(
id = style.id
# style icon
style_icon_path = speaker_path / "icons" / f"{id}.png"
icon = b64encode_str(style_icon_path.read_bytes())
style_icon = None
if style_icon_path.exists():
style_icon = b64encode_str(style_icon_path.read_bytes())
# style portrait
style_portrait_path = speaker_path / "portraits" / f"{id}.png"
style_portrait = None
if style_portrait_path.exists():
style_portrait = b64encode_str(style_portrait_path.read_bytes())
# voice samples
voice_samples = [
b64encode_str(
(
speaker_path
/ "voice_samples/{}_{}.wav".format(id, str(j + 1).zfill(3))
).read_bytes()
)
voice_sample_paths = [
speaker_path / "voice_samples" / f"{id}_{str(j + 1).zfill(3)}.wav"
for j in range(3)
]
voice_samples = None
if all([p.exists() for p in voice_sample_paths]):
voice_samples = [
b64encode_str(p.read_bytes()) for p in voice_sample_paths
]
style_infos.append(
{
"id": id,
"icon": icon,
"portrait": style_portrait,
"voice_samples": voice_samples,
}
StyleInfo(
id=id,
icon=style_icon,
portrait=style_portrait,
voice_samples=voice_samples,
)
)
except FileNotFoundError:
import traceback
Expand All @@ -964,6 +970,7 @@ def _speaker_info(

ret_data = SpeakerInfo(
policy=policy,
icon=icon,
portrait=portrait,
style_infos=style_infos,
)
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

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

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

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

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

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

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

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

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

3 changes: 2 additions & 1 deletion voicevox_engine/dev/core/mock.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,15 @@ def __init__(
def metas(self) -> str:
return json.dumps(
[
# トーク2つ・ハミング2つ
# トーク2つ・ハミング2つ・ソングティーチャー1つ
{
"name": "dummy1",
"styles": [
{"name": "style0", "id": 0},
{"name": "style1", "id": 2},
{"name": "style2", "id": 4, "type": "frame_decode"},
{"name": "style3", "id": 6, "type": "frame_decode"},
{"name": "style4", "id": 6000, "type": "singing_teacher"},
],
"speaker_uuid": "7ffcb7ce-00ec-4bdc-82cd-45a8889e43ff",
"version": "mock",
Expand Down
7 changes: 5 additions & 2 deletions voicevox_engine/metas/Metas.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,11 +84,13 @@ class StyleInfo(BaseModel):
"""

id: StyleId = Field(title="スタイルID")
icon: str = Field(title="当該スタイルのアイコンをbase64エンコードしたもの")
icon: Optional[str] = Field(
title="当該スタイルのアイコンをbase64エンコードしたもの"
)
portrait: Optional[str] = Field(
title="当該スタイルのportrait.pngをbase64エンコードしたもの"
)
voice_samples: List[str] = Field(
voice_samples: Optional[List[str]] = Field(
title="voice_sampleのwavファイルをbase64エンコードしたもの"
)

Expand All @@ -99,5 +101,6 @@ class SpeakerInfo(BaseModel):
"""

policy: str = Field(title="policy.md")
icon: str = Field(title="アイコンをbase64エンコードしたもの")
portrait: str = Field(title="portrait.pngをbase64エンコードしたもの")
style_infos: List[StyleInfo] = Field(title="スタイルの追加情報")
Loading