Commit Graph
52 Commits
Author SHA1 Message Date
Andrew Beveridge 0ce5225bde fix: integrate instrumental review UI into local CLI workflow
The instrumental review UI was built but never integrated into the
local CLI (karaoke-gen) workflow. This fix:

1. Adds run_instrumental_review() function to gen_cli.py that:
   - Analyzes backing vocals using AudioAnalyzer
   - Generates waveform visualization
   - Starts InstrumentalReviewServer and opens browser
   - Returns the user's selected instrumental file path

2. Integrates the review into the finalization loop:
   - Runs before KaraokeFinalise for each track
   - Passes selected_instrumental_file to KaraokeFinalise
   - Skips review if --skip_instrumental_review flag is set

3. Adds --skip_instrumental_review CLI flag for backwards compatibility

4. Adds comprehensive tests in test_cli_feature_parity.py that verify:
   - gen_cli.py has run_instrumental_review function
   - The function uses AudioAnalyzer, WaveformGenerator, and InstrumentalReviewServer
   - The --skip_instrumental_review flag works correctly

These tests would have caught this integration gap and will prevent
similar regressions in the future.

Version bump: 0.71.40 → 0.71.41
2025-12-11 19:15:37 -05:00
Andrew Beveridge 599625e21a fix: address CodeRabbit PR review comments and improve test coverage
CodeRabbit fixes:
- Chain exceptions with 'from e' in jobs.py for proper tracebacks
- Use logger.exception() for automatic stack traces
- Add end_seconds validation warning in audio_editing_service.py
- Handle recommended_selection='with_backing' explicitly in frontend
- Sync audio player state with actual audio element via event listeners
- Fix muted duration stats overcounting by clamping to audio duration
- Add num_points validation (1-10000) in server waveform endpoint
- Improve exception handling in server endpoints

Test coverage improvements:
- Add comprehensive tests for InstrumentalReviewServer
- Test request/response models
- Test server initialization and configuration
- Test FastAPI endpoints with TestClient
- Coverage: karaoke_gen 73.05% (above 70% minimum)

Version bump: 0.71.39 → 0.71.40
2025-12-11 18:33:20 -05:00
Andrew Beveridge f699850d30 feat: rewrite local review server with FastAPI and full-featured standalone UI
- Replace http.server with FastAPI for better async/CORS support
- Add complete standalone HTML/CSS/JS frontend with all features:
  - Dark theme matching React frontend
  - Interactive waveform display with Canvas rendering
  - Audio playback with source selection
  - Region selection via click/drag or quick-add from segments
  - Custom instrumental creation
  - Final selection submission with success feedback
- API endpoints now match cloud backend for true feature parity
- Update CLI parity tests for new FastAPI-based server structure
- Add test-instrumental-review.py script for local testing

This enables the same user experience for instrumental review
whether running locally (karaoke-gen) or remotely (karaoke-gen-remote).

Version bump: 0.71.38 → 0.71.39
2025-12-11 18:08:04 -05:00
Andrew Beveridge e8d9871d3e feat: Add intelligent instrumental selection with web-based review UI
Adds a comprehensive instrumental selection workflow with:
- Audio analysis to detect backing vocals (>-40dB threshold)
- Waveform visualization with segment highlighting
- Interactive web UI for audio playback and region selection
- Custom instrumental creation by muting selected regions
- Smart recommendations based on analysis results
- Feature parity between local (karaoke-gen) and remote (karaoke-gen-remote) CLIs

Key components:
- Shared core module (karaoke_gen/instrumental_review/) with AudioAnalyzer,
  AudioEditor, WaveformGenerator, and InstrumentalReviewServer
- Backend services wrapping core module with GCS integration
- New API endpoints for analysis, audio streaming, and custom creation
- React frontend components for waveform display, audio playback, region selection
- Local HTTP server for browser-based review in local CLI workflow
- 1280 tests passing with comprehensive coverage

