Update app.py
Browse files
app.py
CHANGED
@@ -57,7 +57,7 @@ class AnimationConfig:
|
|
57 |
self.camera_d = 10.
|
58 |
self.z_near = 5.
|
59 |
self.z_far = 15.
|
60 |
-
self.device = '
|
61 |
|
62 |
# Define the blueprint
|
63 |
SWAGGER_URL="/swagger"
|
@@ -193,20 +193,8 @@ def translate_text(text_prompt, target_language):
|
|
193 |
)
|
194 |
return response
|
195 |
|
196 |
-
async def clone_and_generate(user_voice_path, text_prompt, TEMP_DIR):
|
197 |
-
set_api_key("87792fce164425fbe1204e9fd1fe25cd")
|
198 |
-
voice = clone(name="User Cloned Voice", files=[user_voice_path])
|
199 |
-
audio = generate(text=text_prompt, voice=voice, model="eleven_multilingual_v2")
|
200 |
-
|
201 |
-
with tempfile.NamedTemporaryFile(suffix=".mp3", prefix="cloned_audio_", dir=TEMP_DIR.name, delete=False) as temp_file:
|
202 |
-
driven_audio_path = temp_file.name
|
203 |
-
elevenlabs.save(audio, driven_audio_path)
|
204 |
-
|
205 |
-
print('driven_audio_path',driven_audio_path)
|
206 |
-
return driven_audio_path
|
207 |
-
|
208 |
@app.route("/run", methods=['POST'])
|
209 |
-
|
210 |
global TEMP_DIR
|
211 |
TEMP_DIR = create_temp_dir()
|
212 |
if request.method == 'POST':
|
@@ -259,14 +247,17 @@ async def generate_video():
|
|
259 |
user_voice.save(user_voice_path)
|
260 |
print('user_voice_path',user_voice_path)
|
261 |
|
262 |
-
|
263 |
-
|
264 |
-
|
265 |
-
# files = [user_voice_path] )
|
266 |
|
267 |
-
|
268 |
-
|
269 |
-
|
|
|
|
|
|
|
|
|
270 |
# elevenlabs.save(audio, driven_audio_path)
|
271 |
|
272 |
save_dir = tempfile.mkdtemp(dir=TEMP_DIR.name)
|
|
|
57 |
self.camera_d = 10.
|
58 |
self.z_near = 5.
|
59 |
self.z_far = 15.
|
60 |
+
self.device = 'cpu'
|
61 |
|
62 |
# Define the blueprint
|
63 |
SWAGGER_URL="/swagger"
|
|
|
193 |
)
|
194 |
return response
|
195 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
196 |
@app.route("/run", methods=['POST'])
|
197 |
+
def generate_video():
|
198 |
global TEMP_DIR
|
199 |
TEMP_DIR = create_temp_dir()
|
200 |
if request.method == 'POST':
|
|
|
247 |
user_voice.save(user_voice_path)
|
248 |
print('user_voice_path',user_voice_path)
|
249 |
|
250 |
+
set_api_key("87792fce164425fbe1204e9fd1fe25cd")
|
251 |
+
voice = clone(name = "User Cloned Voice",
|
252 |
+
files = [user_voice_path] )
|
|
|
253 |
|
254 |
+
audio = generate(text = text_prompt, voice = voice, model = "eleven_multilingual_v2",stream=True, latency=2)
|
255 |
+
with tempfile.NamedTemporaryFile(suffix=".mp3", prefix="cloned_audio_",dir=TEMP_DIR.name, delete=False) as temp_file:
|
256 |
+
for chunk in audio:
|
257 |
+
temp_file.write(chunk)
|
258 |
+
driven_audio_path = temp_file.name
|
259 |
+
print('driven_audio_path',driven_audio_path)
|
260 |
+
|
261 |
# elevenlabs.save(audio, driven_audio_path)
|
262 |
|
263 |
save_dir = tempfile.mkdtemp(dir=TEMP_DIR.name)
|