Notice: In order to resolve issues more efficiently, please raise issue following the template.
(注意:为了更加高效率解决您遇到的问题,请按照模板提问,补充细节)
File "/home/ubuntu/funasr/Fun-ASR/model.py", line 609, in inference
return self.inference_llm(
~~~~~~~~~~~~~~~~~~^
data_in,
^^^^^^^^
...<4 lines>...
**kwargs,
^^^^^^^^^
)
^
File "/home/ubuntu/funasr/Fun-ASR/model.py", line 627, in inference_llm
inputs_embeds, contents, batch, source_ids, meta_data = self.inference_prepare(
~~~~~~~~~~~~~~~~~~~~~~^
data_in, data_lengths, key, tokenizer, frontend, **kwargs
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
)
^
File "/home/ubuntu/funasr/Fun-ASR/model.py", line 483, in inference_prepare
output = self.data_load_speech(
contents, tokenizer, frontend, meta_data=meta_data, **kwargs
)
File "/home/ubuntu/funasr/Fun-ASR/model.py", line 391, in data_load_speech
speech, speech_lengths = extract_fbank(
~~~~~~~~~~~~~^
data_src,
^^^^^^^^^
...<2 lines>...
is_final=True,
^^^^^^^^^^^^^^
) # speech: [b, T, d]
^
File "/home/ubuntu/.local/lib/python3.13/site-packages/funasr/utils/load_utils.py", line 218, in extract_fbank
data, data_len = frontend(data, data_len, **kwargs)
~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/ubuntu/.local/lib/python3.13/site-packages/torch/nn/modules/module.py", line 1776, in _wrapped_call_impl
return self._call_impl(*args, **kwargs)
~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^
File "/home/ubuntu/.local/lib/python3.13/site-packages/torch/nn/modules/module.py", line 1787, in _call_impl
return forward_call(*args, **kwargs)
File "/home/ubuntu/.local/lib/python3.13/site-packages/funasr/frontends/wav_frontend.py", line 128, in forward
waveform_length = input_lengths[i]
~~~~~~~~~~~~~^^^
IndexError: list index out of range
import numpy as np
import soundfile as sf
import torch
from model import FunASRNano
from tools.utils import load_audio
def main():
wav_path = "shuiqian1004_90.mp3"
model_dir = "FunAudioLLM/Fun-ASR-Nano-2512"
device = (
"cuda:0"
if torch.cuda.is_available()
else "mps"
if torch.backends.mps.is_available()
else "cpu"
)
m, kwargs = FunASRNano.from_pretrained(model=model_dir, device=device)
tokenizer = kwargs.get("tokenizer", None)
m.eval()
chunk_size = 0.72
duration = sf.info(wav_path).duration
cum_durations = np.arange(chunk_size, duration + chunk_size, chunk_size)
prev_text = ""
for idx, cum_duration in enumerate(cum_durations):
audio, rate = load_audio(wav_path, 16000, duration=round(cum_duration, 3))
prev_text = m.inference([torch.tensor(audio)], prev_text=prev_text, **kwargs)[0][0]["text"]
if idx != len(cum_durations) - 1:
prev_text = tokenizer.decode(tokenizer.encode(prev_text)[:-5]).replace("�", "")
if prev_text:
print(prev_text)
if __name__ == "__main__":
main()
Notice: In order to resolve issues more efficiently, please raise issue following the template.
(注意:为了更加高效率解决您遇到的问题,请按照模板提问,补充细节)
🐛 Bug
https://github.com/modelscope/FunASR/blob/main/funasr/utils/load_utils.py#L198 extract_fbank 函數當遇到 雙聲道音檔時會錯誤。這是因為這個時候
data.shape=[2, 11520],但是data_len=[11520],data_len應該要跟batch_size一樣所以應該是data_len=[11520, 11520]。To Reproduce
Steps to reproduce the behavior (always include the command you ran):
shuiqian1004_90.mp3
Code sample
Expected behavior
聽寫執行成功。
Environment
Linux funasr 6.6.87.2-microsoft-standard-WSL2 #1 SMP PREEMPT_DYNAMIC Thu Jun 5 18:30:46 UTC 2025 x86_64 GNU/Linuxpip, source): pipAdditional context