mrfakename / sam-audio-base

huggingface.co
Total runs: 87
24-hour runs: 0
7-day runs: -48
30-day runs: -48
Model's Last Updated: Tháng 12 19 2025

Introduction of sam-audio-base

Model Details of sam-audio-base

SAM-Audio: Segment Anything Model for Audio

SAM-Audio is a model for isolating any sound in audio using text, visual, or temporal prompts. It can separate specific sounds from complex audio mixtures based on natural language descriptions, visual cues from video, or time spans.

Authentication

Before using SAM-Audio, you need to:

  1. Request access to the checkpoints on the SAM-Audio Hugging Face repo
  2. Authenticate with Hugging Face: huggingface-cli login
Usage

SAM-Audio supports three types of prompting: text, visual, and span. Each method allows you to specify which sounds to isolate in different ways.

1. Text Prompting

Use natural language descriptions to isolate sounds.

import torch
import torchaudio
from sam_audio import SAMAudio, SAMAudioProcessor

# Load model and processor
device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
model = SAMAudio.from_pretrained("facebook/sam-audio-large").to(device).eval()
processor = SAMAudioProcessor.from_pretrained("facebook/sam-audio-large")

# Load audio file
audio_file = "path/to/audio.wav"

# Describe the sound you want to isolate
description = "A man speaking"

# Process and separate
inputs = processor(audios=[audio_file], descriptions=[description]).to(device)
with torch.inference_mode():
    result = model.separate(inputs)

# Save results
torchaudio.save("target.wav", result.target[0].unsqueeze(0).cpu(), processor.audio_sampling_rate)
torchaudio.save("residual.wav", result.residual[0].unsqueeze(0).cpu(), processor.audio_sampling_rate)

Examples of text descriptions:

  • "A person coughing"
  • "Raindrops are falling heavily, splashing on the ground"
  • "A dog barking"
  • "Piano playing a melody"
  • "Car engine revving"
2. Visual Prompting

Isolate sounds associated with specific visual objects in a video using masked video frames.

import torch
import numpy as np
from sam_audio import SAMAudio, SAMAudioProcessor
from torchcodec.decoders import VideoDecoder

# NOTE: Requires SAM3 for creating masks
# pip install git+https://github.com/facebookresearch/sam3.git
from sam3.model_builder import build_sam3_video_predictor

# Load SAM-Audio model
device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
model = SAMAudio.from_pretrained("facebook/sam-audio-large").to(device).eval()
processor = SAMAudioProcessor.from_pretrained("facebook/sam-audio-large")

# Load video
video_file = "path/to/video.mp4"
decoder = VideoDecoder(video_file)
frames = decoder[:]

# Create mask using SAM3 (example with text prompt)
video_predictor = build_sam3_video_predictor()
response = video_predictor.handle_request({
    "type": "start_session",
    "resource_path": video_file,
})
session_id = response["session_id"]

masks = []
for frame_index in range(len(decoder)):
    response = video_predictor.handle_request({
        "type": "add_prompt",
        "session_id": session_id,
        "frame_index": frame_index,
        "text": "The person on the left",  # Visual object to isolate
    })
    mask = response["outputs"]["out_binary_masks"]
    if mask.shape[0] == 0:
        mask = np.zeros_like(frames[0, [0]], dtype=bool)
    masks.append(mask[:1])

mask = torch.from_numpy(np.concatenate(masks)).unsqueeze(1)

# Process with visual prompting
inputs = processor(
    audios=[video_file],
    descriptions=[""],
    masked_videos=processor.mask_videos([frames], [mask]),
).to(device)

with torch.inference_mode():
    result = model.separate(inputs)
3. Span Prompting (Temporal Anchors)

Specify time ranges where the target sound occurs or doesn't occur. This provides a specific example to the model of what to isolate

import torch
import torchaudio
from sam_audio import SAMAudio, SAMAudioProcessor

# Load model and processor
device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
model = SAMAudio.from_pretrained("facebook/sam-audio-large").to(device).eval()
processor = SAMAudioProcessor.from_pretrained("facebook/sam-audio-large")

