---
source: https://iinventedlight.com/library/notes/hf-datasets-audio-preprocess.md
title: "Process audio datasets: resample and extract features"
license: CC-BY-4.0
license_url: https://creativecommons.org/licenses/by/4.0/
source_license: "Apache-2.0 (huggingface/datasets docs); prose restates cited source lines"
attribution: "Summary by iinventedlight (AI-assisted). Sources: Hugging Face (datasets docs), Process audio data · Hugging Face, Apache-2.0 (huggingface/datasets docs); Hugging Face (datasets docs), Load audio data · Hugging Face, Apache-2.0 (huggingface/datasets docs)."
author: "iinventedlight (synthesis of cited sources); text drafted with AI assistance"
date: 2026-11-04
status: published
checked_on: 2026-11-04
as_of: 2026-11-04
confidence: medium
untested: "No code was run for this note; only the fetched Hugging Face datasets docs pages were read."
category: hf-datasets
topic_area: "code-ai-eng: Hugging Face datasets library"
tags: huggingface, datasets, audio
sources:
  - id: S1
    title: "Process audio data · Hugging Face"
    publisher: Hugging Face (datasets docs)
    url: https://huggingface.co/docs/datasets/audio_process
    accessed: 2026-11-04
    license: "Apache-2.0 (huggingface/datasets docs)"
  - id: S2
    title: "Load audio data · Hugging Face"
    publisher: Hugging Face (datasets docs)
    url: https://huggingface.co/docs/datasets/audio_load
    accessed: 2026-11-04
    license: "Apache-2.0 (huggingface/datasets docs)"
---
# Process audio datasets: resample and extract features

## Short answer
Cast the audio column to the sampling rate your model expects with `cast_column("audio", Audio(sampling_rate=16000))`; decoding and resampling then happen on the fly. Next, run the model's feature extractor or processor over the data with `map()`. [S1][S2]

## Claims
- id: C1
  claim: cast_column with the Audio feature can resample the sampling rate.
  source: S1
  evidence: "When you use this function with the Audio feature, you can resample the sampling rate:"
- id: C2
  claim: Audio files are decoded and resampled on the fly.
  source: S1
  evidence: "Audio files are decoded and resampled on-the-fly"
- id: C3
  claim: Audio decoding uses torchcodec, built on FFmpeg.
  source: S2
  evidence: "Audio decoding is based on the torchcodec python package"

## Sources
- [S1] Process audio data · Hugging Face. Hugging Face (datasets docs). https://huggingface.co/docs/datasets/audio_process . License: Apache-2.0 (huggingface/datasets docs). Accessed 2026-11-04.
- [S2] Load audio data · Hugging Face. Hugging Face (datasets docs). https://huggingface.co/docs/datasets/audio_load . License: Apache-2.0 (huggingface/datasets docs). Accessed 2026-11-04.

License: this note is CC BY 4.0 (https://creativecommons.org/licenses/by/4.0/). Summary by iinventedlight (AI-assisted).
