Spaces:
Running
Running
eaysu
commited on
Commit
·
d4af80c
1
Parent(s):
5ae480d
voice preset menu changed
Browse files
app.py
CHANGED
@@ -5,31 +5,27 @@ import numpy as np
|
|
5 |
|
6 |
torch.set_num_threads(1)
|
7 |
|
8 |
-
#
|
9 |
models = {
|
10 |
"suno/bark": BarkModel.from_pretrained("suno/bark"),
|
11 |
"suno/bark-small": BarkModel.from_pretrained("suno/bark-small")
|
12 |
}
|
13 |
|
14 |
-
#
|
15 |
-
|
16 |
-
"
|
17 |
-
|
18 |
-
|
19 |
-
"
|
20 |
-
|
21 |
-
|
22 |
-
"
|
23 |
-
|
24 |
-
|
25 |
-
"
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
# Function to update voice presets based on selected language
|
31 |
-
def get_voice_presets(language):
|
32 |
-
return voice_presets[language]
|
33 |
|
34 |
# Function to generate speech
|
35 |
def generate_speech(text, model_name, voice_preset):
|
@@ -47,43 +43,10 @@ def generate_speech(text, model_name, voice_preset):
|
|
47 |
with gr.Blocks() as app:
|
48 |
gr.Markdown("# Multilingual Text-to-Speech with Bark")
|
49 |
|
50 |
-
# Language selection
|
51 |
-
language_input = gr.Dropdown(
|
52 |
-
["English", "French", "German", "Turkish"],
|
53 |
-
label="Select Language",
|
54 |
-
value="English"
|
55 |
-
)
|
56 |
-
|
57 |
# Textbox for user input
|
58 |
text_input = gr.Textbox(label="Enter Text", placeholder="Type something to synthesize...")
|
59 |
|
60 |
# Model selection
|
61 |
model_preset_input = gr.Dropdown(["suno/bark", "suno/bark-small"], label="Select Model", value="suno/bark-small")
|
62 |
|
63 |
-
#
|
64 |
-
voice_preset_input = gr.Dropdown(
|
65 |
-
choices=voice_presets["English"],
|
66 |
-
label="Select Voice Preset"
|
67 |
-
)
|
68 |
-
|
69 |
-
# Button to generate voice
|
70 |
-
generate_button = gr.Button("Generate Voice")
|
71 |
-
|
72 |
-
# Output audio
|
73 |
-
audio_output = gr.Audio(label="Generated Voice", type="numpy")
|
74 |
-
|
75 |
-
# Display voice presets based on language selection
|
76 |
-
def update_preset_choices(language):
|
77 |
-
return gr.Dropdown.update(choices=get_voice_presets(language))
|
78 |
-
|
79 |
-
# Set dynamic update on language selection
|
80 |
-
language_input.change(update_preset_choices, inputs=language_input, outputs=voice_preset_input)
|
81 |
-
|
82 |
-
# Generate voice on button click
|
83 |
-
generate_button.click(
|
84 |
-
generate_speech,
|
85 |
-
inputs=[text_input, model_preset_input, voice_preset_input],
|
86 |
-
outputs=audio_output
|
87 |
-
)
|
88 |
-
|
89 |
-
app.launch()
|
|
|
5 |
|
6 |
torch.set_num_threads(1)
|
7 |
|
8 |
+
# Load models
|
9 |
models = {
|
10 |
"suno/bark": BarkModel.from_pretrained("suno/bark"),
|
11 |
"suno/bark-small": BarkModel.from_pretrained("suno/bark-small")
|
12 |
}
|
13 |
|
14 |
+
# Combined voice presets
|
15 |
+
all_voice_presets = [
|
16 |
+
"v2/en_speaker_0", "v2/en_speaker_1", "v2/en_speaker_2", "v2/en_speaker_3",
|
17 |
+
"v2/en_speaker_4", "v2/en_speaker_5", "v2/en_speaker_6",
|
18 |
+
"v2/en_speaker_7", "v2/en_speaker_8", "v2/en_speaker_9",
|
19 |
+
"v2/fr_speaker_0", "v2/fr_speaker_1", "v2/fr_speaker_2", "v2/fr_speaker_3",
|
20 |
+
"v2/fr_speaker_4", "v2/fr_speaker_5", "v2/fr_speaker_6",
|
21 |
+
"v2/fr_speaker_7", "v2/fr_speaker_8", "v2/fr_speaker_9",
|
22 |
+
"v2/de_speaker_0", "v2/de_speaker_1", "v2/de_speaker_2", "v2/de_speaker_3",
|
23 |
+
"v2/de_speaker_4", "v2/de_speaker_5", "v2/de_speaker_6",
|
24 |
+
"v2/de_speaker_7", "v2/de_speaker_8", "v2/de_speaker_9",
|
25 |
+
"v2/tr_speaker_0", "v2/tr_speaker_1", "v2/tr_speaker_2", "v2/tr_speaker_3",
|
26 |
+
"v2/tr_speaker_4", "v2/tr_speaker_5", "v2/tr_speaker_6",
|
27 |
+
"v2/tr_speaker_7", "v2/tr_speaker_8", "v2/tr_speaker_9"
|
28 |
+
]
|
|
|
|
|
|
|
|
|
29 |
|
30 |
# Function to generate speech
|
31 |
def generate_speech(text, model_name, voice_preset):
|
|
|
43 |
with gr.Blocks() as app:
|
44 |
gr.Markdown("# Multilingual Text-to-Speech with Bark")
|
45 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
46 |
# Textbox for user input
|
47 |
text_input = gr.Textbox(label="Enter Text", placeholder="Type something to synthesize...")
|
48 |
|
49 |
# Model selection
|
50 |
model_preset_input = gr.Dropdown(["suno/bark", "suno/bark-small"], label="Select Model", value="suno/bark-small")
|
51 |
|
52 |
+
# Combined voice pr
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|