Spaces:
Sleeping
Sleeping
Upload infertest.py
Browse files- infertest.py +7 -2
infertest.py
CHANGED
|
@@ -14,7 +14,8 @@ from scipy.io import wavfile
|
|
| 14 |
from datetime import datetime
|
| 15 |
from urllib.parse import urlparse
|
| 16 |
from mega import Mega
|
| 17 |
-
from flask import Flask, request, jsonify
|
|
|
|
| 18 |
app = Flask(__name__)
|
| 19 |
|
| 20 |
now_dir = os.getcwd()
|
|
@@ -109,7 +110,11 @@ def api_convert_voice():
|
|
| 109 |
|
| 110 |
output_path = convert_voice(spk_id, input_audio_path, voice_transform)
|
| 111 |
print(output_path)
|
| 112 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 113 |
|
| 114 |
|
| 115 |
def convert_voice(spk_id, input_audio_path, voice_transform):
|
|
|
|
| 14 |
from datetime import datetime
|
| 15 |
from urllib.parse import urlparse
|
| 16 |
from mega import Mega
|
| 17 |
+
from flask import Flask, request, jsonify, send_file
|
| 18 |
+
import os
|
| 19 |
app = Flask(__name__)
|
| 20 |
|
| 21 |
now_dir = os.getcwd()
|
|
|
|
| 110 |
|
| 111 |
output_path = convert_voice(spk_id, input_audio_path, voice_transform)
|
| 112 |
print(output_path)
|
| 113 |
+
if os.path.exists(output_audio_path):
|
| 114 |
+
return send_file(output_audio_path, as_attachment=True)
|
| 115 |
+
else:
|
| 116 |
+
return jsonify({"error": "File not found."}), 404
|
| 117 |
+
|
| 118 |
|
| 119 |
|
| 120 |
def convert_voice(spk_id, input_audio_path, voice_transform):
|