admin管理员组文章数量:1399225
Trying to run the sample python code given here [(.py)] in Colab.
I tried runnning the same code in all cpu and gpus available in colab and I got the same error. The same code when run on my macbook intel on cpu gives no error. This code also surprisingly worked in kaggle.
code:
!pip install torch torchaudio -f .html --quiet !pip install deepfilternet --quiet
from df.enhance import enhance, init_df, load_audio, save_audio from df.utils import download_file if __name__ == "__main__": # Load default model model, df_state, _ = init_df() # Download and open some audio file. You use your audio files here audio_path = download_file( ".wav", download_dir=".", ) audio, _ = load_audio(audio_path, sr=df_state.sr()) # Denoise the audio enhanced = enhance(model, df_state, audio) # Save for listening save_audio("enhanced.wav", enhanced, df_state.sr())
complete error:
2025-03-25 18:11:11 | INFO | DF | Loading model settings of DeepFilterNet3 2025-03-25 18:11:11 | INFO | DF | Using DeepFilterNet3 model at /root/.cache/DeepFilterNet/DeepFilterNet3 2025-03-25 18:11:11 | INFO | DF | Initializing model `deepfilternet3` 2025-03-25 18:11:11 | INFO | DF | Found checkpoint /root/.cache/DeepFilterNet/DeepFilterNet3/checkpoints/model_120.ckpt.best with epoch 120 2025-03-25 18:11:11 | INFO | DF | Running on device cuda:0 2025-03-25 18:11:11 | INFO | DF | Model loaded --------------------------------------------------------------------------- TypeError Traceback (most recent call last) [<ipython-input-13-8e53b6efe558>](https://localhost:8080/#) in <cell line: 0>() 12 audio, _ = load_audio(audio_path, sr=df_state.sr()) 13 # Denoise the audio ---> 14 enhanced = enhance(model, df_state, audio) 15 # Save for listening 16 save_audio("enhanced.wav", enhanced, df_state.sr()) 2 frames [/usr/local/lib/python3.11/dist-packages/torch/utils/_contextlib.py](https://localhost:8080/#) in decorate_context(*args, **kwargs) 114 def decorate_context(*args, **kwargs): 115 with ctx_factory(): --> 116 return func(*args, **kwargs) 117 118 return decorate_context [/usr/local/lib/python3.11/dist-packages/df/enhance.py](https://localhost:8080/#) in enhance(model, df_state, audio, pad, atten_lim_db) 232 audio = F.pad(audio, (0, n_fft)) 233 nb_df = getattr(model, "nb_df", getattr(model, "df_bins", ModelParams().nb_df)) --> 234 spec, erb_feat, spec_feat = df_features(audio, df_state, nb_df, device=get_device()) 235 enhanced = model(spec.clone(), erb_feat, spec_feat)[0].cpu() 236 enhanced = as_complex(enhanced.squeeze(1)) [/usr/local/lib/python3.11/dist-packages/df/enhance.py](https://localhost:8080/#) in df_features(audio, df, nb_df, device) 188 189 def df_features(audio: Tensor, df: DF, nb_df: int, device=None) -> Tuple[Tensor, Tensor, Tensor]: --> 190 spec = df.analysis(audio.numpy()) # [C, Tf] -> [C, Tf, F] 191 a = get_norm_alpha(False) 192 erb_fb = df.erb_widths() TypeError: argument 'input': 'ndarray' object cannot be converted to 'PyArray<T, D>'
Any help is appreciated!
本文标签:
版权声明:本文标题:audio - Deepfilter example python code in Colab gives error - TypeError: argument 'input': 'ndarray& 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744175815a2593993.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论