1234567891011121314151617181920212223242526272829303132333435363738394041424344 |
- import json
- import requests
- import sys
- def query(file_json_name,id):
- url = "https://openspeech.bytedance.com/api/v1/auc/query"
- data = {
- "appid": "appid-9344610069",
- "token": "token-jGlG-1bU93gdrnLUqOQd44Y474k4J3KC",
- "cluster": "volc_auc_common",
- "id": f"{id}"
- }
- headers = {
- "Content-Type": "application/json",
- "Authorization": "Authorization-Bearer;jGlG-1bU93gdrnLUqOQd44Y474k4J3KC"}
- response = requests.post(url, json=data, headers=headers)
- with open(f"subtitle/{file_json_name}","w") as f:
- f.write(response.text)
- if __name__ == '__main__':
- if len(sys.argv) > 1:
- json_file_path = sys.argv[1]
- with open(json_file_path,"r") as file:
- data=json.loads(file.read())
- for x in data:
- file_json_name = x["fileName"].replace("mp3","json")
- query(file_json_name,x["submitId"])
- print(f"{file_json_name} save success!!!")
- else:
- print("没有传递参数!")
-
|