-
-
Notifications
You must be signed in to change notification settings - Fork 135
AllTalk Configuration System Documentation
The AllTalk configuration system provides a centralized way to manage application settings through three main configuration classes:
-
AlltalkConfig
: Main application configuration -
AlltalkTTSEnginesConfig
: TTS engine settings -
AlltalkNewEnginesConfig
: New/available TTS engines configuration
from config import AlltalkConfig, AlltalkTTSEnginesConfig, AlltalkNewEnginesConfig
def initialize_configs():
"""Initialize all configuration instances"""
config = AlltalkConfig.get_instance()
tts_engines_config = AlltalkTTSEnginesConfig.get_instance()
new_engines_config = AlltalkNewEnginesConfig.get_instance()
return config, tts_engines_config, new_engines_config
# Load configurations
config, tts_engines_config, new_engines_config = initialize_configs()
All configuration classes use a singleton pattern with get_instance()
. Configuration values can be accessed directly as attributes:
# Main config examples
print(config.branding) # Access branding string
print(config.gradio_port_number) # Access port number
print(config.output_folder) # Access output folder path
# TTS engines config examples
print(tts_engines_config.engine_loaded) # Currently loaded engine
print(tts_engines_config.selected_model) # Selected model name
# Accessing nested configuration objects
print(config.rvc_settings.pitch) # Access RVC settings
print(config.tgwui.tgwui_language) # Access TGWUI settings
print(config.api_def.api_port_number) # Access API settings
Changes to configuration values persist only in memory until explicitly saved:
# Modify configuration values
config.branding = "New Branding"
config.gradio_port_number = 7853
config.rvc_settings.pitch = 1
# Save changes to disk
config.save() # Saves to default location
config.save("custom_config.json") # Save to custom location
# Save TTS engine changes
tts_engines_config.engine_loaded = "new_engine"
tts_engines_config.save()
The TTS engines configuration provides methods for managing TTS engines:
# Check available engines
engine_names = tts_engines_config.get_engine_names_available()
# Validate engine names
is_valid = tts_engines_config.is_valid_engine("piper")
# Change active engine
tts_engines_config.change_engine("vits")
Configurations can be forcefully reloaded from disk:
# Force reload all configs
config = AlltalkConfig.get_instance(force_reload=True)
tts_engines_config = AlltalkTTSEnginesConfig.get_instance(force_reload=True)
new_engines_config = AlltalkNewEnginesConfig.get_instance(force_reload=True)
# Or reload individual instances
config.reload()
The main configuration provides helpers for managing output directories:
output_dir = config.get_output_directory() # Returns Path object
Access configuration file paths:
default_path = AlltalkConfig.default_config_path()
current_path = config.get_config_path()
rvc = config.rvc_settings
rvc.rvc_enabled = True
rvc.pitch = 0
rvc.filter_radius = 3
rvc.index_rate = 0.75
etc...
tgwui = config.tgwui
tgwui.tgwui_language = "English"
tgwui.tgwui_pitch_set = 0
tgwui.tgwui_show_text = True
etc...
api = config.api_def
api.api_port_number = 7851
api.api_language = "en"
api.api_autoplay = False
etc...
debug = config.debugging
debug.debug_tts = True
debug.debug_rvc = False
etc...
pages = config.gradio_pages
pages.Generate_Help_page = True
pages.TTS_Generator_page = True
etc...
-
The configuration system automatically creates necessary directories and backup files during saves.
-
File locking is used to prevent concurrent access issues.
-
Configuration files are monitored for changes and automatically reloaded after a 5-second interval.
-
All configuration classes use a singleton pattern - always use
get_instance()
instead of constructing directly. -
The system maintains backup files during saves to prevent data loss.
- Always use the
get_instance()
method to access configurations. - Save changes explicitly using the
save()
method when modifications are made. - Use the provided helper methods instead of accessing file paths directly.
- Check engine validity before changing engines using
is_valid_engine()
. - Use the force_reload parameter sparingly, as the system automatically reloads when needed.