Spaces:
Running
Running
Commit
·
40fb28c
1
Parent(s):
1528d47
Update app.py
Browse files
app.py
CHANGED
@@ -19,7 +19,7 @@ counter = 0
|
|
19 |
# dict to limit max numer of usages per user without API key
|
20 |
# clears up on demo restart, but thats ok for now
|
21 |
users: Dict[str, int] = {}
|
22 |
-
FREE_TIER =
|
23 |
|
24 |
|
25 |
def get_ip(request: gr.Request) -> str:
|
@@ -105,13 +105,10 @@ def main():
|
|
105 |
with gr.Row():
|
106 |
result_audio = gr.Audio()
|
107 |
|
108 |
-
def voice_conversion(src_from_mic_, src_from_file_, tgt_from_file_, api_key_
|
109 |
"""
|
110 |
helper function which checks where source come from
|
111 |
"""
|
112 |
-
if api_key_ is None and api_secret_ is None and request_ is None:
|
113 |
-
logging.warning("Old signature request")
|
114 |
-
return
|
115 |
src_ = None
|
116 |
if src_from_mic_:
|
117 |
src_ = src_from_mic_
|
@@ -120,7 +117,6 @@ def main():
|
|
120 |
tgt_ = tgt_from_file_
|
121 |
if not src_ or not tgt_:
|
122 |
logging.warning("source or target are not provided")
|
123 |
-
gr.Warning("Source or target audio are not provided")
|
124 |
return
|
125 |
global counter, users
|
126 |
ip_ = get_ip(request_)
|
@@ -131,7 +127,6 @@ def main():
|
|
131 |
api_key_ = os.environ["api_key"]
|
132 |
api_secret_ = os.environ["api_secret"]
|
133 |
if free_tier and past_requests_ >= FREE_TIER:
|
134 |
-
gr.Warning("Free tier exceeded, please reach out to get your API key")
|
135 |
logging.info(f"Free tier exceeded for {ip_}")
|
136 |
return
|
137 |
logging.info(f"Total number of requests: {counter}. {past_requests_} for {ip_}")
|
|
|
19 |
# dict to limit max numer of usages per user without API key
|
20 |
# clears up on demo restart, but thats ok for now
|
21 |
users: Dict[str, int] = {}
|
22 |
+
FREE_TIER = 5
|
23 |
|
24 |
|
25 |
def get_ip(request: gr.Request) -> str:
|
|
|
105 |
with gr.Row():
|
106 |
result_audio = gr.Audio()
|
107 |
|
108 |
+
def voice_conversion(src_from_mic_, src_from_file_, tgt_from_file_, api_key_, api_secret_, request_: gr.Request):
|
109 |
"""
|
110 |
helper function which checks where source come from
|
111 |
"""
|
|
|
|
|
|
|
112 |
src_ = None
|
113 |
if src_from_mic_:
|
114 |
src_ = src_from_mic_
|
|
|
117 |
tgt_ = tgt_from_file_
|
118 |
if not src_ or not tgt_:
|
119 |
logging.warning("source or target are not provided")
|
|
|
120 |
return
|
121 |
global counter, users
|
122 |
ip_ = get_ip(request_)
|
|
|
127 |
api_key_ = os.environ["api_key"]
|
128 |
api_secret_ = os.environ["api_secret"]
|
129 |
if free_tier and past_requests_ >= FREE_TIER:
|
|
|
130 |
logging.info(f"Free tier exceeded for {ip_}")
|
131 |
return
|
132 |
logging.info(f"Total number of requests: {counter}. {past_requests_} for {ip_}")
|