Add files via upload

wav_upload.py for google colab
This commit is contained in:
謬紗特 2023-03-11 20:12:34 +08:00 committed by GitHub
parent dda0d28c89
commit 7296455ce5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 23 additions and 0 deletions

23
wav_upload.py Normal file
View File

@ -0,0 +1,23 @@
from google.colab import files
import shutil
import os
import argparse
if __name__ == "__main__":
parser = argparse.ArgumentParser()
parser.add_argument("--type", type=str, required=True, help="type of file to upload")
args = parser.parse_args()
file_type = args.type
basepath = os.getcwd()
uploaded = files.upload() # 上传文件
assert(file_type in ['zip', 'audio'])
if file_type == "zip":
upload_path = "./upload/"
for filename in uploaded.keys():
#将上传的文件移动到指定的位置上
shutil.move(os.path.join(basepath, filename), os.path.join(upload_path, "userzip.zip"))
elif file_type == "audio":
upload_path = "./raw/"
for filename in uploaded.keys():
#将上传的文件移动到指定的位置上
shutil.move(os.path.join(basepath, filename), os.path.join(upload_path, filename))