matdmiller commited on
Commit
26d6d8d
·
1 Parent(s): c586121
Files changed (2) hide show
  1. app.ipynb +51 -25
  2. app.py +5 -5
app.ipynb CHANGED
@@ -2,7 +2,7 @@
2
  "cells": [
3
  {
4
  "cell_type": "code",
5
- "execution_count": null,
6
  "id": "3bedf0dc-8d8e-4ede-a9e6-b8f35136aa00",
7
  "metadata": {},
8
  "outputs": [],
@@ -12,10 +12,19 @@
12
  },
13
  {
14
  "cell_type": "code",
15
- "execution_count": null,
16
  "id": "667802a7-0f36-4136-a381-e66210b20462",
17
  "metadata": {},
18
- "outputs": [],
 
 
 
 
 
 
 
 
 
19
  "source": [
20
  "#| export\n",
21
  "#tts_openai_secrets.py content:\n",
@@ -44,7 +53,7 @@
44
  },
45
  {
46
  "cell_type": "code",
47
- "execution_count": null,
48
  "id": "4d9863fc-969e-409b-8e20-b9c3cd2cc3e7",
49
  "metadata": {},
50
  "outputs": [],
@@ -58,7 +67,7 @@
58
  },
59
  {
60
  "cell_type": "code",
61
- "execution_count": null,
62
  "id": "4f486d3a",
63
  "metadata": {},
64
  "outputs": [],
@@ -81,10 +90,18 @@
81
  },
82
  {
83
  "cell_type": "code",
84
- "execution_count": null,
85
  "id": "0ffd33b4-cb9b-4c01-bff6-4c3102854ab6",
86
  "metadata": {},
87
- "outputs": [],
 
 
 
 
 
 
 
 
88
  "source": [
89
  "#| export\n",
90
  "try:\n",
@@ -96,7 +113,7 @@
96
  },
97
  {
98
  "cell_type": "code",
99
- "execution_count": null,
100
  "id": "2ddbca5d-4b04-43ab-afaf-430802980e78",
101
  "metadata": {},
102
  "outputs": [],
@@ -107,7 +124,7 @@
107
  },
108
  {
109
  "cell_type": "code",
110
- "execution_count": null,
111
  "id": "8eb7e7d5-7121-4762-b8d1-e5a9539e2b36",
112
  "metadata": {},
113
  "outputs": [],
@@ -118,7 +135,7 @@
118
  },
119
  {
120
  "cell_type": "code",
121
- "execution_count": null,
122
  "id": "52d373be-3a79-412e-8ca2-92bb443fa52d",
123
  "metadata": {},
124
  "outputs": [],
@@ -130,7 +147,7 @@
130
  },
131
  {
132
  "cell_type": "code",
133
- "execution_count": null,
134
  "id": "24674094-4d47-4e48-b591-55faabcff8df",
135
  "metadata": {},
136
  "outputs": [],
@@ -171,7 +188,7 @@
171
  },
172
  {
173
  "cell_type": "code",
174
- "execution_count": null,
175
  "id": "e6224ae5-3792-42b2-8392-3abd42998a50",
176
  "metadata": {},
177
  "outputs": [],
@@ -209,7 +226,7 @@
209
  },
210
  {
211
  "cell_type": "code",
212
- "execution_count": null,
213
  "id": "4691703d-ed0f-4481-8006-b2906289b780",
214
  "metadata": {},
215
  "outputs": [],
@@ -229,13 +246,13 @@
229
  },
230
  {
231
  "cell_type": "code",
232
- "execution_count": null,
233
  "id": "e34bb4aa-698c-4452-8cda-bd02b38f7122",
234
  "metadata": {},
235
  "outputs": [],
236
  "source": [
237
  "#| export\n",
238
- "def create_speech2(input_text, model='tts-1', voice='alloy', progress=gr.Progress(),profile: gr.OAuthProfile=None, **kwargs):\n",
239
  " assert authorized(profile) is not None,'Unauthorized M'\n",
240
  " start = datetime.now()\n",
241
  " # Split the input text into chunks\n",
@@ -271,13 +288,13 @@
271
  },
272
  {
273
  "cell_type": "code",
274
- "execution_count": null,
275
  "id": "5388e860",
276
  "metadata": {},
277
  "outputs": [],
278
  "source": [
279
  "#| export\n",
280
- "def create_speech(input_text, model='tts-1', voice='alloy', progress=gr.Progress(), profile: gr.OAuthProfile=None):\n",
281
  " assert authorized(profile) is not None,'Unauthorized M'\n",
282
  " # Split the input text into chunks\n",
283
  " chunks = split_text(input_text)\n",
@@ -322,7 +339,7 @@
322
  },
323
  {
324
  "cell_type": "code",
325
- "execution_count": null,
326
  "id": "236dd8d3-4364-4731-af93-7dcdec6f18a1",
327
  "metadata": {},
328
  "outputs": [],
@@ -334,7 +351,7 @@
334
  },
335
  {
336
  "cell_type": "code",
337
- "execution_count": null,
338
  "id": "0523a158-ee07-48b3-9350-ee39d4deee7f",
339
  "metadata": {},
340
  "outputs": [],
@@ -351,7 +368,7 @@
351
  },
352
  {
353
  "cell_type": "code",
354
- "execution_count": null,
355
  "id": "b5b29507-92bc-453d-bcc5-6402c17e9a0d",
356
  "metadata": {},
357
  "outputs": [],
@@ -366,16 +383,25 @@
366
  },
367
  {
368
  "cell_type": "code",
369
- "execution_count": null,
370
  "id": "e4fb3159-579b-4271-bc96-4cd1e2816eca",
371
  "metadata": {},
372
- "outputs": [],
 
 
 
 
 
 
 
 
 
373
  "source": [
374
  "#| export\n",
375
  "with gr.Blocks(title='OpenAI TTS', head='OpenAI TTS') as app:\n",
376
  " gr.Markdown(\"# OpenAI TTS\")\n",
377
  " gr.Markdown(\"\"\"Start typing below and then click **Go** to create the speech from your text. The current limit is 4,000 characters. \n",
378
- "For requests longer than 4,000 chars they will be broken into chunks of 4,000 or less chars automatically. [Spaces Link](https://huggingface.co/spaces/matdmiller/tts-openai)\"\"\")\n",
379
  " with gr.Row():\n",
380
  " input_text = gr.Textbox(max_lines=100, label=\"Enter text here\")\n",
381
  " with gr.Row():\n",
@@ -400,7 +426,7 @@
400
  },
401
  {
402
  "cell_type": "code",
403
- "execution_count": null,
404
  "id": "a00648a1-891b-470b-9959-f5d502055713",
405
  "metadata": {},
406
  "outputs": [],
@@ -463,7 +489,7 @@
463
  },
464
  {
465
  "cell_type": "code",
466
- "execution_count": 13,
467
  "id": "0420310d-930b-4904-8bd4-3458ad8bdbd3",
468
  "metadata": {},
469
  "outputs": [],
 
2
  "cells": [
3
  {
4
  "cell_type": "code",
5
+ "execution_count": 15,
6
  "id": "3bedf0dc-8d8e-4ede-a9e6-b8f35136aa00",
7
  "metadata": {},
8
  "outputs": [],
 
12
  },
13
  {
14
  "cell_type": "code",
15
+ "execution_count": 16,
16
  "id": "667802a7-0f36-4136-a381-e66210b20462",
17
  "metadata": {},
18
+ "outputs": [
19
+ {
20
+ "name": "stdout",
21
+ "output_type": "stream",
22
+ "text": [
23
+ "OPENAI_API_KEY environment variable was found.\n",
24
+ "GRADIO_PASSWORD environment variable was found.\n"
25
+ ]
26
+ }
27
+ ],
28
  "source": [
29
  "#| export\n",
30
  "#tts_openai_secrets.py content:\n",
 
53
  },
54
  {
55
  "cell_type": "code",
56
+ "execution_count": 17,
57
  "id": "4d9863fc-969e-409b-8e20-b9c3cd2cc3e7",
58
  "metadata": {},
59
  "outputs": [],
 
67
  },
68
  {
69
  "cell_type": "code",
70
+ "execution_count": 18,
71
  "id": "4f486d3a",
72
  "metadata": {},
73
  "outputs": [],
 
90
  },
91
  {
92
  "cell_type": "code",
93
+ "execution_count": 19,
94
  "id": "0ffd33b4-cb9b-4c01-bff6-4c3102854ab6",
95
  "metadata": {},
96
+ "outputs": [
97
+ {
98
+ "name": "stdout",
99
+ "output_type": "stream",
100
+ "text": [
101
+ "successfully got tts model list: ['tts-1-hd-1106', 'tts-1-hd', 'tts-1', 'tts-1-1106']\n"
102
+ ]
103
+ }
104
+ ],
105
  "source": [
106
  "#| export\n",
107
  "try:\n",
 
113
  },
114
  {
115
  "cell_type": "code",
116
+ "execution_count": 20,
117
  "id": "2ddbca5d-4b04-43ab-afaf-430802980e78",
118
  "metadata": {},
119
  "outputs": [],
 
124
  },
125
  {
126
  "cell_type": "code",
127
+ "execution_count": 21,
128
  "id": "8eb7e7d5-7121-4762-b8d1-e5a9539e2b36",
129
  "metadata": {},
130
  "outputs": [],
 
135
  },
136
  {
137
  "cell_type": "code",
138
+ "execution_count": 22,
139
  "id": "52d373be-3a79-412e-8ca2-92bb443fa52d",
140
  "metadata": {},
141
  "outputs": [],
 
147
  },
148
  {
149
  "cell_type": "code",
150
+ "execution_count": 23,
151
  "id": "24674094-4d47-4e48-b591-55faabcff8df",
152
  "metadata": {},
153
  "outputs": [],
 
188
  },
189
  {
190
  "cell_type": "code",
191
+ "execution_count": 24,
192
  "id": "e6224ae5-3792-42b2-8392-3abd42998a50",
193
  "metadata": {},
194
  "outputs": [],
 
226
  },
227
  {
228
  "cell_type": "code",
229
+ "execution_count": 25,
230
  "id": "4691703d-ed0f-4481-8006-b2906289b780",
231
  "metadata": {},
232
  "outputs": [],
 
246
  },
247
  {
248
  "cell_type": "code",
249
+ "execution_count": 26,
250
  "id": "e34bb4aa-698c-4452-8cda-bd02b38f7122",
251
  "metadata": {},
252
  "outputs": [],
253
  "source": [
254
  "#| export\n",
255
+ "def create_speech2(input_text, model='tts-1', voice='alloy', profile: gr.OAuthProfile|None, progress=gr.Progress(), **kwargs):\n",
256
  " assert authorized(profile) is not None,'Unauthorized M'\n",
257
  " start = datetime.now()\n",
258
  " # Split the input text into chunks\n",
 
288
  },
289
  {
290
  "cell_type": "code",
291
+ "execution_count": 33,
292
  "id": "5388e860",
293
  "metadata": {},
294
  "outputs": [],
295
  "source": [
296
  "#| export\n",
297
+ "def create_speech(input_text, model='tts-1', voice='alloy', profile: gr.OAuthProfile|None, progress=gr.Progress()):\n",
298
  " assert authorized(profile) is not None,'Unauthorized M'\n",
299
  " # Split the input text into chunks\n",
300
  " chunks = split_text(input_text)\n",
 
339
  },
340
  {
341
  "cell_type": "code",
342
+ "execution_count": 28,
343
  "id": "236dd8d3-4364-4731-af93-7dcdec6f18a1",
344
  "metadata": {},
345
  "outputs": [],
 
351
  },
352
  {
353
  "cell_type": "code",
354
+ "execution_count": 29,
355
  "id": "0523a158-ee07-48b3-9350-ee39d4deee7f",
356
  "metadata": {},
357
  "outputs": [],
 
368
  },
369
  {
370
  "cell_type": "code",
371
+ "execution_count": 30,
372
  "id": "b5b29507-92bc-453d-bcc5-6402c17e9a0d",
373
  "metadata": {},
374
  "outputs": [],
 
383
  },
384
  {
385
  "cell_type": "code",
386
+ "execution_count": 31,
387
  "id": "e4fb3159-579b-4271-bc96-4cd1e2816eca",
388
  "metadata": {},
389
+ "outputs": [
390
+ {
391
+ "name": "stderr",
392
+ "output_type": "stream",
393
+ "text": [
394
+ "/Users/mathewmiller/anaconda3/envs/gradio1/lib/python3.11/site-packages/gradio/oauth.py:138: UserWarning: Gradio does not support OAuth features outside of a Space environment. To help you debug your app locally, the login and logout buttons are mocked with your profile. To make it work, your machine must be logged in to Huggingface.\n",
395
+ " warnings.warn(\n"
396
+ ]
397
+ }
398
+ ],
399
  "source": [
400
  "#| export\n",
401
  "with gr.Blocks(title='OpenAI TTS', head='OpenAI TTS') as app:\n",
402
  " gr.Markdown(\"# OpenAI TTS\")\n",
403
  " gr.Markdown(\"\"\"Start typing below and then click **Go** to create the speech from your text. The current limit is 4,000 characters. \n",
404
+ "For requests longer than 4,000 chars they will be broken into chunks of 4,000 or less chars automatically. [Spaces Link](https://matdmiller-tts-openai.hf.space/)\"\"\")\n",
405
  " with gr.Row():\n",
406
  " input_text = gr.Textbox(max_lines=100, label=\"Enter text here\")\n",
407
  " with gr.Row():\n",
 
426
  },
427
  {
428
  "cell_type": "code",
429
+ "execution_count": 32,
430
  "id": "a00648a1-891b-470b-9959-f5d502055713",
431
  "metadata": {},
432
  "outputs": [],
 
489
  },
490
  {
491
  "cell_type": "code",
492
+ "execution_count": 14,
493
  "id": "0420310d-930b-4904-8bd4-3458ad8bdbd3",
494
  "metadata": {},
495
  "outputs": [],
app.py CHANGED
@@ -2,8 +2,8 @@
2
 
3
  # %% auto 0
4
  __all__ = ['secret_import_failed', 'tts_voices', 'clean_text_prompt', 'OPENAI_CLIENT_TTS_THREADS', 'launch_kwargs',
5
- 'queue_kwargs', 'split_text', 'concatenate_mp3', 'create_speech_openai', 'create_speech2', 'create_speech',
6
- 'get_input_text_len', 'get_generation_cost', 'authorized']
7
 
8
  # %% app.ipynb 1
9
  #tts_openai_secrets.py content:
@@ -138,7 +138,7 @@ def create_speech_openai(chunk_idx, input, model='tts-1', voice='alloy', speed=1
138
  return chunk_idx, response.content
139
 
140
  # %% app.ipynb 11
141
- def create_speech2(input_text, model='tts-1', voice='alloy', progress=gr.Progress(),profile: gr.OAuthProfile=None, **kwargs):
142
  assert authorized(profile) is not None,'Unauthorized M'
143
  start = datetime.now()
144
  # Split the input text into chunks
@@ -173,7 +173,7 @@ def create_speech2(input_text, model='tts-1', voice='alloy', progress=gr.Progres
173
 
174
 
175
  # %% app.ipynb 12
176
- def create_speech(input_text, model='tts-1', voice='alloy', progress=gr.Progress(), profile: gr.OAuthProfile=None):
177
  assert authorized(profile) is not None,'Unauthorized M'
178
  # Split the input text into chunks
179
  chunks = split_text(input_text)
@@ -240,7 +240,7 @@ def authorized(profile: gr.OAuthProfile) -> str:
240
  with gr.Blocks(title='OpenAI TTS', head='OpenAI TTS') as app:
241
  gr.Markdown("# OpenAI TTS")
242
  gr.Markdown("""Start typing below and then click **Go** to create the speech from your text. The current limit is 4,000 characters.
243
- For requests longer than 4,000 chars they will be broken into chunks of 4,000 or less chars automatically. [Spaces Link](https://huggingface.co/spaces/matdmiller/tts-openai)""")
244
  with gr.Row():
245
  input_text = gr.Textbox(max_lines=100, label="Enter text here")
246
  with gr.Row():
 
2
 
3
  # %% auto 0
4
  __all__ = ['secret_import_failed', 'tts_voices', 'clean_text_prompt', 'OPENAI_CLIENT_TTS_THREADS', 'launch_kwargs',
5
+ 'queue_kwargs', 'split_text', 'concatenate_mp3', 'create_speech_openai', 'get_input_text_len',
6
+ 'get_generation_cost', 'authorized']
7
 
8
  # %% app.ipynb 1
9
  #tts_openai_secrets.py content:
 
138
  return chunk_idx, response.content
139
 
140
  # %% app.ipynb 11
141
+ def create_speech2(input_text, model='tts-1', voice='alloy', profile: gr.OAuthProfile|None, progress=gr.Progress(), **kwargs):
142
  assert authorized(profile) is not None,'Unauthorized M'
143
  start = datetime.now()
144
  # Split the input text into chunks
 
173
 
174
 
175
  # %% app.ipynb 12
176
+ def create_speech(input_text, model='tts-1', voice='alloy', profile: gr.OAuthProfile|None, progress=gr.Progress()):
177
  assert authorized(profile) is not None,'Unauthorized M'
178
  # Split the input text into chunks
179
  chunks = split_text(input_text)
 
240
  with gr.Blocks(title='OpenAI TTS', head='OpenAI TTS') as app:
241
  gr.Markdown("# OpenAI TTS")
242
  gr.Markdown("""Start typing below and then click **Go** to create the speech from your text. The current limit is 4,000 characters.
243
+ For requests longer than 4,000 chars they will be broken into chunks of 4,000 or less chars automatically. [Spaces Link](https://matdmiller-tts-openai.hf.space/)""")
244
  with gr.Row():
245
  input_text = gr.Textbox(max_lines=100, label="Enter text here")
246
  with gr.Row():