Skip to content

Commit a895c13

Browse files
committed
Update: AivisHub の音声合成モデル詳細ページの URL が渡された場合、特別に AivisHub API を使い AIVMX ファイルをダウンロードする
1 parent 02111f7 commit a895c13

File tree

3 files changed

+25
-4
lines changed

3 files changed

+25
-4
lines changed

resources/engine_manifest_assets/dependency_licenses.json

+1-1
Large diffs are not rendered by default.

voicevox_engine/aivm_manager.py

+21
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import asyncio
44
import glob
55
import hashlib
6+
import re
67
from io import BytesIO
78
from pathlib import Path
89
from threading import Thread
@@ -643,6 +644,26 @@ def install_aivm_from_url(self, url: str) -> None:
643644
AIVMX ファイルの URL
644645
"""
645646

647+
# AivisHub の音声合成モデル詳細ページの URL が渡された場合、特別に AivisHub API を使い AIVMX ファイルをダウンロードする
648+
if url.startswith("https://hub.aivis-project.com/aivm-models/"):
649+
# URL から AIVM の UUID を抽出
650+
uuid_match = re.search(
651+
r"/aivm-models/([0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12})",
652+
url.lower(),
653+
)
654+
if not uuid_match:
655+
raise HTTPException(
656+
status_code=422,
657+
detail="Invalid AivisHub URL.",
658+
)
659+
# group(0) は一致した文字列全体なので、group(1) で UUID 部分のみを取得
660+
aivm_uuid = uuid_match.group(1)
661+
# AIVMX ダウンロード用の API の URL に置き換え
662+
url = f"{self.AIVISHUB_API_BASE_URL}/aivm-models/{aivm_uuid}/download?model_type=AIVMX"
663+
logger.info(
664+
f"Detected AivisHub model page URL. Using download API URL: {url}"
665+
)
666+
646667
# URL から AIVMX ファイルをダウンロード
647668
try:
648669
logger.info(f"Downloading AIVMX file from {url}...")

voicevox_engine/user_dict/user_dict_manager.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -308,19 +308,19 @@ def rewrite_word(self, word_uuid: str, word_property: WordProperty) -> None:
308308
# 既存単語の上書きによる辞書データの更新
309309
user_dict = self.read_dict()
310310
if word_uuid not in user_dict:
311-
raise UserDictInputError("UUIDに該当するワードが見つかりませんでした")
311+
raise UserDictInputError("UUID に該当する単語が見つかりませんでした")
312312
user_dict[word_uuid] = create_word(word_property)
313313

314314
# 更新された辞書データの保存と適用
315315
self._write_to_json(user_dict)
316316
self.update_dict()
317317

318318
def delete_word(self, word_uuid: str) -> None:
319-
"""単語UUIDで指定された単語を削除する。"""
319+
"""単語 UUID で指定された単語を削除する。"""
320320
# 既存単語の削除による辞書データの更新
321321
user_dict = self.read_dict()
322322
if word_uuid not in user_dict:
323-
raise UserDictInputError("IDに該当するワードが見つかりませんでした")
323+
raise UserDictInputError("UUID に該当する単語が見つかりませんでした")
324324
del user_dict[word_uuid]
325325

326326
# 更新された辞書データの保存と適用

0 commit comments

Comments
 (0)