Update app.py
Browse files
app.py
CHANGED
@@ -11,8 +11,9 @@ def pad_buffer(audio):
|
|
11 |
audio = audio + b'\0' * (element_size - (buffer_size % element_size))
|
12 |
return audio
|
13 |
|
14 |
-
def generate_voice(text
|
15 |
model_name = "eleven_multilingual_v1"
|
|
|
16 |
try:
|
17 |
audio = generate(
|
18 |
text[:250], # Limit to 250 characters
|
@@ -25,27 +26,13 @@ def generate_voice(text, voice_name):
|
|
25 |
except Exception as e:
|
26 |
raise gr.Error(str(e))
|
27 |
|
28 |
-
# Fetch all available voices
|
29 |
-
all_voices = voices()
|
30 |
-
|
31 |
-
# Filter out the desired voices and set Antonio as default
|
32 |
-
desired_voices = ["Anita", "Rachael", "Michael", "Antonio"]
|
33 |
-
filtered_voices = [voice.name for voice in all_voices if voice.name in desired_voices]
|
34 |
-
|
35 |
input_text = gr.Textbox(
|
36 |
label="Input Text (250 characters max)",
|
37 |
lines=2,
|
38 |
-
value="Ciao,
|
39 |
elem_id="input_text"
|
40 |
)
|
41 |
|
42 |
-
input_voice = gr.Dropdown(
|
43 |
-
choices=filtered_voices,
|
44 |
-
default="Antonio",
|
45 |
-
label="Voice",
|
46 |
-
elem_id="input_voice"
|
47 |
-
)
|
48 |
-
|
49 |
out_audio = gr.Audio(
|
50 |
label="Generated Voice",
|
51 |
type="numpy",
|
@@ -54,7 +41,7 @@ out_audio = gr.Audio(
|
|
54 |
|
55 |
iface = gr.Interface(
|
56 |
fn=generate_voice,
|
57 |
-
inputs=
|
58 |
outputs=out_audio,
|
59 |
live=True,
|
60 |
theme="Monochrome",
|
|
|
11 |
audio = audio + b'\0' * (element_size - (buffer_size % element_size))
|
12 |
return audio
|
13 |
|
14 |
+
def generate_voice(text):
|
15 |
model_name = "eleven_multilingual_v1"
|
16 |
+
voice_name = "Antonio"
|
17 |
try:
|
18 |
audio = generate(
|
19 |
text[:250], # Limit to 250 characters
|
|
|
26 |
except Exception as e:
|
27 |
raise gr.Error(str(e))
|
28 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
29 |
input_text = gr.Textbox(
|
30 |
label="Input Text (250 characters max)",
|
31 |
lines=2,
|
32 |
+
value="Ciao, proviamo a dare una voce alle tue parole. Scrivi qui ciò che vorresti ascoltare!",
|
33 |
elem_id="input_text"
|
34 |
)
|
35 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
36 |
out_audio = gr.Audio(
|
37 |
label="Generated Voice",
|
38 |
type="numpy",
|
|
|
41 |
|
42 |
iface = gr.Interface(
|
43 |
fn=generate_voice,
|
44 |
+
inputs=input_text,
|
45 |
outputs=out_audio,
|
46 |
live=True,
|
47 |
theme="Monochrome",
|