mirror of
https://github.com/DrewThomasson/ebook2audiobook.git
synced 2026-01-09 13:58:14 -05:00
- Added config options in lib/conf.py: enable_parallel_processing (default: True) and parallel_min_free_ram_gb (default: 2) - Replaced simple 2x RAM check with intelligent calculation of max parallel instances - System now considers available RAM, VRAM, and maintains minimum free RAM - Supports creating multiple parallel instances (not just 2) based on available resources - One GPU instance + additional CPU instances as RAM allows Co-authored-by: DrewThomasson <126999465+DrewThomasson@users.noreply.github.com>
82 lines
3.7 KiB
Python
82 lines
3.7 KiB
Python
import os
|
|
import platform
|
|
|
|
tmp_dir = os.path.abspath('tmp')
|
|
tmp_expire = 7 # days
|
|
|
|
models_dir = os.path.abspath('models')
|
|
ebooks_dir = os.path.abspath('ebooks')
|
|
voices_dir = os.path.abspath('voices')
|
|
tts_dir = os.path.join(models_dir, 'tts')
|
|
|
|
os.environ['PYTHONUTF8'] = '1'
|
|
os.environ['PYTHONIOENCODING'] = 'utf-8'
|
|
os.environ['COQUI_TOS_AGREED'] = '1'
|
|
os.environ['PYTHONIOENCODING'] = 'utf-8'
|
|
os.environ['CALIBRE_NO_NATIVE_FILEDIALOGS'] = '1'
|
|
os.environ['GRADIO_DEBUG'] = '1'
|
|
os.environ['DO_NOT_TRACK'] = 'true'
|
|
os.environ['CALIBRE_TEMP_DIR'] = tmp_dir
|
|
os.environ['CALIBRE_CACHE_DIRECTORY'] = tmp_dir
|
|
os.environ['HUGGINGFACE_HUB_CACHE'] = tts_dir
|
|
os.environ['HF_HOME'] = tts_dir
|
|
os.environ['HF_DATASETS_CACHE'] = tts_dir
|
|
os.environ['BARK_CACHE_DIR'] = tts_dir
|
|
os.environ['TTS_CACHE'] = tts_dir
|
|
os.environ['TORCH_HOME'] = tts_dir
|
|
os.environ['TTS_HOME'] = models_dir
|
|
os.environ['XDG_CACHE_HOME'] = models_dir
|
|
os.environ['STANZA_RESOURCES_DIR'] = os.path.join(models_dir, 'stanza')
|
|
os.environ['ARGOS_TRANSLATE_PACKAGE_PATH'] = os.path.join(models_dir, 'argostranslate')
|
|
os.environ['TORCH_FORCE_NO_WEIGHTS_ONLY_LOAD'] = '1'
|
|
os.environ['PYTORCH_ENABLE_MPS_FALLBACK'] = '1'
|
|
os.environ['SUNO_OFFLOAD_CPU'] = 'False' # BARK option: False needs A GPU
|
|
os.environ['SUNO_USE_SMALL_MODELS'] = 'False' # BARK option: False needs a GPU with VRAM > 4GB
|
|
if platform.system() == 'Windows':
|
|
os.environ['ESPEAK_DATA_PATH'] = os.path.expandvars(r"%USERPROFILE%\scoop\apps\espeak-ng\current\eSpeak NG\espeak-ng-data")
|
|
|
|
prog_version = (lambda: open('VERSION.txt').read().strip())()
|
|
|
|
min_python_version = (3,10)
|
|
max_python_version = (3,12)
|
|
|
|
NATIVE = 'native'
|
|
FULL_DOCKER = 'full_docker'
|
|
|
|
debug_mode = True
|
|
|
|
device_list = ['cpu', 'gpu', 'mps']
|
|
default_device = 'cpu'
|
|
default_gpu_wiki = '<a href="https://github.com/DrewThomasson/ebook2audiobook/wiki/GPU-ISSUES">howto wiki</a>'
|
|
|
|
# Parallel processing configuration
|
|
enable_parallel_processing = True # Enable/disable parallel processing feature
|
|
parallel_min_free_ram_gb = 2 # Minimum free RAM (GB) to maintain when calculating parallel instances
|
|
|
|
python_env_dir = os.path.abspath(os.path.join('.','python_env'))
|
|
requirements_file = os.path.abspath(os.path.join('.','requirements.txt'))
|
|
|
|
interface_host = '0.0.0.0'
|
|
interface_port = 7860
|
|
interface_shared_tmp_expire = 3 # in days
|
|
interface_concurrency_limit = 1 # or None for unlimited
|
|
|
|
interface_component_options = {
|
|
"gr_tab_xtts_params": True,
|
|
"gr_tab_bark_params": True,
|
|
"gr_group_voice_file": True,
|
|
"gr_group_custom_model": True
|
|
}
|
|
|
|
audiobooks_gradio_dir = os.path.abspath(os.path.join('audiobooks','gui','gradio'))
|
|
audiobooks_host_dir = os.path.abspath(os.path.join('audiobooks','gui','host'))
|
|
audiobooks_cli_dir = os.path.abspath(os.path.join('audiobooks','cli'))
|
|
|
|
ebook_formats = ['.epub', '.mobi', '.azw3', '.fb2', '.lrf', '.rb', '.snb', '.tcr', '.pdf', '.txt', '.rtf', '.doc', '.docx', '.html', '.odt', '.azw'] # Add or remove the format you accept as input
|
|
voice_formats = ['.mp4', '.m4b', '.m4a', '.mp3', '.wav', '.aac', '.flac', '.alac', '.ogg', '.aiff', '.aif', '.wma', '.dsd', '.opus', '.pcmu', '.pcma', '.gsm'] # Add or remove the format you accept as input
|
|
output_formats = ['aac', 'flac', 'mp3', 'm4b', 'm4a', 'mp4', 'mov', 'ogg', 'wav', 'webm']
|
|
default_audio_proc_samplerate = 24000
|
|
default_audio_proc_format = 'flac' # or 'mp3', 'aac', 'm4a', 'm4b', 'amr', '3gp', 'alac'. 'wav' format is ok but limited to process files < 4GB
|
|
default_output_format = 'm4b'
|
|
default_output_split = False
|
|
default_output_split_hours = '6' # if the final ouput esceed outpout_split_hours * 2 hours the final file will be splitted by outpout_split_hours + the end if any. |