You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

添加--path命令行参数后遇argparse未识别参数错误求助

Fixing the "unrecognized arguments: --path" Error in Your UIS-RNN Speaker Diarization Script

Let's break down why you're seeing that error and fix it step by step:

1. Fix the Command Line Typo (Most Likely Culprit)

Your error message shows:

usage: Speakerdiar.py Speakerdiar.py: error: unrecognized arguments: --path /home/shiva/new

Notice the duplicate Speakerdiar.py in the usage line? This suggests either you ran the script with an extra script name in the command, or you misspelled the script name (you wrote Speakrdiar missing an 'e' instead of Speakerdiar.py).

Run this corrected command instead (replace your_audio.wav with your actual WAV file if /home/shiva/new is a directory):

python3 Speakerdiar.py --path /home/shiva/new/your_audio.wav

2. Improve the --path Argument Definition

While your current parser.add_argument('--path') works in theory, it lacks robustness. Update that line to:

parser.add_argument('--path', required=True, type=str, help='Full path to the input WAV file for speaker diarization')
  • required=True ensures the user can't run the script without providing this parameter, preventing silent failures.
  • type=str explicitly tells argparse to treat the input as a string, avoiding unexpected type issues.
  • help gives clear guidance to anyone using the script.

3. Fix the wav_path Assignment

Your current line wav_path = os.path.join(args.path,"/") is problematic. os.path.join automatically handles path separators, and adding a trailing "/" will override the path you passed in (e.g., it turns /home/shiva/new into just /). Replace it with:

wav_path = args.path

This directly uses the path the user provided, which aligns with what your load_data and load_wav functions expect (they're designed to process a single WAV file).

4. Verify Argument Parsing Order

Double-check that args = parser.parse_args() is called after defining all arguments (which it is in your code). This ensures argparse picks up the --path parameter correctly.

Once you make these changes, run the corrected command again, and the --path argument should be recognized without errors.

内容的提问来源于stack exchange,提问作者Vinu Abraham

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.07 08:33:14