# Sam Audio

> Audio separation with SAM Audio. Isolate any sound using natural language—professional-grade audio editing made simple for creators, researchers, and accessibility applications.


## Overview

- **Endpoint**: `https://fal.run/fal-ai/sam-audio/visual-separate`
- **Model ID**: `fal-ai/sam-audio/visual-separate`
- **Category**: video-to-audio
- **Kind**: inference
**Tags**: video-to-audio, sam-audio



## Pricing

You request will be billed $0.05 per 30s of output audio. Note: You'll be charged $0.025 per 30s per additional reranking candidate.

For more details, see [fal.ai pricing](https://fal.ai/pricing).

## API Information

This model can be used via our HTTP API or more conveniently via our client libraries.
See the input and output schema below, as well as the usage examples.


### Input Schema

The API accepts the following input parameters:


- **`video_url`** (`string`, _required_):
  URL of the video file to process (MP4, MOV, etc.)
  - Examples: "https://v3b.fal.media/files/b/0a8850d1/gff7zKI-6XwIbBBip4946_office.mp4"

- **`mask_video_url`** (`string`, _optional_):
  URL of the mask video (binary mask indicating target object). Black=target, White=background.

- **`prompt`** (`string`, _optional_):
  Text prompt to assist with separation. Use natural language to describe the target sound. Default value: `""`
  - Default: `""`
  - Examples: "man on the left"

- **`reranking_candidates`** (`integer`, _optional_):
  Number of candidates to generate and rank. Higher improves quality but increases latency and cost. Default value: `1`
  - Default: `1`
  - Range: `1` to `4`

- **`acceleration`** (`AccelerationEnum`, _optional_):
  The acceleration level to use. Default value: `"balanced"`
  - Default: `"balanced"`
  - Options: `"fast"`, `"balanced"`, `"quality"`

- **`max_chunk_duration`** (`float`, _optional_):
  Maximum audio duration (in seconds) to process in a single pass. Longer audio will be chunked with overlap and blended. Default value: `60`
  - Default: `60`
  - Range: `10` to `60`

- **`chunk_overlap`** (`float`, _optional_):
  Overlap duration (in seconds) between chunks for crossfade blending. Default value: `5`
  - Default: `5`
  - Range: `0` to `30`

- **`output_format`** (`OutputFormatEnum`, _optional_):
  Output audio format. Default value: `"wav"`
  - Default: `"wav"`
  - Options: `"wav"`, `"mp3"`



**Required Parameters Example**:

```json
{
  "video_url": "https://v3b.fal.media/files/b/0a8850d1/gff7zKI-6XwIbBBip4946_office.mp4"
}
```

**Full Example**:

```json
{
  "video_url": "https://v3b.fal.media/files/b/0a8850d1/gff7zKI-6XwIbBBip4946_office.mp4",
  "prompt": "man on the left",
  "reranking_candidates": 1,
  "acceleration": "balanced",
  "max_chunk_duration": 60,
  "chunk_overlap": 5,
  "output_format": "wav"
}
```


### Output Schema

The API returns the following output format:

- **`target`** (`File`, _required_):
  The isolated target sound.
  - Examples: {"content_type":"audio/wav","url":"https://v3b.fal.media/files/b/0a88550c/CVyBZ1Cxka1vLxVwOfUcc_tmpzzftm934.wav"}

- **`residual`** (`File`, _required_):
  Everything else in the audio.
  - Examples: {"content_type":"audio/wav","url":"https://v3b.fal.media/files/b/0a88550c/pdOH_J84S-197LRjMQDrz_tmprx375uix.wav"}

- **`duration`** (`float`, _required_):
  Duration of the output audio in seconds.
  - Examples: 15

- **`sample_rate`** (`integer`, _optional_):
  Sample rate of the output audio in Hz. Default value: `48000`
  - Default: `48000`



**Example Response**:

```json
{
  "target": {
    "content_type": "audio/wav",
    "url": "https://v3b.fal.media/files/b/0a88550c/CVyBZ1Cxka1vLxVwOfUcc_tmpzzftm934.wav"
  },
  "residual": {
    "content_type": "audio/wav",
    "url": "https://v3b.fal.media/files/b/0a88550c/pdOH_J84S-197LRjMQDrz_tmprx375uix.wav"
  },
  "duration": 15,
  "sample_rate": 48000
}
```


## Usage Examples

### cURL

```bash
curl --request POST \
  --url https://fal.run/fal-ai/sam-audio/visual-separate \
  --header "Authorization: Key $FAL_KEY" \
  --header "Content-Type: application/json" \
  --data '{
     "video_url": "https://v3b.fal.media/files/b/0a8850d1/gff7zKI-6XwIbBBip4946_office.mp4"
   }'
```

### Python

Ensure you have the Python client installed:

```bash
pip install fal-client
```

Then use the API client to make requests:

```python
import fal_client

def on_queue_update(update):
    if isinstance(update, fal_client.InProgress):
        for log in update.logs:
           print(log["message"])

result = fal_client.subscribe(
    "fal-ai/sam-audio/visual-separate",
    arguments={
        "video_url": "https://v3b.fal.media/files/b/0a8850d1/gff7zKI-6XwIbBBip4946_office.mp4"
    },
    with_logs=True,
    on_queue_update=on_queue_update,
)
print(result)
```

### JavaScript

Ensure you have the JavaScript client installed:

```bash
npm install --save @fal-ai/client
```

Then use the API client to make requests:

```javascript
import { fal } from "@fal-ai/client";

const result = await fal.subscribe("fal-ai/sam-audio/visual-separate", {
  input: {
    video_url: "https://v3b.fal.media/files/b/0a8850d1/gff7zKI-6XwIbBBip4946_office.mp4"
  },
  logs: true,
  onQueueUpdate: (update) => {
    if (update.status === "IN_PROGRESS") {
      update.logs.map((log) => log.message).forEach(console.log);
    }
  },
});
console.log(result.data);
console.log(result.requestId);
```


## Additional Resources

### Documentation

- [Model Playground](https://fal.ai/models/fal-ai/sam-audio/visual-separate)
- [API Documentation](https://fal.ai/models/fal-ai/sam-audio/visual-separate/api)
- [OpenAPI Schema](https://fal.ai/api/openapi/queue/openapi.json?endpoint_id=fal-ai/sam-audio/visual-separate)

### fal.ai Platform

- [Platform Documentation](https://docs.fal.ai)
- [Python Client](https://docs.fal.ai/clients/python)
- [JavaScript Client](https://docs.fal.ai/clients/javascript)
