diff --git a/build_util/get_cost_candidates.py b/build_util/get_cost_candidates.py index 2eabb4eeb..15de04175 100644 --- a/build_util/get_cost_candidates.py +++ b/build_util/get_cost_candidates.py @@ -19,7 +19,6 @@ import argparse import statistics from pathlib import Path -from typing import List import numpy as np @@ -30,7 +29,7 @@ def get_candidates( pos_detail_1: str, pos_detail_2: str, pos_detail_3: str, -) -> List[int]: +) -> list[int]: costs = [] with naist_jdic_path.open(encoding="utf-8") as f: for line in f: diff --git a/voicevox_engine/cancellable_engine.py b/voicevox_engine/cancellable_engine.py index a8ebbddbc..8f9a85da2 100644 --- a/voicevox_engine/cancellable_engine.py +++ b/voicevox_engine/cancellable_engine.py @@ -36,7 +36,7 @@ class CancellableEngine: ---------- watch_con_list: list[tuple[Request, Process]] Requestは接続の監視に使用され、Processは通信切断時のプロセスキルに使用される - クライアントから接続があるとListにTupleが追加される + クライアントから接続があるとlistにtupleが追加される 接続が切断、もしくは音声合成が終了すると削除される procs_and_cons: queue.Queue[tuple[Process, ConnectionType]] 音声合成の準備が終わっているプロセスのList diff --git a/voicevox_engine/engine_manifest/EngineManifest.py b/voicevox_engine/engine_manifest/EngineManifest.py index 63094eb8b..3dcf38489 100644 --- a/voicevox_engine/engine_manifest/EngineManifest.py +++ b/voicevox_engine/engine_manifest/EngineManifest.py @@ -3,8 +3,6 @@ # エラーを吐いて表示が崩壊する可能性がある。これを防止するため、EngineManifest関連の定義を # 変更する際は、Optionalにする必要があることに留意しなければならない。 -from typing import List, Optional - from pydantic import BaseModel, Field @@ -14,8 +12,8 @@ class UpdateInfo(BaseModel): """ version: str = Field(title="エンジンのバージョン名") - descriptions: List[str] = Field(title="アップデートの詳細についての説明") - contributors: Optional[List[str]] = Field(title="貢献者名") + descriptions: list[str] = Field(title="アップデートの詳細についての説明") + contributors: list[str] | None = Field(title="貢献者名") class LicenseInfo(BaseModel): @@ -24,8 +22,8 @@ class LicenseInfo(BaseModel): """ name: str = Field(title="依存ライブラリ名") - version: Optional[str] = Field(title="依存ライブラリのバージョン") - license: Optional[str] = Field(title="依存ライブラリのライセンス名") + version: str | None = Field(title="依存ライブラリのバージョン") + license: str | None = Field(title="依存ライブラリのライセンス名") text: str = Field(title="依存ライブラリのライセンス本文") @@ -44,8 +42,8 @@ class SupportedFeatures(BaseModel): synthesis_morphing: bool = Field( title="2種類のスタイルでモーフィングした音声を合成" ) - sing: Optional[bool] = Field(title="歌唱音声合成") - manage_library: Optional[bool] = Field( + sing: bool | None = Field(title="歌唱音声合成") + manage_library: bool | None = Field( title="音声ライブラリのインストール・アンインストール" ) @@ -64,9 +62,9 @@ class EngineManifest(BaseModel): default_sampling_rate: int = Field(title="デフォルトのサンプリング周波数") frame_rate: float = Field(title="エンジンのフレームレート") terms_of_service: str = Field(title="エンジンの利用規約") - update_infos: List[UpdateInfo] = Field(title="エンジンのアップデート情報") - dependency_licenses: List[LicenseInfo] = Field(title="依存関係のライセンス情報") - supported_vvlib_manifest_version: Optional[str] = Field( + update_infos: list[UpdateInfo] = Field(title="エンジンのアップデート情報") + dependency_licenses: list[LicenseInfo] = Field(title="依存関係のライセンス情報") + supported_vvlib_manifest_version: str | None = Field( title="エンジンが対応するvvlibのバージョン" ) supported_features: SupportedFeatures = Field(title="エンジンが持つ機能") diff --git a/voicevox_engine/library_manager.py b/voicevox_engine/library_manager.py index 709ae1448..f2232ebbb 100644 --- a/voicevox_engine/library_manager.py +++ b/voicevox_engine/library_manager.py @@ -94,7 +94,7 @@ def installed_libraries(self) -> dict[str, InstalledLibraryInfo]: インストール済み音声ライブラリの情報を取得 Returns ------- - library : Dict[str, InstalledLibraryInfo] + library : dict[str, InstalledLibraryInfo] インストール済みライブラリの情報 """ library: dict[str, InstalledLibraryInfo] = {} diff --git a/voicevox_engine/metas/Metas.py b/voicevox_engine/metas/Metas.py index b96d7021a..bc1e77db2 100644 --- a/voicevox_engine/metas/Metas.py +++ b/voicevox_engine/metas/Metas.py @@ -1,5 +1,5 @@ from enum import Enum -from typing import List, Literal, NewType, Optional +from typing import Literal, NewType from pydantic import BaseModel, Field @@ -16,7 +16,7 @@ class SpeakerStyle(BaseModel): name: str = Field(title="スタイル名") id: StyleId = Field(title="スタイルID") - type: Optional[StyleType] = Field( + type: StyleType | None = Field( default="talk", title=( "スタイルの種類。" @@ -56,7 +56,7 @@ class Speaker(BaseModel): name: str = Field(title="名前") speaker_uuid: str = Field(title="話者のUUID") - styles: List[SpeakerStyle] = Field(title="スタイルの一覧") + styles: list[SpeakerStyle] = Field(title="スタイルの一覧") version: str = Field("話者のバージョン") supported_features: SpeakerSupportedFeatures = Field( title="話者の対応機能", default_factory=SpeakerSupportedFeatures @@ -70,10 +70,10 @@ class StyleInfo(BaseModel): id: StyleId = Field(title="スタイルID") icon: str = Field(title="当該スタイルのアイコンをbase64エンコードしたもの") - portrait: Optional[str] = Field( + portrait: str | None = Field( title="当該スタイルのportrait.pngをbase64エンコードしたもの" ) - voice_samples: List[str] = Field( + voice_samples: list[str] = Field( title="voice_sampleのwavファイルをbase64エンコードしたもの" ) @@ -85,4 +85,4 @@ class SpeakerInfo(BaseModel): policy: str = Field(title="policy.md") portrait: str = Field(title="portrait.pngをbase64エンコードしたもの") - style_infos: List[StyleInfo] = Field(title="スタイルの追加情報") + style_infos: list[StyleInfo] = Field(title="スタイルの追加情報") diff --git a/voicevox_engine/metas/MetasStore.py b/voicevox_engine/metas/MetasStore.py index adee29ab7..d5655a6c2 100644 --- a/voicevox_engine/metas/MetasStore.py +++ b/voicevox_engine/metas/MetasStore.py @@ -1,7 +1,7 @@ import json from copy import deepcopy from pathlib import Path -from typing import TYPE_CHECKING, Dict, List, Literal, NewType, Tuple +from typing import TYPE_CHECKING, Literal, NewType from pydantic import BaseModel, Field @@ -46,7 +46,7 @@ class _CoreSpeaker(BaseModel): name: str speaker_uuid: str - styles: List[_CoreSpeakerStyle] + styles: list[_CoreSpeakerStyle] version: str = Field("話者のバージョン") @@ -73,16 +73,16 @@ def __init__(self, engine_speakers_path: Path) -> None: エンジンに含まれる話者メタ情報ディレクトリのパス。 """ # エンジンに含まれる各話者のメタ情報 - self._loaded_metas: Dict[str, _EngineSpeaker] = { + self._loaded_metas: dict[str, _EngineSpeaker] = { folder.name: _EngineSpeaker( **json.loads((folder / "metas.json").read_text(encoding="utf-8")) ) for folder in engine_speakers_path.iterdir() } - # FIXME: engineではなくList[CoreSpeaker]を渡す形にすることで + # FIXME: engineではなくlist[CoreSpeaker]を渡す形にすることで # TTSEngineによる循環importを修正する - def load_combined_metas(self, core: "CoreAdapter") -> List[Speaker]: + def load_combined_metas(self, core: "CoreAdapter") -> list[Speaker]: """ コアに含まれる話者メタ情報とエンジンに含まれる話者メタ情報を統合 Parameters @@ -91,7 +91,7 @@ def load_combined_metas(self, core: "CoreAdapter") -> List[Speaker]: 話者メタ情報をもったコア Returns ------- - ret : List[Speaker] + ret : list[Speaker] エンジンとコアに含まれる話者メタ情報 """ # コアに含まれる話者メタ情報の収集 @@ -112,17 +112,17 @@ def load_combined_metas(self, core: "CoreAdapter") -> List[Speaker]: def construct_lookup( - speakers: List[Speaker], -) -> Dict[StyleId, Tuple[Speaker, SpeakerStyle]]: + speakers: list[Speaker], +) -> dict[StyleId, tuple[Speaker, SpeakerStyle]]: """ スタイルID に話者メタ情報・スタイルメタ情報を紐付ける対応表を生成 Parameters ---------- - speakers : List[Speaker] + speakers : list[Speaker] 話者メタ情報 Returns ------- - ret : Dict[StyleId, Tuple[Speaker, SpeakerStyle]] + ret : dict[StyleId, tuple[Speaker, SpeakerStyle]] スタイルID に話者メタ情報・スタイルメタ情報が紐付いた対応表 """ lookup_table: dict[StyleId, tuple[Speaker, SpeakerStyle]] = dict() diff --git a/voicevox_engine/model.py b/voicevox_engine/model.py index 55802ea96..2249b34bc 100644 --- a/voicevox_engine/model.py +++ b/voicevox_engine/model.py @@ -1,6 +1,6 @@ from enum import Enum from re import findall, fullmatch -from typing import Any, Dict, List, Optional +from typing import Any from pydantic import BaseModel, Field, StrictStr, validator @@ -13,8 +13,8 @@ class Mora(BaseModel): """ text: str = Field(title="文字") - consonant: Optional[str] = Field(title="子音の音素") - consonant_length: Optional[float] = Field(title="子音の音長") + consonant: str | None = Field(title="子音の音素") + consonant_length: float | None = Field(title="子音の音長") vowel: str = Field(title="母音の音素") vowel_length: float = Field(title="母音の音長") pitch: float = Field( @@ -23,7 +23,7 @@ class Mora(BaseModel): def __hash__(self) -> int: items = [ - (k, tuple(v)) if isinstance(v, List) else (k, v) + (k, tuple(v)) if isinstance(v, list) else (k, v) for k, v in self.__dict__.items() ] return hash(tuple(sorted(items))) @@ -37,14 +37,14 @@ class AccentPhrase(BaseModel): アクセント句ごとの情報 """ - moras: List[Mora] = Field(title="モーラのリスト") + moras: list[Mora] = Field(title="モーラのリスト") accent: int = Field(title="アクセント箇所") - pause_mora: Optional[Mora] = Field(title="後ろに無音を付けるかどうか") + pause_mora: Mora | None = Field(title="後ろに無音を付けるかどうか") is_interrogative: bool = Field(default=False, title="疑問系かどうか") def __hash__(self) -> int: items = [ - (k, tuple(v)) if isinstance(v, List) else (k, v) + (k, tuple(v)) if isinstance(v, list) else (k, v) for k, v in self.__dict__.items() ] return hash(tuple(sorted(items))) @@ -55,7 +55,7 @@ class AudioQuery(BaseModel): 音声合成用のクエリ """ - accent_phrases: List[AccentPhrase] = Field(title="アクセント句のリスト") + accent_phrases: list[AccentPhrase] = Field(title="アクセント句のリスト") speedScale: float = Field(title="全体の話速") pitchScale: float = Field(title="全体の音高") intonationScale: float = Field(title="全体の抑揚") @@ -64,13 +64,13 @@ class AudioQuery(BaseModel): postPhonemeLength: float = Field(title="音声の後の無音時間") outputSamplingRate: int = Field(title="音声データの出力サンプリングレート") outputStereo: bool = Field(title="音声データをステレオ出力するか否か") - kana: Optional[str] = Field( + kana: str | None = Field( title="[読み取り専用]AquesTalk 風記法によるテキスト。音声合成用のクエリとしては無視される" ) def __hash__(self) -> int: items = [ - (k, tuple(v)) if isinstance(v, List) else (k, v) + (k, tuple(v)) if isinstance(v, list) else (k, v) for k, v in self.__dict__.items() ] return hash(tuple(sorted(items))) @@ -91,7 +91,7 @@ class Score(BaseModel): 楽譜情報 """ - notes: List[Note] = Field(title="音符のリスト") + notes: list[Note] = Field(title="音符のリスト") class FramePhoneme(BaseModel): @@ -108,9 +108,9 @@ class FrameAudioQuery(BaseModel): フレームごとの音声合成用のクエリ """ - f0: List[float] = Field(title="フレームごとの基本周波数") - volume: List[float] = Field(title="フレームごとの音量") - phonemes: List[FramePhoneme] = Field(title="音素のリスト") + f0: list[float] = Field(title="フレームごとの基本周波数") + volume: list[float] = Field(title="フレームごとの音量") + phonemes: list[FramePhoneme] = Field(title="音素のリスト") volumeScale: float = Field(title="全体の音量") outputSamplingRate: int = Field(title="音声データの出力サンプリングレート") outputStereo: bool = Field(title="音声データをステレオ出力するか否か") @@ -147,7 +147,7 @@ class ParseKanaBadRequest(BaseModel): ] ), ) - error_args: Dict[str, str] = Field(title="エラーを起こした箇所") + error_args: dict[str, str] = Field(title="エラーを起こした箇所") def __init__(self, err: ParseKanaError): super().__init__(text=err.text, error_name=err.errname, error_args=err.kwargs) @@ -156,7 +156,7 @@ def __init__(self, err: ParseKanaError): class MorphableTargetInfo(BaseModel): is_morphable: bool = Field(title="指定した話者に対してモーフィングの可否") # FIXME: add reason property - # reason: Optional[str] = Field(title="is_morphableがfalseである場合、その理由") + # reason: str | None = Field(title="is_morphableがfalseである場合、その理由") class StyleIdNotFoundError(LookupError): @@ -184,7 +184,7 @@ class BaseLibraryInfo(BaseModel): version: str = Field(title="音声ライブラリのバージョン") download_url: str = Field(title="音声ライブラリのダウンロードURL") bytes: int = Field(title="音声ライブラリのバイト数") - speakers: List[LibrarySpeaker] = Field(title="音声ライブラリに含まれる話者のリスト") + speakers: list[LibrarySpeaker] = Field(title="音声ライブラリに含まれる話者のリスト") # 今後InstalledLibraryInfo同様に拡張する可能性を考え、モデルを分けている @@ -228,7 +228,7 @@ class UserDictWord(BaseModel): yomi: str = Field(title="読み") pronunciation: str = Field(title="発音") accent_type: int = Field(title="アクセント型") - mora_count: Optional[int] = Field(title="モーラ数") + mora_count: int | None = Field(title="モーラ数") accent_associative_rule: str = Field(title="アクセント結合規則") class Config: @@ -310,8 +310,8 @@ class PartOfSpeechDetail(BaseModel): # context_idは辞書の左・右文脈IDのこと # https://github.com/VOICEVOX/open_jtalk/blob/427cfd761b78efb6094bea3c5bb8c968f0d711ab/src/mecab-naist-jdic/_left-id.def # noqa context_id: int = Field(title="文脈ID") - cost_candidates: List[int] = Field(title="コストのパーセンタイル") - accent_associative_rules: List[str] = Field(title="アクセント結合規則の一覧") + cost_candidates: list[int] = Field(title="コストのパーセンタイル") + accent_associative_rules: list[str] = Field(title="アクセント結合規則の一覧") class WordTypes(str, Enum): diff --git a/voicevox_engine/preset/PresetManager.py b/voicevox_engine/preset/PresetManager.py index 7421c9585..2519cbad2 100644 --- a/voicevox_engine/preset/PresetManager.py +++ b/voicevox_engine/preset/PresetManager.py @@ -1,5 +1,4 @@ from pathlib import Path -from typing import List import yaml from pydantic import ValidationError, parse_obj_as @@ -40,7 +39,7 @@ def _refresh_cache(self) -> None: if obj is None: raise PresetInternalError("プリセットの設定ファイルが空の内容です") try: - _presets = parse_obj_as(List[Preset], obj) + _presets = parse_obj_as(list[Preset], obj) except ValidationError: raise PresetInternalError("プリセットの設定ファイルにミスがあります") diff --git a/voicevox_engine/setting/Setting.py b/voicevox_engine/setting/Setting.py index 1b8695aea..082fbb668 100644 --- a/voicevox_engine/setting/Setting.py +++ b/voicevox_engine/setting/Setting.py @@ -1,5 +1,4 @@ from enum import Enum -from typing import Optional from pydantic import BaseModel, Field @@ -19,4 +18,4 @@ class Setting(BaseModel): """ cors_policy_mode: CorsPolicyMode = Field(title="リソース共有ポリシー") - allow_origin: Optional[str] = Field(title="許可するオリジン") + allow_origin: str | None = Field(title="許可するオリジン") diff --git a/voicevox_engine/tts_pipeline/kana_converter.py b/voicevox_engine/tts_pipeline/kana_converter.py index 5310701cf..6244c7ef4 100644 --- a/voicevox_engine/tts_pipeline/kana_converter.py +++ b/voicevox_engine/tts_pipeline/kana_converter.py @@ -14,8 +14,6 @@ NOTE: ユーザー向け案内 `https://github.com/VOICEVOX/voicevox_engine/blob/master/README.md#aquestalk-風記法` # noqa """ -from typing import List, Optional - from ..model import AccentPhrase, Mora, ParseKanaError, ParseKanaErrorCode from .mora_mapping import mora_kana_to_mora_phonemes from .phoneme import Vowel @@ -70,12 +68,12 @@ def _text_to_accent_phrase(phrase: str) -> AccentPhrase: """ # NOTE: ポーズと疑問形はこの関数内で処理しない - accent_index: Optional[int] = None - moras: List[Mora] = [] + accent_index: int | None = None + moras: list[Mora] = [] base_index = 0 # パース開始位置。ここから右の文字列をstackに詰めていく。 stack = "" # 保留中の文字列 - matched_text: Optional[str] = None # 保留中の文字列内で最後にマッチした仮名 + matched_text: str | None = None # 保留中の文字列内で最後にマッチした仮名 outer_loop = 0 while base_index < len(phrase): @@ -119,7 +117,7 @@ def _text_to_accent_phrase(phrase: str) -> AccentPhrase: return AccentPhrase(moras=moras, accent=accent_index, pause_mora=None) -def parse_kana(text: str) -> List[AccentPhrase]: +def parse_kana(text: str) -> list[AccentPhrase]: """ AquesTalk 風記法テキストからアクセント句系列を生成 Parameters @@ -128,11 +126,11 @@ def parse_kana(text: str) -> List[AccentPhrase]: AquesTalk 風記法テキスト Returns ------- - parsed_results : List[AccentPhrase] + parsed_results : list[AccentPhrase] アクセント句(音素・モーラ音高 0初期化)系列を生成 """ - parsed_results: List[AccentPhrase] = [] + parsed_results: list[AccentPhrase] = [] phrase_base = 0 if len(text) == 0: raise ParseKanaError(ParseKanaErrorCode.EMPTY_PHRASE, position=1) @@ -177,12 +175,12 @@ def parse_kana(text: str) -> List[AccentPhrase]: return parsed_results -def create_kana(accent_phrases: List[AccentPhrase]) -> str: +def create_kana(accent_phrases: list[AccentPhrase]) -> str: """ アクセント句系列からAquesTalk 風記法テキストを生成 Parameters ---------- - accent_phrases : List[AccentPhrase] + accent_phrases : list[AccentPhrase] アクセント句系列 Returns ------- diff --git a/voicevox_engine/user_dict/part_of_speech_data.py b/voicevox_engine/user_dict/part_of_speech_data.py index 302b61381..229851e7c 100644 --- a/voicevox_engine/user_dict/part_of_speech_data.py +++ b/voicevox_engine/user_dict/part_of_speech_data.py @@ -1,5 +1,3 @@ -from typing import Dict - from ..model import ( USER_DICT_MAX_PRIORITY, USER_DICT_MIN_PRIORITY, @@ -10,7 +8,7 @@ MIN_PRIORITY = USER_DICT_MIN_PRIORITY MAX_PRIORITY = USER_DICT_MAX_PRIORITY -part_of_speech_data: Dict[WordTypes, PartOfSpeechDetail] = { +part_of_speech_data: dict[WordTypes, PartOfSpeechDetail] = { WordTypes.PROPER_NOUN: PartOfSpeechDetail( part_of_speech="名詞", part_of_speech_detail_1="固有名詞", diff --git a/voicevox_engine/user_dict/user_dict.py b/voicevox_engine/user_dict/user_dict.py index 3d4092ad9..497975a40 100644 --- a/voicevox_engine/user_dict/user_dict.py +++ b/voicevox_engine/user_dict/user_dict.py @@ -3,7 +3,6 @@ import threading import traceback from pathlib import Path -from typing import Dict, List, Optional from uuid import UUID, uuid4 import numpy as np @@ -38,12 +37,12 @@ class UserDictInputError(Exception): @mutex_wrapper(mutex_user_dict) -def _write_to_json(user_dict: Dict[str, UserDictWord], user_dict_path: Path) -> None: +def _write_to_json(user_dict: dict[str, UserDictWord], user_dict_path: Path) -> None: """ ユーザー辞書ファイルへのユーザー辞書データ書き込み Parameters ---------- - user_dict : Dict[str, UserDictWord] + user_dict : dict[str, UserDictWord] ユーザー辞書データ user_dict_path : Path ユーザー辞書ファイルのパス @@ -156,7 +155,7 @@ def update_dict( @mutex_wrapper(mutex_user_dict) -def read_dict(user_dict_path: Path = user_dict_path) -> Dict[str, UserDictWord]: +def read_dict(user_dict_path: Path = user_dict_path) -> dict[str, UserDictWord]: """ ユーザー辞書の読み出し Parameters @@ -165,7 +164,7 @@ def read_dict(user_dict_path: Path = user_dict_path) -> Dict[str, UserDictWord]: ユーザー辞書ファイルのパス Returns ------- - result : Dict[str, UserDictWord] + result : dict[str, UserDictWord] ユーザー辞書 """ # 指定ユーザー辞書が存在しない場合、空辞書を返す @@ -173,7 +172,7 @@ def read_dict(user_dict_path: Path = user_dict_path) -> Dict[str, UserDictWord]: return {} with user_dict_path.open(encoding="utf-8") as f: - result: Dict[str, UserDictWord] = {} + result: dict[str, UserDictWord] = {} for word_uuid, word in json.load(f).items(): # cost2priorityで変換を行う際にcontext_idが必要となるが、 # 0.12以前の辞書は、context_idがハードコーディングされていたためにユーザー辞書内に保管されていない @@ -193,8 +192,8 @@ def _create_word( surface: str, pronunciation: str, accent_type: int, - word_type: Optional[WordTypes] = None, - priority: Optional[int] = None, + word_type: WordTypes | None = None, + priority: int | None = None, ) -> UserDictWord: """ 単語オブジェクトの生成 @@ -206,9 +205,9 @@ def _create_word( 単語情報 accent_type : int 単語情報 - word_type : Optional[WordTypes] + word_type : WordTypes | None 品詞 - priority : Optional[int] + priority : int | None 優先度 Returns ------- @@ -247,8 +246,8 @@ def apply_word( surface: str, pronunciation: str, accent_type: int, - word_type: Optional[WordTypes] = None, - priority: Optional[int] = None, + word_type: WordTypes | None = None, + priority: int | None = None, user_dict_path: Path = user_dict_path, compiled_dict_path: Path = compiled_dict_path, ) -> str: @@ -262,9 +261,9 @@ def apply_word( 単語情報 accent_type : int 単語情報 - word_type : Optional[WordTypes] + word_type : WordTypes | None 品詞 - priority : Optional[int] + priority : int | None 優先度 user_dict_path : Path ユーザー辞書ファイルのパス @@ -299,8 +298,8 @@ def rewrite_word( surface: str, pronunciation: str, accent_type: int, - word_type: Optional[WordTypes] = None, - priority: Optional[int] = None, + word_type: WordTypes | None = None, + priority: int | None = None, user_dict_path: Path = user_dict_path, compiled_dict_path: Path = compiled_dict_path, ) -> None: @@ -316,9 +315,9 @@ def rewrite_word( 単語情報 accent_type : int 単語情報 - word_type : Optional[WordTypes] + word_type : WordTypes | None 品詞 - priority : Optional[int] + priority : int | None 優先度 user_dict_path : Path ユーザー辞書ファイルのパス @@ -372,7 +371,7 @@ def delete_word( def import_user_dict( - dict_data: Dict[str, UserDictWord], + dict_data: dict[str, UserDictWord], override: bool = False, user_dict_path: Path = user_dict_path, default_dict_path: Path = default_dict_path, @@ -382,7 +381,7 @@ def import_user_dict( ユーザー辞書のインポート Parameters ---------- - dict_data : Dict[str, UserDictWord] + dict_data : dict[str, UserDictWord] インポートするユーザー辞書のデータ override : bool 重複したエントリがあった場合、上書きするかどうか @@ -436,7 +435,7 @@ def import_user_dict( ) -def _search_cost_candidates(context_id: int) -> List[int]: +def _search_cost_candidates(context_id: int) -> list[int]: for value in part_of_speech_data.values(): if value.context_id == context_id: return value.cost_candidates diff --git a/voicevox_engine/utility/connect_base64_waves.py b/voicevox_engine/utility/connect_base64_waves.py index 287e14078..1a6bc4b87 100644 --- a/voicevox_engine/utility/connect_base64_waves.py +++ b/voicevox_engine/utility/connect_base64_waves.py @@ -21,7 +21,7 @@ def decode_base64_waves(waves: list[str]) -> list[tuple[NDArray[np.float64], int base64エンコードされたwavデータのリスト Returns ------- - waves_nparray_sr: List[Tuple[NDArray[np.float64], int]] + waves_nparray_sr: list[tuple[NDArray[np.float64], int]] (NumPy配列の音声波形データ, サンプリングレート) 形式のタプルのリスト """ if len(waves) == 0: