Update app.py
Browse files
app.py
CHANGED
@@ -11,10 +11,11 @@ def pad_buffer(audio):
|
|
11 |
audio = audio + b'\0' * (element_size - (buffer_size % element_size))
|
12 |
return audio
|
13 |
|
14 |
-
def generate_voice(text, voice_name
|
|
|
15 |
try:
|
16 |
audio = generate(
|
17 |
-
text[:250],
|
18 |
voice=voice_name,
|
19 |
model=model_name
|
20 |
)
|
@@ -22,37 +23,9 @@ def generate_voice(text, voice_name, model_name):
|
|
22 |
except UnauthenticatedRateLimitError as e:
|
23 |
raise gr.Error("Thanks for trying out ElevenLabs TTS! You've reached the free tier limit. Please provide an API key to continue.")
|
24 |
except Exception as e:
|
25 |
-
raise gr.Error(e)
|
26 |
-
|
27 |
-
|
28 |
-
badges = """
|
29 |
-
<div style="display: flex">
|
30 |
-
<span style="margin-right: 5px">
|
31 |
-
|
32 |
-
[  ](https://github.com/elevenlabs/elevenlabs-python)
|
33 |
-
|
34 |
-
</span>
|
35 |
-
<span style="margin-right: 5px">
|
36 |
-
|
37 |
-
[  ](https://twitter.com/elevenlabsio)
|
38 |
-
|
39 |
-
</span>
|
40 |
-
<span>
|
41 |
-
|
42 |
-
[  ](https://discord.gg/elevenlabs)
|
43 |
-
|
44 |
-
</span>
|
45 |
-
</div>
|
46 |
-
"""
|
47 |
-
|
48 |
-
description = """
|
49 |
-
A demo of the world's most advanced TTS systems, made by [ElevenLabs](https://elevenlabs.io). Eleven Monolingual is designed to generate highly realistic voices in English, where Eleven Multilingual is a single model supporting multiple languages including English, German, Polish, Spanish, Italian, French, Portuguese, and Hindi. Sign up on [ElevenLabs](https://elevenlabs.io) to get fast access, long-form generation, voice cloning, API keys, and more!
|
50 |
-
"""
|
51 |
|
52 |
with gr.Blocks() as block:
|
53 |
-
gr.Markdown('[  ](https://elevenlabs.io)')
|
54 |
-
gr.Markdown(badges)
|
55 |
-
gr.Markdown(description)
|
56 |
|
57 |
input_text = gr.Textbox(
|
58 |
label="Input Text (250 characters max)",
|
@@ -63,19 +36,12 @@ with gr.Blocks() as block:
|
|
63 |
|
64 |
all_voices = voices()
|
65 |
input_voice = gr.Dropdown(
|
66 |
-
[
|
67 |
value="Arnold",
|
68 |
label="Voice",
|
69 |
elem_id="input_voice"
|
70 |
)
|
71 |
|
72 |
-
input_model = gr.Radio(
|
73 |
-
["eleven_monolingual_v1", "eleven_multilingual_v1"],
|
74 |
-
label="Model",
|
75 |
-
value="eleven_monolingual_v1",
|
76 |
-
elem_id="input_model",
|
77 |
-
)
|
78 |
-
|
79 |
run_button = gr.Button(
|
80 |
text="Generate Voice",
|
81 |
type="button"
|
@@ -87,7 +53,7 @@ with gr.Blocks() as block:
|
|
87 |
elem_id="out_audio"
|
88 |
)
|
89 |
|
90 |
-
inputs = [input_text, input_voice
|
91 |
outputs = [out_audio]
|
92 |
|
93 |
run_button.click(
|
@@ -97,4 +63,4 @@ with gr.Blocks() as block:
|
|
97 |
queue=True
|
98 |
)
|
99 |
|
100 |
-
block.queue(concurrency_count=1).launch(debug=True)
|
|
|
11 |
audio = audio + b'\0' * (element_size - (buffer_size % element_size))
|
12 |
return audio
|
13 |
|
14 |
+
def generate_voice(text, voice_name):
|
15 |
+
model_name = "eleven_multilingual_v1"
|
16 |
try:
|
17 |
audio = generate(
|
18 |
+
text[:250], # Limit to 250 characters
|
19 |
voice=voice_name,
|
20 |
model=model_name
|
21 |
)
|
|
|
23 |
except UnauthenticatedRateLimitError as e:
|
24 |
raise gr.Error("Thanks for trying out ElevenLabs TTS! You've reached the free tier limit. Please provide an API key to continue.")
|
25 |
except Exception as e:
|
26 |
+
raise gr.Error(str(e))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
27 |
|
28 |
with gr.Blocks() as block:
|
|
|
|
|
|
|
29 |
|
30 |
input_text = gr.Textbox(
|
31 |
label="Input Text (250 characters max)",
|
|
|
36 |
|
37 |
all_voices = voices()
|
38 |
input_voice = gr.Dropdown(
|
39 |
+
[voice.name for voice in all_voices],
|
40 |
value="Arnold",
|
41 |
label="Voice",
|
42 |
elem_id="input_voice"
|
43 |
)
|
44 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
45 |
run_button = gr.Button(
|
46 |
text="Generate Voice",
|
47 |
type="button"
|
|
|
53 |
elem_id="out_audio"
|
54 |
)
|
55 |
|
56 |
+
inputs = [input_text, input_voice]
|
57 |
outputs = [out_audio]
|
58 |
|
59 |
run_button.click(
|
|
|
63 |
queue=True
|
64 |
)
|
65 |
|
66 |
+
block.queue(concurrency_count=1, theme="Monochrome").launch(debug=True)
|