@@ -439,178 +439,11 @@ You can also rename specific stems:
439439- **`demucs_params`:** (Optional) Demucs Architecture Specific Attributes & Defaults. `Default: {"segment_size": "Default", "shifts": 2, "overlap": 0.25, "segments_enabled": True}`
440440- **`mdxc_params`:** (Optional) MDXC Architecture Specific Attributes & Defaults. `Default: {"segment_size": 256, "override_model_segment_size": False, "batch_size": 1, "overlap": 8, "pitch_shift": 0}`
441441
442-
443442## Remote API Usage 🌐
444443
445444Audio Separator includes a remote API client that allows you to connect to a deployed Audio Separator API service, enabling you to perform audio separation without running the models locally. The API uses asynchronous processing with job polling for efficient handling of separation tasks.
446445
447- ### Deploying the API Server
448-
449- To use the remote API functionality, you' ll need to deploy the Audio Separator API server. The easiest way is using Modal.com:
450-
451- 1. ** Sign up for Modal.com** at [modal.com](https://modal.com)
452- 2. ** Install the Modal CLI** and authenticate:
453- ` ` ` bash
454- pip install modal
455- modal setup
456- ` ` `
457- 3. ** Deploy the Audio Separator API** :
458- ` ` ` bash
459- modal deploy audio_separator/remote/deploy_modal.py
460- ` ` `
461- 4. ** Get your API URL** from the deployment output. It will look like:
462- ` ` `
463- https://USERNAME--audio-separator-api.modal.run
464- ` ` `
465-
466- Set this API URL as an environment variable:
467- ` ` ` bash
468- export AUDIO_SEPARATOR_API_URL=" https://USERNAME--audio-separator-api.modal.run"
469- ` ` `
470-
471- Or pass it directly with the ` --api_url` parameter.
472-
473- # ## Remote API Client (Python)
474-
475- You can use the ` AudioSeparatorAPIClient` class to interact with a remote Audio Separator API:
476-
477- ` ` ` python
478- import logging
479- from audio_separator.remote import AudioSeparatorAPIClient
480-
481- # Set up logging
482- logger = logging.getLogger(__name__)
483-
484- # Initialize the API client
485- api_client = AudioSeparatorAPIClient(" https://USERNAME--audio-separator-api.modal.run" , logger)
486-
487- # Simple example: separate audio and get results
488- result = api_client.separate_audio_and_wait(" audio.mp3" )
489- if result[" status" ] == " completed" :
490- print(f" ✅ Separation completed! Downloaded files:" )
491- for file_path in result[" downloaded_files" ]:
492- print(f" - {file_path}" )
493- else:
494- print(f" ❌ Separation failed: {result.get('error', 'Unknown error')}" )
495-
496- # Complex example with custom options
497- result = api_client.separate_audio_and_wait(
498- " path/to/audio.wav" ,
499- model=" model_bs_roformer_ep_317_sdr_12.9755.ckpt" ,
500- timeout=300, # Wait up to 5 minutes
501- poll_interval=10, # Check status every 10 seconds
502- download=True, # Automatically download files
503- output_dir=" ./output" # Save files to specific directory
504- )
505-
506- # Advanced approach: manual job management (for custom polling logic)
507- result = api_client.separate_audio(" path/to/audio.wav" , model=" model_bs_roformer_ep_317_sdr_12.9755.ckpt" )
508- task_id = result[" task_id" ]
509- print(f" Job submitted! Task ID: {task_id}" )
510-
511- # Custom polling logic
512- import time
513- while True:
514- status = api_client.get_job_status(task_id)
515- print(f" Job status: {status['status']}" )
516-
517- if status[" status" ] == " completed" :
518- # Download files manually
519- for filename in status[" files" ]:
520- output_path = api_client.download_file(task_id, filename)
521- print(f" Downloaded: {output_path}" )
522- break
523- elif status[" status" ] == " error" :
524- print(f" Job failed: {status.get('error', 'Unknown error')}" )
525- break
526- else:
527- if " progress" in status:
528- print(f" Progress: {status['progress']}%" )
529- time.sleep(10) # Wait 10 seconds
530-
531- # List available models
532- models = api_client.list_models ()
533- print(models[" text" ])
534-
535- # Get server version
536- version = api_client.get_server_version ()
537- print(f" Server version: {version}" )
538- ` ` `
539-
540- # ## Remote API CLI
541-
542- Audio Separator also provides a command-line interface for interacting with remote APIs:
543-
544- # ### Commands
545-
546- ** Separate audio files:**
547- ` ` ` bash
548- # Separate audio file (asynchronous processing)
549- audio-separator-remote separate audio.wav --model model_bs_roformer_ep_317_sdr_12.9755.ckpt
550-
551- # Multiple files
552- audio-separator-remote separate audio1.wav audio2.wav audio3.wav
553-
554- # Use default model (if not specified)
555- audio-separator-remote separate audio.wav
556- ` ` `
557-
558- ** Check job status:**
559- ` ` ` bash
560- audio-separator-remote status < task_id>
561- ` ` `
562-
563- ** List available models:**
564- ` ` ` bash
565- # Pretty formatted list
566- audio-separator-remote models
567-
568- # JSON output
569- audio-separator-remote models --format json
570-
571- # Filter by stem type
572- audio-separator-remote models --filter vocals
573- ` ` `
574-
575- ** Download specific files:**
576- ` ` ` bash
577- audio-separator-remote download < task_id> filename1.wav filename2.wav
578- ` ` `
579-
580- ** Get version information:**
581- ` ` ` bash
582- audio-separator-remote --version
583- ` ` `
584-
585- # ### CLI Options
586-
587- - ` --api_url` : Override the API URL
588- - ` --timeout` : Set timeout for polling (default: 600 seconds)
589- - ` --poll_interval` : Set polling interval (default: 10 seconds)
590- - ` --debug` : Enable debug logging
591- - ` --log_level` : Set log level (info, debug, warning, etc.)
592-
593- # ### Examples
594-
595- ` ` ` bash
596- # Separate with custom settings
597- audio-separator-remote separate song.mp3 \
598- --model model_bs_roformer_ep_317_sdr_12.9755.ckpt \
599- --api_url https://my-api.com \
600- --timeout 300
601-
602- # Check status with debug logging
603- audio-separator-remote status abc123 --debug
604-
605- # List vocal separation models in JSON format
606- audio-separator-remote models --filter vocals --format json
607- ` ` `
608-
609- The remote API client automatically handles:
610- - File uploading and downloading
611- - Job polling and status updates
612- - Error handling and retries
613- - Progress reporting
446+ To deploy Audio Separator as an API on modal.com and use this for remote processing, please see the detailed documentation here: [audio_separator/remote/README.md](audio_separator/remote/README.md).
614447
615448## Requirements 📋
616449
@@ -695,8 +528,6 @@ poetry build
695528This will generate the distribution packages in the dist directory - but for now only @beveradb will be able to publish to PyPI.
696529
697530
698-
699-
700531# # Contributing 🤝
701532
702533Contributions are very much welcome! Please fork the repository and submit a pull request with your changes, and I' ll try to review, merge and publish promptly!
0 commit comments