Spaces:
Running
Running
poemsforaphrodite
commited on
Commit
•
e2aeb29
1
Parent(s):
cb989b0
Update openvoice_app.py
Browse files- openvoice_app.py +4 -13
openvoice_app.py
CHANGED
@@ -12,19 +12,11 @@ from dotenv import load_dotenv
|
|
12 |
from openai import OpenAI
|
13 |
from elevenlabs.client import ElevenLabs
|
14 |
from elevenlabs import play, save
|
15 |
-
|
16 |
-
from flask_limiter import Limiter
|
17 |
-
from flask_limiter.util import get_remote_address
|
18 |
|
19 |
# Load environment variables
|
20 |
load_dotenv()
|
21 |
|
22 |
-
# Initialize Flask app
|
23 |
-
app = Flask(__name__)
|
24 |
-
|
25 |
-
# Setup Limiter for rate limiting and quota management based on IP address
|
26 |
-
limiter = Limiter(get_remote_address, app=app, default_limits=["5 per minute"])
|
27 |
-
|
28 |
# Argument parsing
|
29 |
parser = argparse.ArgumentParser()
|
30 |
parser.add_argument("--share", action='store_true', default=False, help="make link public")
|
@@ -69,8 +61,7 @@ def send_email_with_file(recipient_email, file_path, subject, body):
|
|
69 |
print(f"An error occurred while sending email: {e}")
|
70 |
return False
|
71 |
|
72 |
-
# Predict function
|
73 |
-
@limiter.limit("100 per minute")
|
74 |
def predict(prompt, style, audio_file_pth, voice_name, customer_email):
|
75 |
text_hint = 'Your file will only be saved for 24 hours.\n'
|
76 |
if len(prompt) < 2:
|
@@ -108,7 +99,7 @@ with gr.Blocks(gr.themes.Glass()) as demo:
|
|
108 |
input_text_gr = gr.Textbox(
|
109 |
label="Create This",
|
110 |
info="One or two sentences at a time is better. Up to 200 text characters.",
|
111 |
-
value="
|
112 |
)
|
113 |
style_gr = gr.Dropdown(
|
114 |
label="Style",
|
@@ -148,4 +139,4 @@ footer {visibility: hidden}
|
|
148 |
audio .btn-container {display: none}
|
149 |
"""
|
150 |
|
151 |
-
demo.add_css(css)
|
|
|
12 |
from openai import OpenAI
|
13 |
from elevenlabs.client import ElevenLabs
|
14 |
from elevenlabs import play, save
|
15 |
+
import time
|
|
|
|
|
16 |
|
17 |
# Load environment variables
|
18 |
load_dotenv()
|
19 |
|
|
|
|
|
|
|
|
|
|
|
|
|
20 |
# Argument parsing
|
21 |
parser = argparse.ArgumentParser()
|
22 |
parser.add_argument("--share", action='store_true', default=False, help="make link public")
|
|
|
61 |
print(f"An error occurred while sending email: {e}")
|
62 |
return False
|
63 |
|
64 |
+
# Predict function
|
|
|
65 |
def predict(prompt, style, audio_file_pth, voice_name, customer_email):
|
66 |
text_hint = 'Your file will only be saved for 24 hours.\n'
|
67 |
if len(prompt) < 2:
|
|
|
99 |
input_text_gr = gr.Textbox(
|
100 |
label="Create This",
|
101 |
info="One or two sentences at a time is better. Up to 200 text characters.",
|
102 |
+
value="He hoped there would be stew for dinner, turnips and carrots and bruised potatoes and fat mutton pieces to be ladled out in thick, peppered, flour-fattened sauce.",
|
103 |
)
|
104 |
style_gr = gr.Dropdown(
|
105 |
label="Style",
|
|
|
139 |
audio .btn-container {display: none}
|
140 |
"""
|
141 |
|
142 |
+
demo.add_css(css)
|