Spaces:
Running
Running
Commit
·
4306d26
1
Parent(s):
8aa19f9
feat: set max len, remove api key
Browse files
app.py
CHANGED
|
@@ -11,13 +11,12 @@ 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, model_name
|
| 15 |
try:
|
| 16 |
audio = generate(
|
| 17 |
-
text,
|
| 18 |
voice=voice_name,
|
| 19 |
-
model=model_name
|
| 20 |
-
api_key=api_key if api_key != '' else None
|
| 21 |
)
|
| 22 |
return (44100, np.frombuffer(pad_buffer(audio), dtype=np.int16))
|
| 23 |
except UnauthenticatedRateLimitError as e:
|
|
@@ -47,7 +46,7 @@ badges = """
|
|
| 47 |
"""
|
| 48 |
|
| 49 |
description = """
|
| 50 |
-
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.
|
| 51 |
"""
|
| 52 |
|
| 53 |
with gr.Blocks() as block:
|
|
@@ -56,7 +55,7 @@ with gr.Blocks() as block:
|
|
| 56 |
gr.Markdown(description)
|
| 57 |
|
| 58 |
input_text = gr.Textbox(
|
| 59 |
-
label="Input Text",
|
| 60 |
lines=2,
|
| 61 |
value="Hahaha OHH MY GOD! This is SOOO funny, I-I am Eleven and-and I am a text to speech system!!",
|
| 62 |
elem_id="input_text"
|
|
@@ -77,12 +76,6 @@ with gr.Blocks() as block:
|
|
| 77 |
elem_id="input_model",
|
| 78 |
)
|
| 79 |
|
| 80 |
-
input_api_key = gr.Textbox(
|
| 81 |
-
label="API Key (Optional)",
|
| 82 |
-
lines=1,
|
| 83 |
-
elem_id="input_api_key"
|
| 84 |
-
)
|
| 85 |
-
|
| 86 |
run_button = gr.Button(
|
| 87 |
text="Generate Voice",
|
| 88 |
type="button"
|
|
@@ -94,7 +87,7 @@ with gr.Blocks() as block:
|
|
| 94 |
elem_id="out_audio"
|
| 95 |
)
|
| 96 |
|
| 97 |
-
inputs = [input_text, input_voice, input_model
|
| 98 |
outputs = [out_audio]
|
| 99 |
|
| 100 |
run_button.click(
|
|
@@ -104,4 +97,4 @@ with gr.Blocks() as block:
|
|
| 104 |
queue=True
|
| 105 |
)
|
| 106 |
|
| 107 |
-
block.queue(
|
|
|
|
| 11 |
audio = audio + b'\0' * (element_size - (buffer_size % element_size))
|
| 12 |
return audio
|
| 13 |
|
| 14 |
+
def generate_voice(text, voice_name, model_name):
|
| 15 |
try:
|
| 16 |
audio = generate(
|
| 17 |
+
text[:250], # Limit to 250 characters
|
| 18 |
voice=voice_name,
|
| 19 |
+
model=model_name
|
|
|
|
| 20 |
)
|
| 21 |
return (44100, np.frombuffer(pad_buffer(audio), dtype=np.int16))
|
| 22 |
except UnauthenticatedRateLimitError as e:
|
|
|
|
| 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:
|
|
|
|
| 55 |
gr.Markdown(description)
|
| 56 |
|
| 57 |
input_text = gr.Textbox(
|
| 58 |
+
label="Input Text (250 characters max)",
|
| 59 |
lines=2,
|
| 60 |
value="Hahaha OHH MY GOD! This is SOOO funny, I-I am Eleven and-and I am a text to speech system!!",
|
| 61 |
elem_id="input_text"
|
|
|
|
| 76 |
elem_id="input_model",
|
| 77 |
)
|
| 78 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 79 |
run_button = gr.Button(
|
| 80 |
text="Generate Voice",
|
| 81 |
type="button"
|
|
|
|
| 87 |
elem_id="out_audio"
|
| 88 |
)
|
| 89 |
|
| 90 |
+
inputs = [input_text, input_voice, input_model]
|
| 91 |
outputs = [out_audio]
|
| 92 |
|
| 93 |
run_button.click(
|
|
|
|
| 97 |
queue=True
|
| 98 |
)
|
| 99 |
|
| 100 |
+
block.queue(concurrency_count=1).launch(debug=True)
|