Closes the need for manual Audacity editing when selecting instrumentals.
2025-12-11 17:12:49 -05:00
Andrew Beveridge 7eb082d382 test: Increase unit test coverage from 68% to 72%
Add comprehensive tests for:
- style_loader.py - new test file covering all loading, saving, and helper functions
- file_handler.py - tests for download_video, extract_metadata_from_url, backup_existing_outputs
- remote executor - tests for run_pipeline, _submit_job, _monitor_job

This brings test coverage above the required 70% CI threshold.
2025-12-11 14:15:27 -05:00
Andrew Beveridge 2b5ef28789 feat: Batch 3 - Existing Instrumental Support for Remote CLI
Add --existing_instrumental parameter to remote CLI to allow users to upload
and use their own pre-made instrumental file instead of AI-separated audio.

Key changes:
- remote_cli.py: Add existing_instrumental parameter to submit_job()
- file_upload.py: Add existing_instrumental file type with duration validation (±0.5s)
- job.py: Add existing_instrumental_gcs_path field to Job and JobCreate models
- video_worker.py: Download and use user-provided instrumental for final video encoding

Backend still runs AI separation for stems (to provide consistent download outputs),
but uses the user-provided instrumental for the final karaoke video.

Includes 20+ unit tests and maintains >70% coverage.
2025-12-11 02:06:18 -05:00
Andrew Beveridge 7480950a1b feat: implement signed URL uploads to bypass 32MB Cloud Run limit
The remote CLI was hitting Cloud Run's 32MB request body limit when
uploading large FLAC files with 4K PNG style assets. This implements
a two-step signed URL upload flow that bypasses the limit entirely:

1. CLI calls POST /api/jobs/create-with-upload-urls with job metadata
2. Backend returns signed GCS upload URLs for each file
3. CLI uploads files directly to GCS (no size limit)
4. CLI calls POST /api/jobs/{job_id}/uploads-complete to start processing

Benefits:
- No file size limits (GCS supports up to 5TB)
- Faster uploads (direct to storage, no proxy)
- Works with any HTTP client (no HTTP/2 required)
- Future-proof for web UI uploads

Changes:
- backend/services/storage_service.py: Add generate_signed_upload_url()
- backend/api/routes/file_upload.py: Add two new endpoints + models
- karaoke_gen/utils/remote_cli.py: Refactor submit_job() for signed URLs
- Add 21 new tests for the signed URL upload flow
- Bump version to 0.71.25

Also includes: Download spaCy model at Docker build time (not runtime)
2025-12-11 01:34:15 -05:00
Andrew Beveridge 18ee2df5a2 test: add comprehensive tests for --retry CLI mode to improve coverage 2025-12-10 20:15:11 -05:00
Andrew Beveridge 68b8cd25a4 fix: handle Discord webhook errors gracefully and add job retry capability
- Fix Discord webhook URL validation to strip trailing whitespace/newlines
  that can be introduced from environment variables or secrets (fixes %0A error)
- Make Discord notification failures non-fatal - log error and continue
- Add --retry CLI command to retry failed jobs from last checkpoint
- Add POST /api/jobs/{job_id}/retry endpoint for retrying failed jobs
- Bump version to 0.71.17

The root cause was environment variables or secrets containing trailing
newline characters (\n) which get URL-encoded as %0A, breaking Discord
API authentication.
2025-12-10 19:31:59 -05:00
Andrew Beveridge 849eeeb95e test: Update test mocks for job tracking attributes
Update remaining test cases to include the new bulk_delete,
filter_environment, filter_client_id, environment, and client_id
mock attributes needed for the job tracking feature.

Bump version to 0.71.2.
2025-12-10 01:48:45 -05:00
Andrew Beveridge 2135c2fb0b test: Update test mocks for new CLI filtering attributes
Adds mock attributes for:
- bulk_delete
- filter_environment
- filter_client_id
2025-12-10 01:44:25 -05:00
Andrew Beveridge 3456bee932 Add comprehensive tests for job management CLI commands
Add tests for:
- list_jobs, cancel_job, delete_job client methods
- --list, --cancel, --delete main() handlers
- Delete confirmation prompt (interactive/non-interactive modes)

Coverage restored to 70.83%

