Spaces:
Running
Running
matdmiller
commited on
Commit
·
990159e
1
Parent(s):
45b2ac8
added auth
Browse files
app.ipynb
CHANGED
@@ -30,17 +30,25 @@
|
|
30 |
"#tts_openai_secrets.py content:\n",
|
31 |
"#import os\n",
|
32 |
"#os.environ['OPENAI_API_KEY'] = 'sk-XXXXXXXXXXXXXXXXXXXXXX'\n",
|
|
|
|
|
33 |
"try:\n",
|
34 |
-
" import os\n",
|
35 |
" _ = os.environ['OPENAI_API_KEY']\n",
|
36 |
-
" print('OPENAI_API_KEY
|
37 |
"except:\n",
|
38 |
-
" print('OPENAI_API_KEY
|
39 |
-
"
|
40 |
-
"
|
41 |
-
"
|
42 |
-
"
|
43 |
-
"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
44 |
]
|
45 |
},
|
46 |
{
|
@@ -164,13 +172,55 @@
|
|
164 |
{
|
165 |
"cell_type": "code",
|
166 |
"execution_count": null,
|
167 |
-
"id": "
|
168 |
"metadata": {},
|
169 |
"outputs": [],
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
170 |
"source": [
|
171 |
"#| hide\n",
|
172 |
"#Notebook launch\n",
|
173 |
-
"app.launch()"
|
174 |
]
|
175 |
},
|
176 |
{
|
@@ -213,7 +263,7 @@
|
|
213 |
"#| export\n",
|
214 |
"#.py launch\n",
|
215 |
"if __name__ == \"__main__\":\n",
|
216 |
-
" app.launch()"
|
217 |
]
|
218 |
},
|
219 |
{
|
|
|
30 |
"#tts_openai_secrets.py content:\n",
|
31 |
"#import os\n",
|
32 |
"#os.environ['OPENAI_API_KEY'] = 'sk-XXXXXXXXXXXXXXXXXXXXXX'\n",
|
33 |
+
"import os\n",
|
34 |
+
"secret_import_failed = False\n",
|
35 |
"try:\n",
|
|
|
36 |
" _ = os.environ['OPENAI_API_KEY']\n",
|
37 |
+
" print('OPENAI_API_KEY environment variable was found.')\n",
|
38 |
"except:\n",
|
39 |
+
" print('OPENAI_API_KEY environment variable was not found.')\n",
|
40 |
+
" secret_import_failed = True\n",
|
41 |
+
"try:\n",
|
42 |
+
" GRADIO_PASSWORD = os.environ['GRADIO_PASSWORD']\n",
|
43 |
+
" print('GRADIO_PASSWORD environment variable was found.')\n",
|
44 |
+
"except:\n",
|
45 |
+
" print('GRADIO_PASSWORD environment variable was not found.')\n",
|
46 |
+
" secret_import_failed = True\n",
|
47 |
+
"\n",
|
48 |
+
"if secret_import_failed == True:\n",
|
49 |
+
" import tts_openai_secrets\n",
|
50 |
+
" GRADIO_PASSWORD = os.environ['GRADIO_PASSWORD']\n",
|
51 |
+
" print('import tts_openai_secrets succeeded')"
|
52 |
]
|
53 |
},
|
54 |
{
|
|
|
172 |
{
|
173 |
"cell_type": "code",
|
174 |
"execution_count": null,
|
175 |
+
"id": "a00648a1-891b-470b-9959-f5d502055713",
|
176 |
"metadata": {},
|
177 |
"outputs": [],
|
178 |
+
"source": [
|
179 |
+
"#| export\n",
|
180 |
+
"launch_kwargs = {'auth':('username',GRADIO_PASSWORD),\n",
|
181 |
+
" 'auth_message':'Please log in to Mat\\'s TTS App with username: username and password.'}"
|
182 |
+
]
|
183 |
+
},
|
184 |
+
{
|
185 |
+
"cell_type": "code",
|
186 |
+
"execution_count": null,
|
187 |
+
"id": "4b534fe7-4337-423e-846a-1bdb7cccc4ea",
|
188 |
+
"metadata": {},
|
189 |
+
"outputs": [
|
190 |
+
{
|
191 |
+
"name": "stdout",
|
192 |
+
"output_type": "stream",
|
193 |
+
"text": [
|
194 |
+
"Running on local URL: http://0.0.0.0:7860\n",
|
195 |
+
"\n",
|
196 |
+
"To create a public link, set `share=True` in `launch()`.\n"
|
197 |
+
]
|
198 |
+
},
|
199 |
+
{
|
200 |
+
"data": {
|
201 |
+
"text/html": [
|
202 |
+
"<div><iframe src=\"http://localhost:7860/\" width=\"100%\" height=\"500\" allow=\"autoplay; camera; microphone; clipboard-read; clipboard-write;\" frameborder=\"0\" allowfullscreen></iframe></div>"
|
203 |
+
],
|
204 |
+
"text/plain": [
|
205 |
+
"<IPython.core.display.HTML object>"
|
206 |
+
]
|
207 |
+
},
|
208 |
+
"metadata": {},
|
209 |
+
"output_type": "display_data"
|
210 |
+
},
|
211 |
+
{
|
212 |
+
"data": {
|
213 |
+
"text/plain": []
|
214 |
+
},
|
215 |
+
"execution_count": null,
|
216 |
+
"metadata": {},
|
217 |
+
"output_type": "execute_result"
|
218 |
+
}
|
219 |
+
],
|
220 |
"source": [
|
221 |
"#| hide\n",
|
222 |
"#Notebook launch\n",
|
223 |
+
"app.launch(**launch_kwargs)"
|
224 |
]
|
225 |
},
|
226 |
{
|
|
|
263 |
"#| export\n",
|
264 |
"#.py launch\n",
|
265 |
"if __name__ == \"__main__\":\n",
|
266 |
+
" app.launch(**launch_kwargs)"
|
267 |
]
|
268 |
},
|
269 |
{
|
app.py
CHANGED
@@ -1,23 +1,31 @@
|
|
1 |
# AUTOGENERATED! DO NOT EDIT! File to edit: app.ipynb.
|
2 |
|
3 |
# %% auto 0
|
4 |
-
__all__ = ['tts_voices', 'create_speech', 'get_input_text_len']
|
5 |
|
6 |
# %% app.ipynb 1
|
7 |
#tts_openai_secrets.py content:
|
8 |
#import os
|
9 |
#os.environ['OPENAI_API_KEY'] = 'sk-XXXXXXXXXXXXXXXXXXXXXX'
|
|
|
|
|
10 |
try:
|
11 |
-
import os
|
12 |
_ = os.environ['OPENAI_API_KEY']
|
13 |
-
print('OPENAI_API_KEY
|
14 |
except:
|
15 |
-
print('OPENAI_API_KEY
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
21 |
|
22 |
# %% app.ipynb 3
|
23 |
import gradio as gr
|
@@ -67,7 +75,11 @@ with gr.Blocks(title='OpenAI TTS', head='OpenAI TTS') as app:
|
|
67 |
clear_btn.click(fn=lambda: '', outputs=input_text)
|
68 |
|
69 |
|
70 |
-
# %% app.ipynb
|
|
|
|
|
|
|
|
|
71 |
#.py launch
|
72 |
if __name__ == "__main__":
|
73 |
-
app.launch()
|
|
|
1 |
# AUTOGENERATED! DO NOT EDIT! File to edit: app.ipynb.
|
2 |
|
3 |
# %% auto 0
|
4 |
+
__all__ = ['secret_import_failed', 'tts_voices', 'launch_kwargs', 'create_speech', 'get_input_text_len']
|
5 |
|
6 |
# %% app.ipynb 1
|
7 |
#tts_openai_secrets.py content:
|
8 |
#import os
|
9 |
#os.environ['OPENAI_API_KEY'] = 'sk-XXXXXXXXXXXXXXXXXXXXXX'
|
10 |
+
import os
|
11 |
+
secret_import_failed = False
|
12 |
try:
|
|
|
13 |
_ = os.environ['OPENAI_API_KEY']
|
14 |
+
print('OPENAI_API_KEY environment variable was found.')
|
15 |
except:
|
16 |
+
print('OPENAI_API_KEY environment variable was not found.')
|
17 |
+
secret_import_failed = True
|
18 |
+
try:
|
19 |
+
GRADIO_PASSWORD = os.environ['GRADIO_PASSWORD']
|
20 |
+
print('GRADIO_PASSWORD environment variable was found.')
|
21 |
+
except:
|
22 |
+
print('GRADIO_PASSWORD environment variable was not found.')
|
23 |
+
secret_import_failed = True
|
24 |
+
|
25 |
+
if secret_import_failed == True:
|
26 |
+
import tts_openai_secrets
|
27 |
+
GRADIO_PASSWORD = os.environ['GRADIO_PASSWORD']
|
28 |
+
print('import tts_openai_secrets succeeded')
|
29 |
|
30 |
# %% app.ipynb 3
|
31 |
import gradio as gr
|
|
|
75 |
clear_btn.click(fn=lambda: '', outputs=input_text)
|
76 |
|
77 |
|
78 |
+
# %% app.ipynb 9
|
79 |
+
launch_kwargs = {'auth':('username',GRADIO_PASSWORD),
|
80 |
+
'auth_message':'Please log in to Mat\'s TTS App with username: username and password.'}
|
81 |
+
|
82 |
+
# %% app.ipynb 11
|
83 |
#.py launch
|
84 |
if __name__ == "__main__":
|
85 |
+
app.launch(**launch_kwargs)
|