Chloe commited on
Commit
5e4f596
·
1 Parent(s): db5e913

change to cid

Browse files
Files changed (1) hide show
  1. app.py +7 -5
app.py CHANGED
@@ -68,13 +68,15 @@ def voice_transfer():
68
  # voice_file_path = os.path.join(temp_dir, file.filename)
69
  # file.save(voice_file_path)
70
  # 2. Check for file URL
71
- if 'voice_file' in request.form:
72
- file_url = request.form.get('voice_file')
73
- if not file_url:
74
- return jsonify({"error": "No voice_file (URL) provided"}), 400
 
 
75
  response = requests.get(file_url)
76
  if response.status_code != 200:
77
- return jsonify({"error": "Failed to download voice file from URL"}), 400
78
  # Save as webm first
79
  webm_path = os.path.join(temp_dir, "input.webm")
80
  with open(webm_path, "wb") as f:
 
68
  # voice_file_path = os.path.join(temp_dir, file.filename)
69
  # file.save(voice_file_path)
70
  # 2. Check for file URL
71
+ if 'cid' in request.form:
72
+ cid = request.form.get('cid')
73
+ if not cid:
74
+ return jsonify({"error": "No cid (for voice file) provided"}), 400
75
+ # Construct the IPFS URL from the CID
76
+ file_url = f"http://ipfs.io/ipfs/{cid}"
77
  response = requests.get(file_url)
78
  if response.status_code != 200:
79
+ return jsonify({"error": "Failed to download voice file from IPFS"}), 400
80
  # Save as webm first
81
  webm_path = os.path.join(temp_dir, "input.webm")
82
  with open(webm_path, "wb") as f: