query_subtitle.py 953 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. import json
  2. import requests
  3. import sys
  4. def query(file_json_name,id):
  5. url = "https://openspeech.bytedance.com/api/v1/auc/query"
  6. data = {
  7. "appid": "appid-9344610069",
  8. "token": "token-jGlG-1bU93gdrnLUqOQd44Y474k4J3KC",
  9. "cluster": "volc_auc_common",
  10. "id": f"{id}"
  11. }
  12. headers = {
  13. "Content-Type": "application/json",
  14. "Authorization": "Authorization-Bearer;jGlG-1bU93gdrnLUqOQd44Y474k4J3KC"}
  15. response = requests.post(url, json=data, headers=headers)
  16. with open(f"subtitle/{file_json_name}","w") as f:
  17. f.write(response.text)
  18. if __name__ == '__main__':
  19. if len(sys.argv) > 1:
  20. json_file_path = sys.argv[1]
  21. with open(json_file_path,"r") as file:
  22. data=json.loads(file.read())
  23. for x in data:
  24. file_json_name = x["fileName"].replace("mp3","json")
  25. query(file_json_name,x["submitId"])
  26. print(f"{file_json_name} save success!!!")
  27. else:
  28. print("没有传递参数!")