mirror of
https://github.com/jamiepine/voicebox.git
synced 2026-09-19 23:00:45 -07:00
refactor: remove dead code, deduplicate backends
Phase 1 - delete dead code: - studio.py, migrate_add_instruct.py, utils/validation.py - duplicate _profile_to_response in main.py, duplicate asyncio import - pointless _get_profiles_dir/_get_generations_dir wrappers - duplicate LANGUAGE_CODE_TO_NAME and WHISPER_HF_REPOS constants Phase 2 - extract backends/base.py with shared utilities: - is_model_cached() replaces 7 copy-pasted HF cache checks - get_torch_device() replaces 5 device detection methods - combine_voice_prompts() replaces 5 identical implementations - model_load_progress() ctx manager replaces progress boilerplate in all backends - patch_chatterbox_f32() replaces identical monkey-patches in both chatterbox backends net -1078 lines across the backend
This commit is contained in:
+4
-9
@@ -58,11 +58,6 @@ def _profile_to_response(
|
||||
)
|
||||
|
||||
|
||||
def _get_profiles_dir() -> Path:
|
||||
"""Get profiles directory from config."""
|
||||
return config.get_profiles_dir()
|
||||
|
||||
|
||||
async def create_profile(
|
||||
data: VoiceProfileCreate,
|
||||
db: Session,
|
||||
@@ -100,7 +95,7 @@ async def create_profile(
|
||||
db.refresh(db_profile)
|
||||
|
||||
# Create profile directory
|
||||
profile_dir = _get_profiles_dir() / db_profile.id
|
||||
profile_dir = config.get_profiles_dir() / db_profile.id
|
||||
profile_dir.mkdir(parents=True, exist_ok=True)
|
||||
|
||||
return _profile_to_response(db_profile)
|
||||
@@ -136,7 +131,7 @@ async def add_profile_sample(
|
||||
|
||||
# Create sample ID and directory
|
||||
sample_id = str(uuid.uuid4())
|
||||
profile_dir = _get_profiles_dir() / profile_id
|
||||
profile_dir = config.get_profiles_dir() / profile_id
|
||||
profile_dir.mkdir(parents=True, exist_ok=True)
|
||||
|
||||
# Copy audio file to profile directory
|
||||
@@ -316,7 +311,7 @@ async def delete_profile(
|
||||
db.commit()
|
||||
|
||||
# Delete profile directory
|
||||
profile_dir = _get_profiles_dir() / profile_id
|
||||
profile_dir = config.get_profiles_dir() / profile_id
|
||||
if profile_dir.exists():
|
||||
shutil.rmtree(profile_dir)
|
||||
|
||||
@@ -516,7 +511,7 @@ async def upload_avatar(
|
||||
ext = ext_map.get(img_format, '.png')
|
||||
|
||||
# Save processed image to profile directory
|
||||
profile_dir = _get_profiles_dir() / profile_id
|
||||
profile_dir = config.get_profiles_dir() / profile_id
|
||||
profile_dir.mkdir(parents=True, exist_ok=True)
|
||||
output_path = profile_dir / f"avatar{ext}"
|
||||
|
||||
|
||||
Reference in New Issue
Block a user