change to cid
Browse files
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 '
|
| 72 |
-
|
| 73 |
-
if not
|
| 74 |
-
return jsonify({"error": "No
|
|
|
|
|
|
|
| 75 |
response = requests.get(file_url)
|
| 76 |
if response.status_code != 200:
|
| 77 |
-
return jsonify({"error": "Failed to download voice file from
|
| 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:
|