def maybe_update_voice(self): ss = _script_setting(self.seq) if not ss.gen_voice: return if self._seq_setting.voice_text() == '': return seq_missing = self.voice_seq is None is_changed = _script_setting(self.seq).voice_cache_state \ .is_changed(_global_setting(self.context), self.chara, self.seq) should_regenerate: bool = seq_missing or is_changed if should_regenerate: if self.voice_seq is not None: self._remove_sequence(self.voice_seq) self.voice_seq = None self.voice_seq = self._generate_voice_sequence() self._seq_setting.voice_seq_name = self.voice_seq.name self._seq_setting.voice_cache_state.update( global_setting=_global_setting(self.context), chara=self.chara, seq=self.seq, ) assert self.voice_seq is not None self._align_sequence( seq=self.voice_seq, channel=self.chara.voice_channel(self._global_setting), frame_start=self.seq.frame_start, ) frame_final_end = max(self.voice_seq.frame_final_end, self.seq.frame_final_end) if self.seq.frame_final_end != frame_final_end: self.seq.frame_final_end = frame_final_end
def draw(self, context: Context): layout = self.layout gs = _global_setting(context) layout.prop(gs.seika_center, 'addr') layout.prop(gs.seika_center, 'user') layout.prop(gs.seika_center, 'password')
def execute(self, context): charas = _global_setting(context).characters charas.clear() kiritan: KiritanifyCharacterSetting = charas.add() kiritan.chara_name = "Kiritan" kiritan.cid = 1700 kiritan.caption_style.stroke_color = [0.23, 0.23, 0.23, 1.] kiritan.tachie_style.offset_x_px = 1400 kiritan.tachie_style.offset_y_px = -400 kiritan.tachie_style.use_flip_x = True kiritan.voice_style.speed = 1.3 kiritan.voice_style.intonation = 1.1 kiritan.tachie_directory = '//../assets/karai/kiritan/normal/' akari: KiritanifyCharacterSetting = charas.add() akari.chara_name = "Akari" akari.cid = 2000 akari.caption_style.stroke_color = [0.75, 0.38, 0.03, 1.4] akari.tachie_style.offset_x_px = 1400 akari.tachie_style.offset_y_px = -400 akari.voice_style.speed = 1.25 akari.voice_style.pitch = 1.08 akari.voice_style.intonation = 1.60 akari.tachie_directory = '//../assets/karai/akari/normal/' return {'FINISHED'}
def execute(self, context): charas = _global_setting(context).characters for idx, chara in enumerate(charas): if chara.chara_name == self.chara_name: charas.remove(idx) break return {'FINISHED'}
def draw(self, context): layout = self.layout gs = _global_setting(context) row = layout.row() row.label(text="FromChan:") row.prop(gs, 'start_channel_for_script', slider=False, text='Script') row.prop(gs, 'start_channel_for_caption', slider=False, text='Caption') row = layout.row() row.label(text="Character:") row.operator(KIRITANIFY_OT_AddCharacter.bl_idname, text='AddChara') row.operator(KIRITANIFY_OT_SetDefaultCharacters.bl_idname, text='UseDefault') for chara in gs.characters: # type: KiritanifyCharacterSetting box = layout.box() col = box.column(align=True) col.prop(chara, "chara_name") _row = col.row() _row.prop(chara, "cid", slider=False) op = _row.operator(KIRITANIFY_OT_RemoveCharacter.bl_idname, text='', icon='X') op.chara_name = chara.chara_name col.separator() _row = col.row() _row.prop(chara.caption_style, "fill_color") _row = col.row() _row.prop(chara.caption_style, "stroke_color") _row.prop(chara.caption_style, "stroke_width", slider=False) col.separator() _row = col.row() _row.label(text=f'Sc: {chara.script_channel(gs)}') _row.label(text=f'Cp: {chara.caption_channel(gs)}') _row.label(text=f'Vo: {chara.voice_channel(gs)}') _row.label(text=f'Ta: {0}') col.separator() _row = col.row() _row.label(text="TachieOffset") _row.prop(chara.tachie_style, property="offset_x_px", text="x", slider=False) _row.prop(chara.tachie_style, property="offset_y_px", text="y", slider=False) _row.prop(chara.tachie_style, property="use_flip_x", text="flip") col.separator() _row = col.row() _row.prop(chara.voice_style, 'volume', slider=False) _row.prop(chara.voice_style, 'speed', slider=False) _row.prop(chara.voice_style, 'pitch', slider=False) _row.prop(chara.voice_style, 'intonation', slider=False)
def execute(self, context): gs = _global_setting(context) target_channels = [ chara.voice_channel(gs) for chara in gs.characters ] for seq in _sequences(context): # type: Sequence if seq.channel in target_channels and isinstance(seq, SoundSequence): seq.sound.use_memory_cache = not seq.sound.use_memory_cache return {'FINISHED'}
def _draw_ui_for_new_seq(context: Context, layout: UILayout): gs = _global_setting(context) # new sequence button per character if len(gs.characters) > 0: _box = layout.box() _row = _box.row() for chara in gs.characters: # type: KiritanifyCharacterSetting op: KIRITANIFY_OT_NewScriptSequence \ = _row.operator( operator=KIRITANIFY_OT_NewScriptSequence.bl_idname, text=f'{chara.chara_name}', ) op.chara_name = chara.chara_name
def execute(self, context: Context): current_frame = _current_frame(context) gs = _global_setting(context) chara = gs.find_character_by_name(self.chara_name) if chara is None: return {'FINISHED'} filepath = self.image_path if filepath is None: return {'FINISHED'} frame_start = context.scene.frame_start frame_end = context.scene.frame_end _prev, _curr, _next = find_neighbor_sequence(context, chara.tachie_channel(gs), current_frame) if _curr is not None: return {'FINISHED'} if _prev is not None: frame_start = _prev.frame_final_end if _next is not None: frame_end = _next.frame_final_start print(_prev, _curr, _next) if _prev is not None: print('prev', (_prev.frame_final_start, _prev.frame_final_end)) if _next is not None: print('_next', (_next.frame_final_start, _next.frame_final_end)) print(frame_start, frame_end) bpy.ops.sequencer.select_all(action='DESELECT') seq: kiritanify.types.ImageSequence = _sequences(context).new_image( name=f'Tachie:{chara.chara_name}:{_datetime_str()}', filepath=str(filepath), channel=chara.tachie_channel(gs), frame_start=current_frame, ) seq.frame_final_start = frame_start seq.frame_final_end = frame_end seq.blend_type = "ALPHA_OVER" seq.use_translation = True seq.transform.offset_x = chara.tachie_style.offset_x_px seq.transform.offset_y = chara.tachie_style.offset_y_px seq.use_flip_x = chara.tachie_style.use_flip_x return {'FINISHED'}
def _draw_ui_for_new_seq(context: Context, layout: UILayout): gs = _global_setting(context) # new sequence button per character if len(gs.characters) > 0: for chara in gs.characters: # type: KiritanifyCharacterSetting _box = layout.box() _box.label(text=f'{chara.chara_name}') for seqs in split_per_num(chara.tachie_files(), 4): _row = _box.row() for e in seqs: # type: Path op: KIRITANIFY_OT_NewTachieSequences \ = _row.operator( operator=KIRITANIFY_OT_NewTachieSequences.bl_idname, text=f'{e.name}', ) op.chara_name = chara.chara_name op.image_path = str(e) layout.separator()
def execute(self, context): referred_files: Set[Path] = set(sum(map( self.get_paths_from, _sequences(context) ), [])) path = _global_setting(context).cache_setting.root_dir() png_paths = set(p.resolve() for p in path.glob('caption/*/*.png')) ogg_paths = set(p.resolve() for p in path.glob('voice/*/*.ogg')) existing_paths = png_paths.union(ogg_paths) logger.debug(f'referred_files: {referred_files}') logger.debug(f'existing_files: {existing_paths}') deletable_paths = existing_paths - referred_files for path in deletable_paths: # type: Path path.unlink() return {'FINISHED'}
def execute(self, context: Context): gs = _global_setting(context) chara_for_channel = { chara.script_channel(gs): chara for chara in gs.characters } print(chara_for_channel) for seq in context.selected_sequences: # type: Sequence print(seq) if not (seq.channel in chara_for_channel and isinstance(seq, AdjustmentSequence)): continue chara = chara_for_channel[seq.channel] print(chara) if chara is None: continue print(chara.voice_style) _script_setting(seq).custom_voice_style.update(chara.voice_style) return {'FINISHED'}
def execute(self, context: Context): current_frame = _current_frame(context) gs = _global_setting(context) chara = gs.find_character_by_name(self.chara_name) if chara is None: return {'FINISHED'} bpy.ops.sequencer.select_all(action='DESELECT') result = bpy.ops.sequencer.effect_strip_add( frame_start=current_frame, frame_end=current_frame + _fps(context) // 2, channel=chara.script_channel(gs), type='ADJUSTMENT', ) if 'FINISHED' not in result: return result script_sequence = get_selected_script_sequence(context) script_sequence.name = f'Script:{chara.chara_name}:{_datetime_str()}' return {'FINISHED'}
def execute(self, context: Context) -> Set[Union[int, str]]: gs = _global_setting(context) chara_for_chan: Dict[int, KiritanifyCharacterSetting] = { chara.script_channel(gs): chara for chara in gs.characters } logger.debug(f"chara_for_chan: {chara_for_chan!r}") for chara in gs.characters: for seq in get_sequences_by_channel(context, chara.script_channel(gs)): logger.debug(f"seq: {seq!r}") if not isinstance(seq, AdjustmentSequence): continue seq: kiritanify.types.KiritanifyScriptSequence cs = CharacterScript.create_from(chara, seq, context) logger.debug(f"cs: {cs!r}") cs.maybe_update_voice() cs.maybe_update_caption() return {'FINISHED'}
def _global_setting(self): return _global_setting(self.context)
def get_character_from_channel(context, channel) -> KiritanifyCharacterSetting: global_channel = _global_setting(context) for chara in global_channel.characters: # type: KiritanifyCharacterSetting if channel == chara.script_channel(global_channel): return chara
def execute(self, context): charas = _global_setting(context).characters c: KiritanifyCharacterSetting = charas.add() c.chara_name = 'XYZ' return {'FINISHED'}