Hacktoberfest 2026: die Issues, die Maintainer für den Oktober markiert haben – offen und einsteigerfreundlich. Hacktoberfest-Issues durchsuchen

Bug: blank lines in wav.scp / jsonl file lists crash prepare_data_iterator (IndexError / JSONDecodeError)

Offen Anfängerfreundlich
#3,757 1 Kommentar 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen

Maintainer antworten meist innerhalb von 1 Tag

Ein zugehöriger Pull Request wurde bereits gemerged.

  • #3758 von @Lesereingrape — gemerged

Bewertung

Schwierigkeit
2/5
Geschätzter Aufwand
1-3 Stunden
Anfängerfreundlichkeit
85/100
Issue-Typ
Bug
Klarheit
Klar beschrieben
Aktivitätsstatus
Aktiv
Tech-Stack
python
Bereich
backend

Rechercherichtung

Beginne in funasr/auto/auto_model.py bei prepare_data_iterator(), insbesondere bei den im Issue beschriebenen Parsing-Zweigen für .jsonl und id/data. Führe die bereitgestellte Reproduktion mit leeren und ausschließlich aus Leerzeichen bestehenden Zeilen sowohl für wav.scp als auch für data.jsonl aus. Erledigt ist die Aufgabe, wenn leere Zeilen ignoriert werden und beide Aufrufe die zwei erwarteten IDs und Datenpfade ohne eine der beiden Ausnahmen zurückgeben.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Beschreibung

needs feedback

🐛 Bug

AutoModel.generate() with a file list (wav.scp, text.txt, file.jsonl, ...) crashes if the list contains a blank or whitespace-only line. prepare_data_iterator() in funasr/auto/auto_model.py iterates over every line without skipping empty ones:

  • the id \t data branch does lines = line.strip().split(maxsplit=1) and then indexes lines[0], so an empty line raises IndexError: list index out of range;
  • the .jsonl branch calls json.loads(line.strip()) on the empty line and raises json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0).

Blank lines are easy to produce in practice — lists concatenated from several sources, lists edited by hand, or files written with an extra separator line — and one of them aborts the whole batch instead of being ignored.

To Reproduce

  1. Install from source: pip install -e .
  2. Run the snippet below (it calls prepare_data_iterator directly, so no model weights or download are needed).
  3. See IndexError for the .scp list and JSONDecodeError for the .jsonl list.

Code sample

from funasr.auto.auto_model import prepare_data_iterator

open("wav.scp", "w", encoding="utf-8").write("utt1 /a.wav\n\nutt2 /b.wav\n")
open("data.jsonl", "w", encoding="utf-8").write(
    '{"key": "k1", "source": "/a.wav"}\n\n{"key": "k2", "source": "/b.wav"}\n'
)

prepare_data_iterator("wav.scp")     # IndexError: list index out of range
prepare_data_iterator("data.jsonl")  # json.decoder.JSONDecodeError

The same crash reaches users through model.generate(input="wav.scp").

Expected behavior

Blank lines carry no utterance, so they should be skipped; the two real entries should come back as (['utt1', 'utt2'], ['/a.wav', '/b.wav']) and (['k1', 'k2'], ['/a.wav', '/b.wav']), exactly as they do when the blank line is deleted manually.

Error logs

Traceback (most recent call last):
  File "repro.py", line 8, in <module>
    prepare_data_iterator("wav.scp")
  File ".../funasr/auto/auto_model.py", line 479, in prepare_data_iterator
    data = lines[1] if len(lines) > 1 else lines[0]
IndexError: list index out of range

Traceback (most recent call last):
  File "repro.py", line 9, in <module>
    prepare_data_iterator("data.jsonl")
  File ".../funasr/auto/auto_model.py", line 474, in prepare_data_iterator
    lines = json.loads(line.strip())
json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)

Environment

  • OS: Windows 11 26200 (the file-list reader is pure Python, so this reproduces on Linux too)
  • Python version: 3.11.14
  • FunASR version: source main at 66d7a4c264a5993a2a63ed00c1f402c296ee521a
  • ModelScope version: not used by this code path
  • PyTorch / torchaudio version: 2.14.1+cpu
  • Install method (pip, source, Docker): source, pip install -e . equivalent
  • Device (cuda, cpu, mps): cpu
  • GPU model: n/a
  • CUDA/cuDNN version: n/a
  • Docker image tag, if used: n/a

Audio details

No audio is needed — the crash happens while parsing the list file itself.

Vorherrschende Sprache
Python
Sterne
20.7k
Forks
2.1k
Ø Merge
23 Std. 18 Min.
Gemergte PRs (30 T.)
38

Entwicklungsumgebung

Erste Schritte

  1. Lesen Sie das ganze Issue und danach den Beitragsleitfaden des Projekts.
  2. Schreiben Sie ins Issue, dass Sie es übernehmen — das erspart doppelte Arbeit.
  3. Forken Sie das Repository und arbeiten Sie in einem Branch.
  4. Öffnen Sie einen Pull Request, der die Issue-Nummer nennt.

Mehr aus modelscope/FunASR

Alle Issues in modelscope/FunASR

Ähnliche Issues

Weitere Issues zu Python

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.