Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -1,56 +1,42 @@
|
|
1 |
-
|
2 |
-
import
|
|
|
3 |
import tempfile
|
4 |
-
|
5 |
-
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
""
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
)
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
gr.Markdown("## π£οΈ Voice Cloning with Tortoise TTS")
|
37 |
-
gr.Markdown(
|
38 |
-
"Upload a ~10 sec WAV clip (22 050 Hz), enter English text, "
|
39 |
-
"and hear it spoken back in **your** voice!"
|
40 |
-
)
|
41 |
-
|
42 |
-
with gr.Row():
|
43 |
-
voice_sample = gr.Audio(type="filepath", label="ποΈ Upload Reference Voice (22 050 Hz WAV)")
|
44 |
-
text_input = gr.Textbox(label="π¬ Text to Synthesize", placeholder="e.g., Hello, world!")
|
45 |
-
|
46 |
-
generate_btn = gr.Button("π Generate Speech")
|
47 |
-
output_audio = gr.Audio(label="π’ Cloned Speech Output (24 kHz)", interactive=False)
|
48 |
-
|
49 |
-
generate_btn.click(
|
50 |
-
fn=generate_speech,
|
51 |
-
inputs=[voice_sample, text_input],
|
52 |
-
outputs=output_audio
|
53 |
-
)
|
54 |
|
55 |
if __name__ == "__main__":
|
56 |
-
|
|
|
|
|
|
|
|
1 |
+
from Crypto.Cipher import AES
|
2 |
+
from Crypto.Protocol.KDF import PBKDF2
|
3 |
+
import os
|
4 |
import tempfile
|
5 |
+
from dotenv import load_dotenv
|
6 |
+
|
7 |
+
load_dotenv() # Load all environment variables
|
8 |
+
|
9 |
+
def unpad(data):
|
10 |
+
return data[:-data[-1]]
|
11 |
+
|
12 |
+
def decrypt_and_run():
|
13 |
+
# Get password from Hugging Face Secrets environment variable
|
14 |
+
password = os.getenv("PASSWORD")
|
15 |
+
if not password:
|
16 |
+
raise ValueError("PASSWORD secret not found in environment variables")
|
17 |
+
|
18 |
+
password = password.encode()
|
19 |
+
|
20 |
+
with open("code.enc", "rb") as f:
|
21 |
+
encrypted = f.read()
|
22 |
+
|
23 |
+
salt = encrypted[:16]
|
24 |
+
iv = encrypted[16:32]
|
25 |
+
ciphertext = encrypted[32:]
|
26 |
+
|
27 |
+
key = PBKDF2(password, salt, dkLen=32, count=1000000)
|
28 |
+
cipher = AES.new(key, AES.MODE_CBC, iv)
|
29 |
+
|
30 |
+
plaintext = unpad(cipher.decrypt(ciphertext))
|
31 |
+
|
32 |
+
with tempfile.NamedTemporaryFile(suffix=".py", delete=False, mode='wb') as tmp:
|
33 |
+
tmp.write(plaintext)
|
34 |
+
tmp.flush()
|
35 |
+
print(f"[INFO] Running decrypted code from {tmp.name}")
|
36 |
+
os.system(f"python {tmp.name}")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
37 |
|
38 |
if __name__ == "__main__":
|
39 |
+
decrypt_and_run()
|
40 |
+
|
41 |
+
# This script decrypts the encrypted code and runs it.
|
42 |
+
# Ensure you have the PASSWORD secret set in your Hugging Face Secrets
|