Skip to content

CharacterDatabase

Pathos edited this page Jan 28, 2025 · 3 revisions

Character Database

The character database is a class that can load and convert from CSV and JSON files for how to store a list of character objects. It can also save the character database to a CSV or JSON file. The character database can be used to get a character by name, ref_id, or base_id. It can also be used to compare two character databases and return the differences between them. The character database can also be used to get a list of available voice models and voice folders and is used during startup to figure out which voices aren't accounted for by any of the TTSes.

Character Database Class

  • __init__(self, config, synthesizer, conversation_manager, character_database_path, db_type='json'): Initializes the character database with the given configuration, synthesizer, conversation manager, character database path, and database type.
  • loaded(self): Returns whether the character database has been loaded.
  • load(self): Loads the character database from the character database path.
  • load_characters_json(self, path): Loads the character database from a JSON file.
  • load_characters_csv(self, path): Loads the character database from a CSV file.
  • format_character(self, character): Formats a character object to have the necessary fields.
  • get_unique_ref_index(self, character): Returns the unique reference index for a character.
  • characters: Returns the characters in the character database.
  • patch_character_info(self, info): Patches information about a character into the character database and saves the changes to the JSON file.
  • get_character_by_name(self, name): Gets a character from the character database using the character's name.
  • get_character_by_voice_folder(self, voice_folder): Looks through non-generic characters for a character with the given voice folder.
  • get_voice_folder_by_voice_model(self, voice_model): Gets the voice folder for a given voice model.
  • verify_characters(self): Verifies the characters in the character database.
  • get_character(self, character_name, character_ref_id=None, character_base_id=None, character_in_game_race=None, character_in_game_gender=None, character_is_guard=None, character_is_ghost=None, in_game_voice_model=None, location=None): Gets a character from the character database using the character's name, ref_id, or base_id.
  • _get_character(self, character_name, character_ref_id=None, character_base_id=None, character_in_game_race=None, character_in_game_gender=None, character_is_guard=None, character_is_ghost=None, in_game_voice_model=None, location=None): Gets a character from the character database using the character's name, ref_id, or base_id.
  • has_character(self, character): Checks if a character is in the character database.
  • compare(self, db): Compares this character database with another character database and returns the differences.
  • save(self, path, type='json'): Saves the character database to a JSON directory or CSV file.
  • male_voice_models: Returns a dictionary
  • female_voice_models: Returns a dictionary
  • all_voice_models: Returns a list of all voice models
  • voice_folders: Returns a dictionary of voice models and their corresponding voice folders
  • all_voice_folders: Returns a list of all voice folders

Method Details

__init__(self, config, synthesizer, conversation_manager, character_database_path, db_type='json') Method

Initializes the character database with the given configuration, synthesizer, conversation manager, character database path, and database type.

loaded(self) Method

Returns whether the character database has been loaded.

load(self) Method

Loads the character database from the character database path.

load_characters_json(self, path) Method

Loads the character database from a JSON file.

load_characters_csv(self, path) Method

Loads the character database from a CSV file.

format_character(self, character) Method

Formats a character object to have the necessary fields.

get_unique_ref_index(self, character) Method

Returns the unique reference index for a character.

characters Property

Returns the characters in the character database.

patch_character_info(self, info) Method

Patches information about a character into the character database and saves the changes to the JSON file.

get_character_by_name(self, name) Method

Gets a character from the character database using the character's name.

get_character_by_voice_folder(self, voice_folder) Method

Looks through non-generic characters for a character with the given voice folder.

get_voice_folder_by_voice_model(self, voice_model) Method

Gets the voice folder for a given voice model.

verify_characters(self) Method

Verifies the characters in the character database.

get_character(self, character_name, character_ref_id=None, character_base_id=None, character_in_game_race=None, character_in_game_gender=None, character_is_guard=None, character_is_ghost=None, in_game_voice_model=None, location=None) Method

Gets a character from the character database using the character's name, ref_id, base_id, in-game race and gender, whether the character is a guard or ghost, the in-game voice model, and the location.

_get_character(self, character_name, character_ref_id=None, character_base_id=None, character_in_game_race=None, character_in_game_gender=None, character_is_guard=None, character_is_ghost=None, in_game_voice_model=None, location=None) Method

Gets a character from the character database using the character's name, ref_id, base_id, in-game race and gender, whether the character is a guard or ghost, the in-game voice model, and the location.

has_character(self, character) Method

Checks if a character is in the character database.

compare(self, db) Method

Compares this character database with another character database and returns the differences.

save(self, path, type='json') Method

Saves the character database to a JSON directory or CSV file.

male_voice_models Property

Returns a dictionary of all male voice models.

female_voice_models Property

Returns a dictionary of all female voice models.

all_voice_models Property

Returns a list of all voice models.

voice_folders Property

Returns a dictionary of voice models and their corresponding voice folders.

all_voice_folders Property

Returns a list of all voice folders.

Clone this wiki locally