Bump version to 0.70.38
2025-12-10 01:12:38 -05:00
Andrew Beveridge 6294383f51 Add --list, --cancel, and --delete options to remote CLI
New job management commands for karaoke-gen-remote:
- --list / --list-jobs: List all jobs with ID, status, artist, and title
- --cancel <job_id>: Cancel a running job (stops processing, keeps record)
- --delete <job_id>: Permanently delete a job and all its files

Usage:
  karaoke-gen-remote --list
  karaoke-gen-remote --cancel abc12345
  karaoke-gen-remote --delete abc12345 [-y]

The delete command prompts for confirmation unless -y flag is passed.

Bump version to 0.70.36
2025-12-10 01:00:37 -05:00
Andrew Beveridge 4f8f15d88c Fix Discord webhook and improve YouTube thumbnail error handling
- Change DEFAULT_DISCORD_WEBHOOK_URL to use discord-releases-webhook instead
  of discord-alert-webhook (alerts channel was for errors, not releases)
- Created discord-releases-webhook secret in GCP with correct webhook URL
- Add better error handling for YouTube thumbnail upload:
  - Check if file exists before attempting upload
  - Catch and log exceptions instead of failing silently
  - Warn user if thumbnail upload fails but video succeeded
- Update tests to mock os.path.isfile for thumbnail upload tests
- Bump version to 0.70.34
2025-12-10 00:34:43 -05:00
Andrew Beveridge 8a014b89a8 Fix YouTube upload and Discord notification for server-side mode
- Enable YouTube upload when pre-stored credentials are provided (server-side mode)
  Previously, youtube_upload_enabled was only set when youtube_client_secrets_file was
  provided. Now also enables when user_youtube_credentials is provided.

- Move Discord notification outside YouTube upload block so it runs independently
  Previously Discord notification was nested inside the youtube_upload_enabled condition,
  meaning it would never run if YouTube wasn't enabled.

- Discord notification only posts when there's a YouTube URL (as requested)

- Add non_interactive check when YouTube upload fails to avoid hanging in server mode

- Update test to explicitly set non_interactive=False for interactive failure case

- Bump version to 0.70.32
2025-12-09 23:51:50 -05:00
Andrew Beveridge c823bd9426 test: Improve test coverage to meet 70% threshold
- Add comprehensive tests for DropboxService methods (upload, shared links)
- Add comprehensive tests for GoogleDriveService methods (folder ops, uploads)
- Add tests for video worker native distribution handling
- Add tests for RemoteExecutor session and job status methods
- Add tests for PipelineContext cleanup and logging methods
- Fix test imports and mock paths
- Version bump to 0.70.23

Coverage now at 70.88% for karaoke_gen (required: 70%)
2025-12-09 16:15:17 -05:00
Andrew Beveridge af82886b99 test: Add comprehensive tests for native API distribution and pipeline
- Add unit tests for DropboxService (brand code calculation, configuration)
- Add unit tests for GoogleDriveService (configuration, singleton pattern)
- Add tests for Job model distribution fields (dropbox_path, gdrive_folder_id)
- Add tests for file upload endpoint distribution parameters
- Add pipeline tests for base classes, context, stages, and executors
- Add remote CLI tests for distribution parameter handling
- Version bump to 0.70.22
2025-12-09 15:52:53 -05:00
Andrew Beveridge e8b3d3c906 Replaced yt-dlp with FlacFetch for alternate audio sources 2025-12-08 13:12:32 -05:00
Andrew Beveridge c402a2cb64 Add comprehensive tests for remote_cli.py to meet coverage requirements
Adds 56 tests covering:
- JobStatus enum and Config dataclass
- RemoteKaraokeClient methods (auth, style parsing, API calls)
- JobMonitor methods (browser, timeline, downloads)
- Helper functions (check_prerequisites, get_auth_token)
- main() function argument handling and error cases

