我试图使用此Python脚本比较声音,但是我可以找到上传它们的位置;和目标文件''''
我是Python的新手,并且通常需要比较2个声音文件,而这个脚本似乎可以做到,但是我不知道如何将.Wav文件上传到此脚本,所以请帮助我
#!/usr/bin/python3
# compare.py
import argparse
from correlation import correlate
def initialize():
parser = argparse.ArgumentParser()
parser.add_argument("-i ", "--source-file", help="source file")
parser.add_argument("-o ", "--target-file", help="target file")
args = parser.parse_args()
SOURCE_FILE = args.source_file if args.source_file else None
TARGET_FILE = args.target_file if args.target_file else None
if not SOURCE_FILE or not TARGET_FILE:
raise Exception("Source or Target files not specified.")
return SOURCE_FILE, TARGET_FILE
if __name__ == "__main__":
SOURCE_FILE, TARGET_FILE = initialize()
correlate(SOURCE_FILE, TARGET_FILE)
i'm new to python and to programming in general, i just need to compare 2 sound files and this script seems to do it but i can't figure out how to upload my .WAV files to this script so please help me
#!/usr/bin/python3
# compare.py
import argparse
from correlation import correlate
def initialize():
parser = argparse.ArgumentParser()
parser.add_argument("-i ", "--source-file", help="source file")
parser.add_argument("-o ", "--target-file", help="target file")
args = parser.parse_args()
SOURCE_FILE = args.source_file if args.source_file else None
TARGET_FILE = args.target_file if args.target_file else None
if not SOURCE_FILE or not TARGET_FILE:
raise Exception("Source or Target files not specified.")
return SOURCE_FILE, TARGET_FILE
if __name__ == "__main__":
SOURCE_FILE, TARGET_FILE = initialize()
correlate(SOURCE_FILE, TARGET_FILE)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这看起来像是可以从命令行运行的程序。假设您已经安装了
Python3
,则可以启动它,它将打印有关如何使用它的帮助消息。 compare.py.py 文件的目录。这是使用
cd
命令完成的)(这要求您首先导航到包含
在与
compare.py.py
的同一目录中,您可以简单地指定其名称:如果文件不在同一文件夹中,则应写入文件的完整路径。
关于术语的小评论:我不会将其称为上传将文件上传到脚本。您将所有内容都保留在计算机上,没有任何内容上传。您正在尝试将文件指定为命令行参数到python脚本。
This looks like a program that can be run from the command line. Assuming you already have
python3
installed, you can launch it asand it will print a help message on how to use it. (This requires you to first navigate to the directory that contains the
compare.py
file you showed us. That is done with thecd
command)If you place your two sound files in the same directory as the
compare.py
, you can simply specify their names:If the files are not in the same folder, you should write the full path of the files instead.
Minor Remark regarding Terminology: I wouldn't call it uploading the files to the script. You keep everything local on your computer, nothing is being uploaded. You are trying to specify the files as command line arguments to the python script.