[Error] The frame has 0 channels, expected 1.

#2
by ikalachy - opened

Running:

import torch
from transformers import AutoProcessor, MoonshineForConditionalGeneration
from datasets import load_dataset

processor = AutoProcessor.from_pretrained("UsefulSensors/moonshine-tiny")
model = MoonshineForConditionalGeneration.from_pretrained("UsefulSensors/moonshine-tiny")

ds = load_dataset("jacktol/ATC-ASR-Dataset", "default", split="validation")
print(ds[0])
audio_array = ds[0]["audio"]["array"]

inputs = processor(audio_array, return_tensors="pt")

generated_ids = model.generate(**inputs)

transcription = processor.batch_decode(generated_ids, skip_special_tokens=True)[0]
print(transcription)

getting The frame has 0 channels, expected 1. If you are hitting this, it may be because you are using a buggy FFmpeg version. FFmpeg4 is known to fail here in some valid scenarios. Try to upgrade FFmpeg?

How to get audio_array

Owner

On my PC, running the exact code you gave yields:

{'id': '020ZTX6P8Z5D5EUSC74C', 'audio': {'path': '020ZTX6P8Z5D5EUSC74C.wav', 'array': array([ 0.00045776,  0.00054932,  0.00061035, ...,  0.0005188 ,
       -0.00057983, -0.00106812]), 'sampling_rate': 16000}, 'text': 'PRAGA RADAR HELLO AEROFLOT TWO EIGHT FIVE APPROACHING TUSIN FLIGHT LEVEL TWO FOUR ZERO'}
It is strongly recommended to pass the `sampling_rate` argument to `Wav2Vec2FeatureExtractor()`. Failing to do so can result in silent errors that might be hard to debug.
President of the House of Representatives, Joe A. Twice, but he has to send quite a little to Bulgaria.

So it doesn't seem to be a code issue, but an FFMPEG issue. I'm on Windows using this version of FFMPEG:

ffmpeg version 2025-03-31-git-35c091f4b7-full_build-www.gyan.dev Copyright (c) 2000-2025 the FFmpeg developers
  built with gcc 14.2.0 (Rev1, Built by MSYS2 project)

But I remember running into this issue on a Linux machine once before, and yeah to my suprise it actually was my FFMPEG version which was the issue, not the code. I uninstalled the current version I had installed, cloned the FFMPEG repo, checked out version 7.1.1 and built it, and then the error resolved.

Best of luck!

jacktol changed discussion status to closed

Sign up or log in to comment