Increases test coverage from 62.55% to 72.62%, meeting the 70% minimum.
2025-12-08 10:55:46 -05:00
Andrew Beveridge 9faa62bdb0 Added unit tests with thorough coverage 2025-12-01 19:02:42 -05:00
Andrew Beveridge a802386e7d Added video background support 2025-10-26 16:43:05 -04:00
Andrew Beveridge e9f18118ca Added support for automatic audio padding based on output from LyricsTranscriber 2025-10-24 15:48:19 -04:00
Andrew Beveridge edc720d1e6 Fixed logic bug causing duplicate separation 2025-09-25 17:58:11 -04:00
Andrew Beveridge 7c81822fc0 Added CLI parameter to override specific style JSON values 2025-08-30 22:17:29 -04:00
Andrew Beveridge 6d9e015833 Fixed bug with youtube match always yes in headless on modal 2025-08-08 17:30:30 -04:00
Andrew Beveridge 49c9a82034 Fixed duplicate audio separation, finished implementing remote audio separation on modal when env var is set 2025-07-26 01:30:07 -04:00
Andrew Beveridge fd428febc7 Changed rclone sync to skip existing files to prevent overwriting fixes in cloud destinations 2025-07-19 12:15:57 -04:00
Andrew Beveridge dab88f0868 Skipped nvenc tests due to temporary disablement 2025-07-19 11:40:28 -04:00
Andrew Beveridge 3776f4d803 FIxed tests, fixed modal web implementation (at least for a first end to end successful job with upload to youtube, dropbox and google drive etc.) 2025-07-08 02:22:05 -04:00
Andrew Beveridge 7c8c57cd26 Fixed tests, fixed some other issues in finalizaion 2025-07-08 00:50:55 -04:00
Andrew Beveridge e3b71cfc1c Fixed tests, bumped version for release 0.56 2025-07-05 11:26:49 -04:00
Andrew Beveridge e4042932f7 Maybe fix tests 2025-07-03 12:23:49 -04:00
Andrew Beveridge aa9a6e8659 Fix unit test mocking to fix CI 2025-06-29 16:55:50 -04:00
Andrew Beveridge 9169e5b4a7 Restructured tests, fixed support for python 3.13, updated to latest audio-separator and numpy etc. 2025-06-29 16:36:59 -04:00
Andrew Beveridge d53d015e72 Fixed tests, tidied up pytest config to match other projects 2025-06-29 15:05:45 -04:00
Andrew Beveridge 5012c5d0a1 Fixed edit mode and began adding integration test for it (currently failing) 2025-04-06 21:47:30 -04:00
Andrew Beveridge 2d7b0f1c26 Fixed all tests 2025-04-03 11:31:09 -04:00
Andrew Beveridge cfe16f6184 Only 3 more failing unit tests to go 2025-04-03 01:44:33 -04:00
Andrew Beveridge 510c3bf10e Fixed CLI tests 2025-04-02 22:48:34 -04:00
Andrew Beveridge 8ba63b2947 In theory, fixed all tests after the first iteration of extracting functionality. Full integration test failing though. 2025-04-02 09:47:42 -04:00
Andrew Beveridge 84faf54256 Fixed all tests 2025-04-02 00:21:48 -04:00
Andrew Beveridge ebca11c8f1 Improved a few more bulk_cli tests 2025-04-01 23:49:00 -04:00
Andrew Beveridge 8fd2287566 Fixed/skipped all tests 2025-04-01 23:27:46 -04:00
Andrew Beveridge 3cedf10243 Fixed more CLI tests, 9 failing 2025-04-01 23:09:58 -04:00
Andrew Beveridge e2383634ed Added more tests for CLI bits, 16 still failin 2025-04-01 22:19:57 -04:00
Andrew Beveridge 4157076365 Fixed all tests 2025-04-01 14:34:14 -04:00
Andrew Beveridge a0c50367e3 Fixed all but 13 finalise tests 2025-04-01 13:10:30 -04:00
Andrew Beveridge 716ea76fa8 First pass at finalise tests (41 failing) 2025-04-01 12:54:14 -04:00
Andrew Beveridge ec08054d99 Exclude slow integration test from default pytest 2025-04-01 12:33:22 -04:00
Andrew Beveridge d71047bace Fixed all but 2 tests 2025-04-01 12:16:24 -04:00