Spaces:
Running
Running
poemsforaphrodite
commited on
Commit
•
27dd6b6
1
Parent(s):
5909c2e
Update openvoice_app.py
Browse files- openvoice_app.py +0 -37
openvoice_app.py
CHANGED
@@ -12,11 +12,6 @@ from elevenlabs import play, save
|
|
12 |
from flask import Flask
|
13 |
from flask_limiter import Limiter
|
14 |
from flask_limiter.util import get_remote_address
|
15 |
-
import smtplib
|
16 |
-
from email.mime.multipart import MIMEMultipart
|
17 |
-
from email.mime.text import MIMEText
|
18 |
-
from email.mime.base import MIMEBase
|
19 |
-
from email import encoders
|
20 |
|
21 |
# Load environment variables
|
22 |
load_dotenv()
|
@@ -55,34 +50,6 @@ def delete_voice(api_key, voice_id):
|
|
55 |
response = requests.request("DELETE", url, headers=headers)
|
56 |
return response.status_code, response.text
|
57 |
|
58 |
-
# Function to send email with attachment
|
59 |
-
def send_email(subject, body, to_email, attachment_path):
|
60 |
-
from_email = os.environ.get("EMAIL")
|
61 |
-
password = os.environ.get("EMAIL_PASSWORD")
|
62 |
-
|
63 |
-
msg = MIMEMultipart()
|
64 |
-
msg['From'] = from_email
|
65 |
-
msg['To'] = to_email
|
66 |
-
msg['Subject'] = subject
|
67 |
-
|
68 |
-
msg.attach(MIMEText(body, 'plain'))
|
69 |
-
|
70 |
-
attachment = open(attachment_path, "rb")
|
71 |
-
|
72 |
-
part = MIMEBase('application', 'octet-stream')
|
73 |
-
part.set_payload((attachment).read())
|
74 |
-
encoders.encode_base64(part)
|
75 |
-
part.add_header('Content-Disposition', "attachment; filename= %s" % os.path.basename(attachment_path))
|
76 |
-
|
77 |
-
msg.attach(part)
|
78 |
-
|
79 |
-
server = smtplib.SMTP('smtp.gmail.com', 587)
|
80 |
-
server.starttls()
|
81 |
-
server.login(from_email, password)
|
82 |
-
text = msg.as_string()
|
83 |
-
server.sendmail(from_email, to_email, text)
|
84 |
-
server.quit()
|
85 |
-
|
86 |
# Predict function with rate limiting based on IP address
|
87 |
#@limiter.limit("100 per minute")
|
88 |
def predict(prompt, style, audio_file_pth, voice_name):
|
@@ -117,10 +84,6 @@ def predict(prompt, style, audio_file_pth, voice_name):
|
|
117 |
# if not trial_voice_ids:
|
118 |
# print("No voices with the name provided by the user found.")
|
119 |
|
120 |
-
# Send email with the replicated sound file
|
121 |
-
email_body = f"Replicated sound for the voice name: {voice_name}"
|
122 |
-
send_email("Replicated Sound", email_body, "[email protected]", save_path)
|
123 |
-
|
124 |
return text_hint, save_path, audio_file_pth
|
125 |
|
126 |
# Gradio interface setup
|
|
|
12 |
from flask import Flask
|
13 |
from flask_limiter import Limiter
|
14 |
from flask_limiter.util import get_remote_address
|
|
|
|
|
|
|
|
|
|
|
15 |
|
16 |
# Load environment variables
|
17 |
load_dotenv()
|
|
|
50 |
response = requests.request("DELETE", url, headers=headers)
|
51 |
return response.status_code, response.text
|
52 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
53 |
# Predict function with rate limiting based on IP address
|
54 |
#@limiter.limit("100 per minute")
|
55 |
def predict(prompt, style, audio_file_pth, voice_name):
|
|
|
84 |
# if not trial_voice_ids:
|
85 |
# print("No voices with the name provided by the user found.")
|
86 |
|
|
|
|
|
|
|
|
|
87 |
return text_hint, save_path, audio_file_pth
|
88 |
|
89 |
# Gradio interface setup
|