37 lines
1.1 KiB
Python
37 lines
1.1 KiB
Python
"""
|
|
話者リスト更新用オペレーター
|
|
"""
|
|
|
|
import bpy
|
|
from bpy.types import Operator
|
|
from .properties import update_speaker_cache
|
|
|
|
|
|
class VOICEVOX_OT_refresh_speakers(Operator):
|
|
"""VoiceVoxから話者リストを再取得"""
|
|
bl_idname = "voicevox.refresh_speakers"
|
|
bl_label = "Refresh Speakers"
|
|
bl_description = "VoiceVoxエンジンから話者リストを再取得します"
|
|
bl_options = {'REGISTER'}
|
|
|
|
def execute(self, context):
|
|
props = context.scene.voicevox
|
|
|
|
# VoiceVox APIから話者リストを取得してキャッシュを更新
|
|
count = update_speaker_cache(props.voicevox_host, props.voicevox_port)
|
|
|
|
if count > 0:
|
|
self.report({'INFO'}, f"{count}人の話者を取得しました")
|
|
else:
|
|
self.report({'WARNING'}, "話者の取得に失敗しました")
|
|
|
|
# EnumPropertyを強制的に再評価
|
|
current = props.speaker
|
|
try:
|
|
props.speaker = '0'
|
|
props.speaker = current
|
|
except:
|
|
pass
|
|
|
|
return {'FINISHED'}
|