# Define anchors: [type, start_time, end_time]
# "+" means the sound IS present in this time range
# "-" means the sound is NOT present in this time range
anchors = [
    ["+", 6.3, 7.0],  # Sound occurs between 6.3 and 7.0 seconds
]

# Process with span prompting
inputs = processor(
    audios=[audio_file],
    descriptions=["A horn honking"],
    anchors=[anchors],
).to(device)

with torch.inference_mode():
    result = model.separate(inputs)

Example with multiple anchors:

anchors = [
    ["+", 2.0, 3.5],   # Sound present from 2.0 to 3.5 seconds
    ["+", 8.0, 9.0],   # Sound present from 8.0 to 9.0 seconds
    ["-", 0.0, 1.0],   # Sound NOT present from 0.0 to 1.0 seconds
]
Output Format

The model.separate() method returns a result object with:

  • result.target : The isolated sound (what you asked for)
  • result.residual : Everything else (the remainder)

Both are list[torch.Tensor] where each tensor is a 1D waveform

Citation

If you use SAM-Audio in your research, please cite:

@article{sam-audio,
  title={SAM-Audio: Segment Anything in Audio},
  author={Bowen Shi, Andros Tjandra, John Hoffman, Helin Wang, Yi-Chiao Wu, Luya Gao, Julius Richter, Matt Le, Apoorv Vyas, Sanyuan Chen, Christoph Feichtenhofer, Piotr Dollár, Wei-Ning Hsu, Ann Lee},
  year={2025}
  url={arxiv link coming soon}
}
License

This project is licensed under the SAM License. See the LICENSE file for details.

Runs of mrfakename sam-audio-base on huggingface.co

87
Total runs
0
24-hour runs
-73
3-day runs
-48
7-day runs
-48
30-day runs

More Information About sam-audio-base huggingface.co Model

More sam-audio-base license Visit here:

https://choosealicense.com/licenses/sam-license

sam-audio-base huggingface.co

sam-audio-base huggingface.co is an AI model on huggingface.co that provides sam-audio-base's model effect (), which can be used instantly with this mrfakename sam-audio-base model. huggingface.co supports a free trial of the sam-audio-base model, and also provides paid use of the sam-audio-base. Support call sam-audio-base model through api, including Node.js, Python, http.

mrfakename sam-audio-base online free

sam-audio-base huggingface.co is an online trial and call api platform, which integrates sam-audio-base's modeling effects, including api services, and provides a free online trial of sam-audio-base, you can try sam-audio-base online for free by clicking the link below.

mrfakename sam-audio-base online free url in huggingface.co:

https://huggingface.co/mrfakename/sam-audio-base

sam-audio-base install

sam-audio-base is an open source model from GitHub that offers a free installation service, and any user can find sam-audio-base on GitHub to install. At the same time, huggingface.co provides the effect of sam-audio-base install, users can directly use sam-audio-base installed effect in huggingface.co for debugging and trial. It also supports api for free installation.

sam-audio-base install url in huggingface.co:

https://huggingface.co/mrfakename/sam-audio-base

Url of sam-audio-base

sam-audio-base huggingface.co Url

Provider of sam-audio-base huggingface.co

mrfakename
ORGANIZATIONS

Other API from mrfakename

huggingface.co

Total runs: 86
Run Growth: -217
Growth Rate: -252.33%
Updated:Tháng mười một 27 2025
huggingface.co

Total runs: 34
Run Growth: 0
Growth Rate: 0.00%
Updated:Tháng 12 01 2025
huggingface.co

Total runs: 22
Run Growth: 19
Growth Rate: 86.36%
Updated:Tháng tư 24 2024
huggingface.co

Total runs: 10
Run Growth: -1
Growth Rate: -10.00%
Updated:Có thể 24 2026
huggingface.co

Total runs: 6
Run Growth: 2
Growth Rate: 33.33%
Updated:Tháng tư 23 2025
huggingface.co

Total runs: 0
Run Growth: 0
Growth Rate: 0.00%
Updated:Tháng mười một 25 2025
huggingface.co

Total runs: 0
Run Growth: 0
Growth Rate: 0.00%
Updated:Bước đều 27 2025
huggingface.co

Total runs: 0
Run Growth: 0
Growth Rate: 0.00%
Updated:Tháng Mười 30 2025