Spaces:
Running
on
Zero
Running
on
Zero
Update app.py
Browse files
app.py
CHANGED
@@ -31,9 +31,9 @@ _model_initialized = False
|
|
31 |
_initialization_in_progress = False
|
32 |
|
33 |
def get_speakers_dict():
|
34 |
-
"""Get speakers dictionary using the
|
35 |
try:
|
36 |
-
#
|
37 |
from maliba_ai.config.settings import Speakers
|
38 |
return {
|
39 |
"Adama": Speakers.Adama,
|
@@ -48,8 +48,8 @@ def get_speakers_dict():
|
|
48 |
"Amara": Speakers.Amara
|
49 |
}
|
50 |
except Exception as e:
|
51 |
-
logger.error(f"Failed to import from settings: {e}")
|
52 |
-
# Fallback to old structure
|
53 |
try:
|
54 |
from maliba_ai.config.speakers import Adame, Moussa, Bourama, Modibo, Seydou
|
55 |
return {
|
@@ -85,7 +85,7 @@ def initialize_model_once():
|
|
85 |
logger.info("Initializing Bambara TTS model...")
|
86 |
start_time = time.time()
|
87 |
|
88 |
-
# Use the
|
89 |
from maliba_ai.tts.inference import BambaraTTSInference
|
90 |
|
91 |
model = BambaraTTSInference()
|
@@ -174,12 +174,18 @@ def generate_speech(text, speaker_name, use_advanced, temperature, top_k, top_p,
|
|
174 |
logger.error(f"Speech generation failed: {e}")
|
175 |
return None, f"β Error: {str(e)}"
|
176 |
|
177 |
-
# Use available speakers (
|
178 |
def get_speaker_names():
|
179 |
speakers = get_speakers_dict()
|
180 |
-
if speakers:
|
|
|
|
|
|
|
|
|
181 |
return list(speakers.keys())
|
182 |
-
|
|
|
|
|
183 |
|
184 |
SPEAKER_NAMES = get_speaker_names()
|
185 |
|
@@ -224,7 +230,7 @@ def build_interface():
|
|
224 |
choices=SPEAKER_NAMES,
|
225 |
value="Bourama" if "Bourama" in SPEAKER_NAMES else SPEAKER_NAMES[0],
|
226 |
label="π£οΈ Speaker Voice",
|
227 |
-
info=f"Choose from {len(SPEAKER_NAMES)} authentic voices"
|
228 |
)
|
229 |
|
230 |
generate_btn = gr.Button("π΅ Generate Speech", variant="primary", size="lg")
|
@@ -313,6 +319,18 @@ def build_interface():
|
|
313 |
### π Available Speakers:
|
314 |
{', '.join(SPEAKER_NAMES)}
|
315 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
316 |
**License**: Creative Commons Attribution-NonCommercial-ShareAlike 4.0 (CC BY-NC-SA 4.0)
|
317 |
|
318 |
---
|
|
|
31 |
_initialization_in_progress = False
|
32 |
|
33 |
def get_speakers_dict():
|
34 |
+
"""Get speakers dictionary using the new SDK structure"""
|
35 |
try:
|
36 |
+
# Use new structure from maliba_ai.config.settings (as shown in README)
|
37 |
from maliba_ai.config.settings import Speakers
|
38 |
return {
|
39 |
"Adama": Speakers.Adama,
|
|
|
48 |
"Amara": Speakers.Amara
|
49 |
}
|
50 |
except Exception as e:
|
51 |
+
logger.error(f"Failed to import from new settings structure: {e}")
|
52 |
+
# Fallback to old structure if new one fails
|
53 |
try:
|
54 |
from maliba_ai.config.speakers import Adame, Moussa, Bourama, Modibo, Seydou
|
55 |
return {
|
|
|
85 |
logger.info("Initializing Bambara TTS model...")
|
86 |
start_time = time.time()
|
87 |
|
88 |
+
# Use the new import structure from the README
|
89 |
from maliba_ai.tts.inference import BambaraTTSInference
|
90 |
|
91 |
model = BambaraTTSInference()
|
|
|
174 |
logger.error(f"Speech generation failed: {e}")
|
175 |
return None, f"β Error: {str(e)}"
|
176 |
|
177 |
+
# Use available speakers (prioritize new SDK structure with 10 speakers)
|
178 |
def get_speaker_names():
|
179 |
speakers = get_speakers_dict()
|
180 |
+
if speakers and len(speakers) >= 10:
|
181 |
+
# New SDK with all 10 speakers
|
182 |
+
return ["Bourama", "Adama", "Moussa", "Modibo", "Seydou", "Amadou", "Bakary", "Ngolo", "Ibrahima", "Amara"]
|
183 |
+
elif speakers:
|
184 |
+
# Return whatever speakers are available
|
185 |
return list(speakers.keys())
|
186 |
+
else:
|
187 |
+
# Fallback to old 5 speakers
|
188 |
+
return ["Adama", "Moussa", "Bourama", "Modibo", "Seydou"]
|
189 |
|
190 |
SPEAKER_NAMES = get_speaker_names()
|
191 |
|
|
|
230 |
choices=SPEAKER_NAMES,
|
231 |
value="Bourama" if "Bourama" in SPEAKER_NAMES else SPEAKER_NAMES[0],
|
232 |
label="π£οΈ Speaker Voice",
|
233 |
+
info=f"Choose from {len(SPEAKER_NAMES)} authentic voices (Bourama recommended)"
|
234 |
)
|
235 |
|
236 |
generate_btn = gr.Button("π΅ Generate Speech", variant="primary", size="lg")
|
|
|
319 |
### π Available Speakers:
|
320 |
{', '.join(SPEAKER_NAMES)}
|
321 |
|
322 |
+
### π― Speaker Characteristics:
|
323 |
+
- **Bourama**: Most stable and accurate (recommended)
|
324 |
+
- **Adama**: Natural conversational tone
|
325 |
+
- **Moussa**: Clear pronunciation for educational content
|
326 |
+
- **Modibo**: Expressive delivery for storytelling
|
327 |
+
- **Seydou**: Balanced characteristics for general use
|
328 |
+
- **Amadou**: Warm and friendly voice
|
329 |
+
- **Bakary**: Deep, authoritative tone
|
330 |
+
- **Ngolo**: Youthful and energetic
|
331 |
+
- **Ibrahima**: Calm and measured delivery
|
332 |
+
- **Amara**: Melodic and smooth
|
333 |
+
|
334 |
**License**: Creative Commons Attribution-NonCommercial-ShareAlike 4.0 (CC BY-NC-SA 4.0)
|
335 |
|
336 |
---
|