PE-A-Frame is a state-of-the-art audio-text embedding model. For text, the model produces a single embedding. For audio, it produces a sequence of embeddings (onen for every 40ms of audio). These embeddings can then be used for audio event localization. For convienience, model outputs temporal spans (start and end timestamps) indicating when that event (freeform audio description) occurs in the audio.
Model Description
PE-A-Frame uses contrastive learning to align frame-level audio representations with text descriptions. The model can identify precise time ranges when described audio events occur
Model Variants
We release multiple model checkpoints with varying sizes:
import torch
from core.audio_visual_encoder import PEAudioFrame, PEAudioFrameTransform
device = torch.device("cuda"if torch.cuda.is_available() else"cpu")
# Load model and transform
model = PEAudioFrame.from_config("pe-a-frame-large", pretrained=True).to(device)
transform = PEAudioFrameTransform.from_config("pe-a-frame-large")
# Define audio file and event descriptions
audio_file = "office_conversation.wav"
descriptions = ["a person talking", "keyboard typing", "phone ringing"]
# Process inputs
inputs = transform(audio=[audio_file], text=descriptions).to(device)
# Run inferencewith torch.inference_mode():
outputs = model(**inputs, return_spans=True)
# Print detected time spans for each eventfor description, spans inzip(descriptions, outputs.spans):
if spans:
span_str = ", ".join([f"({start:.2f}s, {end:.2f}s)"for start, end in spans])
print(f'"{description}": [{span_str}]')
else:
print(f'"{description}": No events detected')
Example Output:
"a person talking": [(2.34s, 5.67s), (8.90s, 12.45s)]
"keyboard typing": [(1.20s, 3.40s), (6.78s, 9.12s)]
"phone ringing": No events detected
Batch Processing Multiple Audio Files
import torch
from core.audio_visual_encoder import PEAudioFrame, PEAudioFrameTransform
device = torch.device("cuda"if torch.cuda.is_available() else"cpu")
model = PEAudioFrame.from_config("pe-a-frame-large", pretrained=True).to(device)
transform = PEAudioFrameTransform.from_config("pe-a-frame-large")
# Process multiple audio files with different descriptions
audio_files = ["meeting.wav", "street.wav", "kitchen.wav"]
descriptions = [
"people discussing in a meeting",
"cars passing by",
"water running from a faucet"
]
inputs = transform(audio=audio_files, text=descriptions).to(device)
with torch.inference_mode():
outputs = model(**inputs, return_spans=True)
# Each audio-text pair gets its own span predictionsfor audio, description, spans inzip(audio_files, descriptions, outputs.spans):
if spans:
span_str = ", ".join([f"({start:.2f}s, {end:.2f}s)"for start, end in spans])
print(f'"{description}": [{span_str}] in {audio}')
else:
print(f'"{description}": No events detected in {audio}')
Adjusting Detection Threshold
The
threshold
parameter controls sensitivity for event detection. Lower values detect more events (higher recall), while higher values are more selective (higher precision):
# High sensitivity - detect more events (may include false positives)
outputs_sensitive = model(**inputs, threshold=0.2)
Extracting Embeddings Without Spans
If you only need embeddings without temporal localization:
inputs = transform(audio=[audio_file], text=descriptions).to(device)
with torch.inference_mode():
outputs = model(**inputs, return_spans=False)
# Access embeddings
audio_embeds = outputs.audio_embeds # Shape: [batch_size, num_frames, embed_dim]
text_embeds = outputs.text_embeds # Shape: [batch_size, embed_dim]# Compute similarity between audio frames and text# audio_embeds is frame-level, so you can see which frames match the description
similarities = torch.einsum("btd,bd->bt", audio_embeds, text_embeds)
# similarities shape: [batch_size, num_frames]
Usage with 🤗 Transformers
model = PeAudioFrameLevelModel.from_pretrained("facebook/pe-a-frame-large")
processor = PeAudioProcessor.from_pretrained("facebook/pe-a-frame-large")
inputs = transform(audio=[audio_file], text=descriptions, return_tensors="pt").to(device)
with torch.inference_mode():
outputs = model(**inputs)
# Access embeddings
audio_embeds = outputs.audio_embeds # Shape: [batch_size, num_frames, embed_dim]
text_embeds = outputs.text_audio_embeds # Shape: [batch_size, embed_dim]# Compute similarity between audio frames and text# audio_embeds is frame-level, so you can see which frames match the description
similarities = torch.einsum("btd,bd->bt", audio_embeds, text_embeds)
# similarities shape: [batch_size, num_frames]
Citation
@article{pe-av2025,
title={PEAV: An Audiovisual Perception Encoder via Large-Scale Multimodal Correspondence Learning},
author={Apoorv Vyas, Heng-Jui Chang, Cheng-Fu Yang, Po-Yao Huang, Luya Gao, Julius Richter, Sanyuan Chen, Matt Le, Piotr Dollár, Christoph Feichtenhofer, Ann Lee, Wei-Ning Hsu},
url={arxiv link coming soon}
year={2025}
}
License
This model is released under the Apache 2.0 license.
Runs of facebook pe-a-frame-large on huggingface.co
47.1K
Total runs
0
24-hour runs
2.4K
3-day runs
13.0K
7-day runs
19.7K
30-day runs
More Information About pe-a-frame-large huggingface.co Model
pe-a-frame-large huggingface.co is an AI model on huggingface.co that provides pe-a-frame-large's model effect (), which can be used instantly with this facebook pe-a-frame-large model. huggingface.co supports a free trial of the pe-a-frame-large model, and also provides paid use of the pe-a-frame-large. Support call pe-a-frame-large model through api, including Node.js, Python, http.
pe-a-frame-large huggingface.co is an online trial and call api platform, which integrates pe-a-frame-large's modeling effects, including api services, and provides a free online trial of pe-a-frame-large, you can try pe-a-frame-large online for free by clicking the link below.
facebook pe-a-frame-large online free url in huggingface.co:
pe-a-frame-large is an open source model from GitHub that offers a free installation service, and any user can find pe-a-frame-large on GitHub to install. At the same time, huggingface.co provides the effect of pe-a-frame-large install, users can directly use pe-a-frame-large installed effect in huggingface.co for debugging and trial. It also supports api for free installation.