Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,656 +1,523 @@
|
|
| 1 |
-
import gradio as gr
|
| 2 |
-
import google.generativeai as genai
|
| 3 |
-
from gtts import gTTS
|
| 4 |
-
import pyttsx3
|
| 5 |
-
|
| 6 |
-
import
|
| 7 |
-
import
|
| 8 |
-
|
| 9 |
-
import
|
| 10 |
-
import
|
| 11 |
-
|
| 12 |
-
import
|
| 13 |
-
|
| 14 |
-
|
| 15 |
-
|
| 16 |
-
|
| 17 |
-
|
| 18 |
-
|
| 19 |
-
|
| 20 |
-
|
| 21 |
-
|
| 22 |
-
|
| 23 |
-
|
| 24 |
-
|
| 25 |
-
{"name": "
|
| 26 |
-
|
| 27 |
-
|
| 28 |
-
|
| 29 |
-
|
| 30 |
-
{"name": "
|
| 31 |
-
{"name": "
|
| 32 |
-
|
| 33 |
-
}
|
| 34 |
-
|
| 35 |
-
|
| 36 |
-
|
| 37 |
-
|
| 38 |
-
|
| 39 |
-
|
| 40 |
-
|
| 41 |
-
|
| 42 |
-
|
| 43 |
-
|
| 44 |
-
|
| 45 |
-
|
| 46 |
-
|
| 47 |
-
return
|
| 48 |
-
|
| 49 |
-
|
| 50 |
-
|
| 51 |
-
|
| 52 |
-
|
| 53 |
-
|
| 54 |
-
|
| 55 |
-
|
| 56 |
-
|
| 57 |
-
return
|
| 58 |
-
|
| 59 |
-
|
| 60 |
-
|
| 61 |
-
|
| 62 |
-
|
| 63 |
-
|
| 64 |
-
|
| 65 |
-
|
| 66 |
-
|
| 67 |
-
|
| 68 |
-
|
| 69 |
-
|
| 70 |
-
|
| 71 |
-
|
| 72 |
-
|
| 73 |
-
|
| 74 |
-
|
| 75 |
-
|
| 76 |
-
|
| 77 |
-
|
| 78 |
-
|
| 79 |
-
|
| 80 |
-
|
| 81 |
-
|
| 82 |
-
|
| 83 |
-
|
| 84 |
-
|
| 85 |
-
|
| 86 |
-
|
| 87 |
-
|
| 88 |
-
|
| 89 |
-
|
| 90 |
-
|
| 91 |
-
|
| 92 |
-
|
| 93 |
-
|
| 94 |
-
|
| 95 |
-
|
| 96 |
-
|
| 97 |
-
|
| 98 |
-
|
| 99 |
-
|
| 100 |
-
|
| 101 |
-
|
| 102 |
-
|
| 103 |
-
|
| 104 |
-
|
| 105 |
-
|
| 106 |
-
|
| 107 |
-
|
| 108 |
-
|
| 109 |
-
|
| 110 |
-
|
| 111 |
-
|
| 112 |
-
|
| 113 |
-
|
| 114 |
-
|
| 115 |
-
|
| 116 |
-
|
| 117 |
-
|
| 118 |
-
|
| 119 |
-
|
| 120 |
-
|
| 121 |
-
|
| 122 |
-
|
| 123 |
-
|
| 124 |
-
|
| 125 |
-
|
| 126 |
-
|
| 127 |
-
|
| 128 |
-
|
| 129 |
-
|
| 130 |
-
|
| 131 |
-
|
| 132 |
-
|
| 133 |
-
|
| 134 |
-
|
| 135 |
-
|
| 136 |
-
|
| 137 |
-
|
| 138 |
-
|
| 139 |
-
#
|
| 140 |
-
|
| 141 |
-
|
| 142 |
-
|
| 143 |
-
|
| 144 |
-
|
| 145 |
-
|
| 146 |
-
|
| 147 |
-
|
| 148 |
-
|
| 149 |
-
|
| 150 |
-
|
| 151 |
-
|
| 152 |
-
|
| 153 |
-
|
| 154 |
-
|
| 155 |
-
|
| 156 |
-
|
| 157 |
-
|
| 158 |
-
|
| 159 |
-
|
| 160 |
-
|
| 161 |
-
|
| 162 |
-
|
| 163 |
-
|
| 164 |
-
|
| 165 |
-
|
| 166 |
-
|
| 167 |
-
|
| 168 |
-
|
| 169 |
-
|
| 170 |
-
|
| 171 |
-
|
| 172 |
-
|
| 173 |
-
|
| 174 |
-
|
| 175 |
-
|
| 176 |
-
|
| 177 |
-
|
| 178 |
-
|
| 179 |
-
|
| 180 |
-
|
| 181 |
-
|
| 182 |
-
|
| 183 |
-
|
| 184 |
-
|
| 185 |
-
|
| 186 |
-
|
| 187 |
-
|
| 188 |
-
|
| 189 |
-
|
| 190 |
-
|
| 191 |
-
|
| 192 |
-
|
| 193 |
-
|
| 194 |
-
|
| 195 |
-
|
| 196 |
-
|
| 197 |
-
|
| 198 |
-
|
| 199 |
-
|
| 200 |
-
|
| 201 |
-
|
| 202 |
-
|
| 203 |
-
|
| 204 |
-
|
| 205 |
-
|
| 206 |
-
|
| 207 |
-
|
| 208 |
-
|
| 209 |
-
|
| 210 |
-
|
| 211 |
-
|
| 212 |
-
|
| 213 |
-
|
| 214 |
-
|
| 215 |
-
|
| 216 |
-
|
| 217 |
-
|
| 218 |
-
|
| 219 |
-
|
| 220 |
-
|
| 221 |
-
|
| 222 |
-
|
| 223 |
-
|
| 224 |
-
|
| 225 |
-
|
| 226 |
-
|
| 227 |
-
|
| 228 |
-
|
| 229 |
-
|
| 230 |
-
|
| 231 |
-
|
| 232 |
-
|
| 233 |
-
|
| 234 |
-
|
| 235 |
-
|
| 236 |
-
|
| 237 |
-
|
| 238 |
-
|
| 239 |
-
|
| 240 |
-
|
| 241 |
-
|
| 242 |
-
|
| 243 |
-
|
| 244 |
-
|
| 245 |
-
|
| 246 |
-
|
| 247 |
-
|
| 248 |
-
|
| 249 |
-
|
| 250 |
-
|
| 251 |
-
|
| 252 |
-
|
| 253 |
-
|
| 254 |
-
|
| 255 |
-
|
| 256 |
-
|
| 257 |
-
|
| 258 |
-
|
| 259 |
-
|
| 260 |
-
|
| 261 |
-
|
| 262 |
-
|
| 263 |
-
|
| 264 |
-
|
| 265 |
-
|
| 266 |
-
|
| 267 |
-
|
| 268 |
-
|
| 269 |
-
|
| 270 |
-
|
| 271 |
-
|
| 272 |
-
|
| 273 |
-
|
| 274 |
-
|
| 275 |
-
|
| 276 |
-
|
| 277 |
-
|
| 278 |
-
|
| 279 |
-
|
| 280 |
-
|
| 281 |
-
|
| 282 |
-
|
| 283 |
-
|
| 284 |
-
|
| 285 |
-
|
| 286 |
-
|
| 287 |
-
|
| 288 |
-
|
| 289 |
-
|
| 290 |
-
|
| 291 |
-
|
| 292 |
-
|
| 293 |
-
|
| 294 |
-
|
| 295 |
-
|
| 296 |
-
|
| 297 |
-
|
| 298 |
-
|
| 299 |
-
|
| 300 |
-
|
| 301 |
-
|
| 302 |
-
|
| 303 |
-
|
| 304 |
-
|
| 305 |
-
|
| 306 |
-
|
| 307 |
-
|
| 308 |
-
|
| 309 |
-
|
| 310 |
-
|
| 311 |
-
|
| 312 |
-
|
| 313 |
-
|
| 314 |
-
|
| 315 |
-
|
| 316 |
-
|
| 317 |
-
|
| 318 |
-
.
|
| 319 |
-
|
| 320 |
-
|
| 321 |
-
|
| 322 |
-
|
| 323 |
-
|
| 324 |
-
|
| 325 |
-
|
| 326 |
-
|
| 327 |
-
|
| 328 |
-
|
| 329 |
-
|
| 330 |
-
|
| 331 |
-
|
| 332 |
-
|
| 333 |
-
|
| 334 |
-
|
| 335 |
-
|
| 336 |
-
|
| 337 |
-
|
| 338 |
-
.
|
| 339 |
-
|
| 340 |
-
|
| 341 |
-
|
| 342 |
-
|
| 343 |
-
|
| 344 |
-
|
| 345 |
-
|
| 346 |
-
|
| 347 |
-
|
| 348 |
-
|
| 349 |
-
|
| 350 |
-
|
| 351 |
-
|
| 352 |
-
|
| 353 |
-
|
| 354 |
-
|
| 355 |
-
|
| 356 |
-
|
| 357 |
-
|
| 358 |
-
|
| 359 |
-
|
| 360 |
-
|
| 361 |
-
|
| 362 |
-
|
| 363 |
-
|
| 364 |
-
|
| 365 |
-
|
| 366 |
-
|
| 367 |
-
|
| 368 |
-
|
| 369 |
-
|
| 370 |
-
|
| 371 |
-
|
| 372 |
-
|
| 373 |
-
|
| 374 |
-
|
| 375 |
-
|
| 376 |
-
|
| 377 |
-
|
| 378 |
-
|
| 379 |
-
|
| 380 |
-
|
| 381 |
-
|
| 382 |
-
|
| 383 |
-
|
| 384 |
-
|
| 385 |
-
|
| 386 |
-
|
| 387 |
-
|
| 388 |
-
|
| 389 |
-
|
| 390 |
-
|
| 391 |
-
|
| 392 |
-
|
| 393 |
-
|
| 394 |
-
|
| 395 |
-
|
| 396 |
-
|
| 397 |
-
|
| 398 |
-
|
| 399 |
-
|
| 400 |
-
|
| 401 |
-
|
| 402 |
-
|
| 403 |
-
|
| 404 |
-
|
| 405 |
-
|
| 406 |
-
|
| 407 |
-
|
| 408 |
-
|
| 409 |
-
|
| 410 |
-
|
| 411 |
-
|
| 412 |
-
|
| 413 |
-
|
| 414 |
-
|
| 415 |
-
|
| 416 |
-
|
| 417 |
-
|
| 418 |
-
|
| 419 |
-
|
| 420 |
-
|
| 421 |
-
|
| 422 |
-
|
| 423 |
-
|
| 424 |
-
|
| 425 |
-
|
| 426 |
-
|
| 427 |
-
|
| 428 |
-
|
| 429 |
-
|
| 430 |
-
|
| 431 |
-
|
| 432 |
-
|
| 433 |
-
|
| 434 |
-
|
| 435 |
-
|
| 436 |
-
|
| 437 |
-
|
| 438 |
-
|
| 439 |
-
|
| 440 |
-
|
| 441 |
-
|
| 442 |
-
|
| 443 |
-
|
| 444 |
-
|
| 445 |
-
|
| 446 |
-
|
| 447 |
-
|
| 448 |
-
|
| 449 |
-
|
| 450 |
-
with gr.
|
| 451 |
-
gr.
|
| 452 |
-
|
| 453 |
-
|
| 454 |
-
|
| 455 |
-
|
| 456 |
-
|
| 457 |
-
|
| 458 |
-
|
| 459 |
-
|
| 460 |
-
|
| 461 |
-
|
| 462 |
-
|
| 463 |
-
|
| 464 |
-
|
| 465 |
-
|
| 466 |
-
|
| 467 |
-
|
| 468 |
-
|
| 469 |
-
|
| 470 |
-
|
| 471 |
-
|
| 472 |
-
|
| 473 |
-
)
|
| 474 |
-
|
| 475 |
-
|
| 476 |
-
|
| 477 |
-
|
| 478 |
-
|
| 479 |
-
|
| 480 |
-
|
| 481 |
-
|
| 482 |
-
|
| 483 |
-
|
| 484 |
-
|
| 485 |
-
|
| 486 |
-
|
| 487 |
-
|
| 488 |
-
|
| 489 |
-
value=
|
| 490 |
-
|
| 491 |
-
|
| 492 |
-
|
| 493 |
-
|
| 494 |
-
|
| 495 |
-
|
| 496 |
-
|
| 497 |
-
|
| 498 |
-
|
| 499 |
-
|
| 500 |
-
|
| 501 |
-
|
| 502 |
-
|
| 503 |
-
|
| 504 |
-
|
| 505 |
-
|
| 506 |
-
|
| 507 |
-
|
| 508 |
-
|
| 509 |
-
|
| 510 |
-
|
| 511 |
-
|
| 512 |
-
|
| 513 |
-
|
| 514 |
-
|
| 515 |
-
|
| 516 |
-
|
| 517 |
-
|
| 518 |
-
|
| 519 |
-
|
| 520 |
-
|
| 521 |
-
|
| 522 |
-
|
| 523 |
-
|
| 524 |
-
type="filepath",
|
| 525 |
-
visible=False
|
| 526 |
-
)
|
| 527 |
-
download_btn = gr.DownloadButton(
|
| 528 |
-
"⬇️ Download Podcast",
|
| 529 |
-
visible=False,
|
| 530 |
-
variant="secondary"
|
| 531 |
-
)
|
| 532 |
-
|
| 533 |
-
# Speaker info display
|
| 534 |
-
speaker_info = gr.HTML(
|
| 535 |
-
value="",
|
| 536 |
-
visible=False
|
| 537 |
-
)
|
| 538 |
-
|
| 539 |
-
# Script output
|
| 540 |
-
script_output = gr.Textbox(
|
| 541 |
-
label="Podcast Script",
|
| 542 |
-
visible=False,
|
| 543 |
-
lines=8,
|
| 544 |
-
elem_classes="output-script"
|
| 545 |
-
)
|
| 546 |
-
|
| 547 |
-
# Instructions
|
| 548 |
-
with gr.Column(elem_classes="instructions"):
|
| 549 |
-
gr.Markdown("### ℹ️ How to Use")
|
| 550 |
-
gr.Markdown("""
|
| 551 |
-
1. **Optional**: Enter your Gemini API key for AI-powered conversation generation
|
| 552 |
-
2. **Paste your text** in the input box (articles, blogs, etc.)
|
| 553 |
-
3. **Choose number of speakers** (1-4) for different conversation styles
|
| 554 |
-
4. **Select voice engine**:
|
| 555 |
-
- Multi-Speaker Edge TTS (best quality, realistic voices)
|
| 556 |
-
- gTTS (single voice, good quality)
|
| 557 |
-
- pyttsx3 (offline, system voice)
|
| 558 |
-
5. **Click Generate Podcast** and wait for processing
|
| 559 |
-
6. **Listen and download** your podcast!
|
| 560 |
-
|
| 561 |
-
**Speaker Configurations**:
|
| 562 |
-
- **1 Speaker**: Solo narration
|
| 563 |
-
- **2 Speakers**: Host conversation (Alex & Brian)
|
| 564 |
-
- **3 Speakers**: Panel discussion (Sarah, Mike & Emma)
|
| 565 |
-
- **4 Speakers**: Full roundtable (Sarah, Mike, Emma & David)
|
| 566 |
-
|
| 567 |
-
**Tips**:
|
| 568 |
-
- For best results, use 500-3000 characters of text
|
| 569 |
-
- Multi-speaker works best with Gemini AI enabled
|
| 570 |
-
- Edge TTS provides the most realistic conversations
|
| 571 |
-
""")
|
| 572 |
-
|
| 573 |
-
def get_speaker_info(speaker_count):
|
| 574 |
-
"""Get speaker information for display"""
|
| 575 |
-
if speaker_count == 1:
|
| 576 |
-
return "<div class='speaker-info'><b>Single Speaker Mode</b><br/>Solo narration with one voice</div>"
|
| 577 |
-
|
| 578 |
-
voice_config = VOICE_CONFIGS[f"{speaker_count}_speakers"]
|
| 579 |
-
speakers_html = "<div class='speaker-info'><b>Speakers in this podcast:</b><br/>"
|
| 580 |
-
|
| 581 |
-
for i, config in enumerate(voice_config):
|
| 582 |
-
speakers_html += f"🎤 <b>{config['name']}</b> ({config['gender']} voice)<br/>"
|
| 583 |
-
|
| 584 |
-
speakers_html += "</div>"
|
| 585 |
-
return speakers_html
|
| 586 |
-
|
| 587 |
-
# Event handlers
|
| 588 |
-
def update_status(message, success=True):
|
| 589 |
-
"""Update status message with appropriate styling"""
|
| 590 |
-
status_class = "status-success" if success else "status-error"
|
| 591 |
-
if "Ready" in message or "ℹ️" in message:
|
| 592 |
-
status_class = "status-info"
|
| 593 |
-
return f"<div class='status-message {status_class}'>{message}</div>"
|
| 594 |
-
|
| 595 |
-
def generate_podcast_wrapper(text, use_gemini, tts_engine, speaker_count, progress=gr.Progress()):
|
| 596 |
-
"""Wrapper function for podcast generation"""
|
| 597 |
-
audio_data, message, script = create_podcast(text, use_gemini, tts_engine, speaker_count, progress)
|
| 598 |
-
|
| 599 |
-
status_html = update_status(message, success=audio_data is not None)
|
| 600 |
-
|
| 601 |
-
outputs = [status_html]
|
| 602 |
-
if audio_data:
|
| 603 |
-
# Save audio to temporary file for playback and download
|
| 604 |
-
filename = f"podcast_{speaker_count}speakers_{uuid4().hex[:8]}.wav"
|
| 605 |
-
filepath = os.path.join(tempfile.gettempdir(), filename)
|
| 606 |
-
|
| 607 |
-
with open(filepath, 'wb') as f:
|
| 608 |
-
f.write(audio_data)
|
| 609 |
-
|
| 610 |
-
# Get speaker info
|
| 611 |
-
speaker_info_html = get_speaker_info(speaker_count)
|
| 612 |
-
|
| 613 |
-
outputs.extend([filepath, filepath, speaker_info_html, script])
|
| 614 |
-
else:
|
| 615 |
-
outputs.extend([None, None, "", script])
|
| 616 |
-
|
| 617 |
-
return outputs
|
| 618 |
-
|
| 619 |
-
# Connect the button click event
|
| 620 |
-
generate_btn.click(
|
| 621 |
-
fn=generate_podcast_wrapper,
|
| 622 |
-
inputs=[input_text, use_gemini, tts_engine, speaker_count],
|
| 623 |
-
outputs=[status_msg, audio_output, download_btn, speaker_info, script_output]
|
| 624 |
-
)
|
| 625 |
-
|
| 626 |
-
# Update speaker info when speaker count changes
|
| 627 |
-
speaker_count.change(
|
| 628 |
-
fn=get_speaker_info,
|
| 629 |
-
inputs=speaker_count,
|
| 630 |
-
outputs=speaker_info
|
| 631 |
-
)
|
| 632 |
-
|
| 633 |
-
# Show/hide outputs based on results
|
| 634 |
-
def toggle_visibility(audio_data):
|
| 635 |
-
has_audio = audio_data is not None
|
| 636 |
-
return (
|
| 637 |
-
gr.Audio(visible=has_audio),
|
| 638 |
-
gr.DownloadButton(visible=has_audio),
|
| 639 |
-
gr.HTML(visible=has_audio),
|
| 640 |
-
gr.Textbox(visible=has_audio)
|
| 641 |
-
)
|
| 642 |
-
|
| 643 |
-
audio_output.change(
|
| 644 |
-
fn=toggle_visibility,
|
| 645 |
-
inputs=audio_output,
|
| 646 |
-
outputs=[audio_output, download_btn, speaker_info, script_output]
|
| 647 |
-
)
|
| 648 |
-
|
| 649 |
-
# Launch the application
|
| 650 |
-
if __name__ == "__main__":
|
| 651 |
-
demo.launch(
|
| 652 |
-
server_name="0.0.0.0",
|
| 653 |
-
server_port=7860,
|
| 654 |
-
share=False,
|
| 655 |
-
show_error=True
|
| 656 |
-
)
|
|
|
|
| 1 |
+
import gradio as gr
|
| 2 |
+
import google.generativeai as genai
|
| 3 |
+
from gtts import gTTS
|
| 4 |
+
import pyttsx3
|
| 5 |
+
import tempfile
|
| 6 |
+
import os
|
| 7 |
+
from uuid import uuid4
|
| 8 |
+
import time
|
| 9 |
+
import asyncio
|
| 10 |
+
from pydub import AudioSegment
|
| 11 |
+
try:
|
| 12 |
+
import edge_tts
|
| 13 |
+
EDGE_TTS_AVAILABLE = True
|
| 14 |
+
except ImportError:
|
| 15 |
+
EDGE_TTS_AVAILABLE = False
|
| 16 |
+
print("Edge TTS not available, using fallback options")
|
| 17 |
+
|
| 18 |
+
# Voice configurations for different speakers
|
| 19 |
+
VOICE_CONFIGS = {
|
| 20 |
+
"2_speakers": [
|
| 21 |
+
{"name": "Alex", "voice": "en-US-AriaNeural", "gender": "female"},
|
| 22 |
+
{"name": "Brian", "voice": "en-US-GuyNeural", "gender": "male"}
|
| 23 |
+
],
|
| 24 |
+
"3_speakers": [
|
| 25 |
+
{"name": "Sarah", "voice": "en-US-JennyNeural", "gender": "female"},
|
| 26 |
+
{"name": "Mike", "voice": "en-US-BrandonNeural", "gender": "male"},
|
| 27 |
+
{"name": "Emma", "voice": "en-US-AriaNeural", "gender": "female"}
|
| 28 |
+
],
|
| 29 |
+
"4_speakers": [
|
| 30 |
+
{"name": "Sarah", "voice": "en-US-JennyNeural", "gender": "female"},
|
| 31 |
+
{"name": "Mike", "voice": "en-US-BrandonNeural", "gender": "male"},
|
| 32 |
+
{"name": "Emma", "voice": "en-US-AriaNeural", "gender": "female"},
|
| 33 |
+
{"name": "David", "voice": "en-US-GuyNeural", "gender": "male"}
|
| 34 |
+
]
|
| 35 |
+
}
|
| 36 |
+
|
| 37 |
+
# Initialize Gemini client
|
| 38 |
+
client = None
|
| 39 |
+
|
| 40 |
+
def init_gemini(api_key):
|
| 41 |
+
"""Initialize Gemini client with API key"""
|
| 42 |
+
global client
|
| 43 |
+
if api_key and api_key.strip():
|
| 44 |
+
try:
|
| 45 |
+
genai.configure(api_key=api_key)
|
| 46 |
+
client = genai.GenerativeModel('gemini-1.5-flash')
|
| 47 |
+
return "✅ Gemini API connected successfully!"
|
| 48 |
+
except Exception as e:
|
| 49 |
+
return f"❌ Gemini API error: {str(e)}"
|
| 50 |
+
return "ℹ️ Add Gemini API key for AI-powered conversations"
|
| 51 |
+
|
| 52 |
+
def generate_with_gtts(text, filename):
|
| 53 |
+
"""Generate speech using Google's gTTS"""
|
| 54 |
+
try:
|
| 55 |
+
tts = gTTS(text=text, lang='en', slow=False)
|
| 56 |
+
tts.save(filename)
|
| 57 |
+
return filename, None
|
| 58 |
+
except Exception as e:
|
| 59 |
+
return None, f"gTTS Error: {str(e)}"
|
| 60 |
+
|
| 61 |
+
def generate_with_pyttsx3(text, filename):
|
| 62 |
+
"""Generate speech using system's TTS engine"""
|
| 63 |
+
try:
|
| 64 |
+
engine = pyttsx3.init()
|
| 65 |
+
engine.setProperty('rate', 180)
|
| 66 |
+
engine.setProperty('volume', 0.9)
|
| 67 |
+
|
| 68 |
+
voices = engine.getProperty('voices')
|
| 69 |
+
if voices:
|
| 70 |
+
for voice in voices:
|
| 71 |
+
if 'female' in voice.name.lower() or 'zira' in voice.name.lower():
|
| 72 |
+
engine.setProperty('voice', voice.id)
|
| 73 |
+
break
|
| 74 |
+
|
| 75 |
+
engine.save_to_file(text, filename)
|
| 76 |
+
engine.runAndWait()
|
| 77 |
+
return filename, None
|
| 78 |
+
except Exception as e:
|
| 79 |
+
return None, f"pyttsx3 Error: {str(e)}"
|
| 80 |
+
|
| 81 |
+
async def generate_with_edge_tts(text, voice, filename):
|
| 82 |
+
"""Generate speech using Microsoft Edge TTS with specific voice"""
|
| 83 |
+
if not EDGE_TTS_AVAILABLE:
|
| 84 |
+
return None, "Edge TTS not available"
|
| 85 |
+
|
| 86 |
+
try:
|
| 87 |
+
communicate = edge_tts.Communicate(text, voice)
|
| 88 |
+
# Save as MP3 since that's Edge TTS default format
|
| 89 |
+
mp3_filename = filename.replace('.wav', '.mp3')
|
| 90 |
+
await communicate.save(mp3_filename)
|
| 91 |
+
return mp3_filename, None
|
| 92 |
+
except Exception as e:
|
| 93 |
+
return None, f"Edge TTS Error: {str(e)}"
|
| 94 |
+
|
| 95 |
+
def generate_podcast_script(text, speaker_count, use_gemini):
|
| 96 |
+
"""Generate a podcast script with multiple speakers"""
|
| 97 |
+
if use_gemini and client:
|
| 98 |
+
try:
|
| 99 |
+
voice_config = VOICE_CONFIGS[f"{speaker_count}_speakers"]
|
| 100 |
+
speaker_names = [config["name"] for config in voice_config]
|
| 101 |
+
|
| 102 |
+
prompt = f"""Create an engaging podcast conversation between {speaker_count} hosts: {', '.join(speaker_names)}.
|
| 103 |
+
|
| 104 |
+
Transform this text into a natural conversation where each speaker contributes meaningfully.
|
| 105 |
+
|
| 106 |
+
Guidelines:
|
| 107 |
+
- Make it sound like a real podcast discussion
|
| 108 |
+
- Each speaker should have distinct perspectives
|
| 109 |
+
- Include natural transitions and interactions
|
| 110 |
+
- Keep it under 2000 characters total
|
| 111 |
+
- Use speaker names clearly (e.g., "Sarah: Hello everyone...")
|
| 112 |
+
|
| 113 |
+
Original text: {text[:2500]}
|
| 114 |
+
|
| 115 |
+
Format the output with clear speaker labels like:
|
| 116 |
+
{speaker_names[0]}: [text]
|
| 117 |
+
{speaker_names[1] if len(speaker_names) > 1 else speaker_names[0]}: [text]
|
| 118 |
+
etc."""
|
| 119 |
+
|
| 120 |
+
response = client.generate_content(prompt)
|
| 121 |
+
return response.text
|
| 122 |
+
except Exception as e:
|
| 123 |
+
return f"AI generation failed: {str(e)}. Using original text."
|
| 124 |
+
|
| 125 |
+
# Fallback: simple text with speaker distribution
|
| 126 |
+
return text[:1500] + ("..." if len(text) > 1500 else "")
|
| 127 |
+
|
| 128 |
+
def parse_script_for_speakers(script, speaker_count):
|
| 129 |
+
"""Parse the script to extract speaker parts"""
|
| 130 |
+
try:
|
| 131 |
+
voice_config = VOICE_CONFIGS[f"{speaker_count}_speakers"]
|
| 132 |
+
speaker_names = [config["name"] for config in voice_config]
|
| 133 |
+
|
| 134 |
+
parts = []
|
| 135 |
+
lines = script.split('\n')
|
| 136 |
+
current_speaker = 0
|
| 137 |
+
current_text = ""
|
| 138 |
+
|
| 139 |
+
# First, try to find explicit speaker labels
|
| 140 |
+
for line in lines:
|
| 141 |
+
line = line.strip()
|
| 142 |
+
if not line:
|
| 143 |
+
continue
|
| 144 |
+
|
| 145 |
+
# Check if line starts with a speaker name
|
| 146 |
+
speaker_found = False
|
| 147 |
+
for i, name in enumerate(speaker_names):
|
| 148 |
+
if line.lower().startswith(f"{name.lower()}:"):
|
| 149 |
+
if current_text.strip():
|
| 150 |
+
parts.append((current_text.strip(), current_speaker))
|
| 151 |
+
current_speaker = i
|
| 152 |
+
current_text = line[len(name)+1:].strip()
|
| 153 |
+
speaker_found = True
|
| 154 |
+
break
|
| 155 |
+
|
| 156 |
+
if not speaker_found:
|
| 157 |
+
current_text += " " + line
|
| 158 |
+
|
| 159 |
+
if current_text.strip():
|
| 160 |
+
parts.append((current_text.strip(), current_speaker))
|
| 161 |
+
|
| 162 |
+
# If no explicit speakers were found, intelligently distribute text
|
| 163 |
+
if not parts or len(parts) < 2:
|
| 164 |
+
print(f"No explicit speakers found, distributing text among {speaker_count} speakers")
|
| 165 |
+
parts = []
|
| 166 |
+
|
| 167 |
+
# Split into sentences and distribute
|
| 168 |
+
sentences = []
|
| 169 |
+
for delimiter in ['. ', '! ', '? ']:
|
| 170 |
+
if delimiter in script:
|
| 171 |
+
sentences = script.split(delimiter)
|
| 172 |
+
# Add back the delimiter except for the last sentence
|
| 173 |
+
for i in range(len(sentences) - 1):
|
| 174 |
+
sentences[i] += delimiter.strip()
|
| 175 |
+
break
|
| 176 |
+
|
| 177 |
+
if not sentences:
|
| 178 |
+
sentences = [script]
|
| 179 |
+
|
| 180 |
+
# Remove empty sentences
|
| 181 |
+
sentences = [s.strip() for s in sentences if s.strip()]
|
| 182 |
+
|
| 183 |
+
if len(sentences) >= speaker_count:
|
| 184 |
+
# Distribute sentences among speakers
|
| 185 |
+
sentences_per_speaker = len(sentences) // speaker_count
|
| 186 |
+
remainder = len(sentences) % speaker_count
|
| 187 |
+
|
| 188 |
+
start_idx = 0
|
| 189 |
+
for i in range(speaker_count):
|
| 190 |
+
# Give extra sentences to first speakers if there's remainder
|
| 191 |
+
num_sentences = sentences_per_speaker + (1 if i < remainder else 0)
|
| 192 |
+
|
| 193 |
+
if start_idx < len(sentences):
|
| 194 |
+
end_idx = min(start_idx + num_sentences, len(sentences))
|
| 195 |
+
speaker_sentences = sentences[start_idx:end_idx]
|
| 196 |
+
|
| 197 |
+
if speaker_sentences:
|
| 198 |
+
speaker_text = ' '.join(speaker_sentences)
|
| 199 |
+
parts.append((speaker_text, i))
|
| 200 |
+
print(f"Speaker {speaker_names[i]}: {len(speaker_sentences)} sentences")
|
| 201 |
+
|
| 202 |
+
start_idx = end_idx
|
| 203 |
+
else:
|
| 204 |
+
# If we have fewer sentences than speakers, alternate between first two speakers
|
| 205 |
+
for i, sentence in enumerate(sentences):
|
| 206 |
+
speaker_idx = i % min(speaker_count, 2) # Alternate between first 2 speakers
|
| 207 |
+
parts.append((sentence, speaker_idx))
|
| 208 |
+
|
| 209 |
+
# Ensure we have content and speakers are properly assigned
|
| 210 |
+
if not parts:
|
| 211 |
+
parts = [(script, 0)]
|
| 212 |
+
|
| 213 |
+
# Print debug info
|
| 214 |
+
print(f"Generated {len(parts)} parts for {speaker_count} speakers:")
|
| 215 |
+
for i, (text, speaker_idx) in enumerate(parts):
|
| 216 |
+
speaker_name = speaker_names[speaker_idx]
|
| 217 |
+
print(f" Part {i+1}: {speaker_name} - {text[:60]}...")
|
| 218 |
+
|
| 219 |
+
return parts
|
| 220 |
+
|
| 221 |
+
except Exception as e:
|
| 222 |
+
print(f"Error parsing script: {e}")
|
| 223 |
+
return [(script, 0)]
|
| 224 |
+
|
| 225 |
+
async def generate_multi_speaker_audio(script_parts, speaker_count):
|
| 226 |
+
"""Generate multi-speaker podcast audio"""
|
| 227 |
+
if not EDGE_TTS_AVAILABLE:
|
| 228 |
+
return None, "Edge TTS not available for multi-speaker"
|
| 229 |
+
|
| 230 |
+
try:
|
| 231 |
+
voice_config = VOICE_CONFIGS[f"{speaker_count}_speakers"]
|
| 232 |
+
audio_files = []
|
| 233 |
+
|
| 234 |
+
print(f"Generating audio for {len(script_parts)} parts with {speaker_count} speakers")
|
| 235 |
+
|
| 236 |
+
for i, (speaker_text, speaker_idx) in enumerate(script_parts):
|
| 237 |
+
voice = voice_config[speaker_idx]["voice"]
|
| 238 |
+
speaker_name = voice_config[speaker_idx]["name"]
|
| 239 |
+
temp_filename = f"temp_speaker_{i}_{speaker_name}_{uuid4().hex[:8]}.mp3"
|
| 240 |
+
|
| 241 |
+
print(f"Part {i+1}: {speaker_name} ({voice}) says: {speaker_text[:50]}...")
|
| 242 |
+
|
| 243 |
+
result, error = await generate_with_edge_tts(speaker_text, voice, temp_filename)
|
| 244 |
+
if result:
|
| 245 |
+
audio_files.append(temp_filename)
|
| 246 |
+
print(f"✅ Generated audio for {speaker_name}")
|
| 247 |
+
else:
|
| 248 |
+
print(f"❌ Error generating voice for {speaker_name}: {error}")
|
| 249 |
+
# Cleanup and return error
|
| 250 |
+
for f in audio_files:
|
| 251 |
+
try:
|
| 252 |
+
os.unlink(f)
|
| 253 |
+
except:
|
| 254 |
+
pass
|
| 255 |
+
return None, f"Error generating voice for {speaker_name}: {error}"
|
| 256 |
+
|
| 257 |
+
# Combine all audio files
|
| 258 |
+
if len(audio_files) > 1:
|
| 259 |
+
print(f"Combining {len(audio_files)} audio files...")
|
| 260 |
+
combined_audio = AudioSegment.empty()
|
| 261 |
+
|
| 262 |
+
for i, audio_file in enumerate(audio_files):
|
| 263 |
+
try:
|
| 264 |
+
# Load the audio segment - auto-detect format
|
| 265 |
+
segment = AudioSegment.from_file(audio_file)
|
| 266 |
+
|
| 267 |
+
# Add the segment to combined audio
|
| 268 |
+
combined_audio += segment
|
| 269 |
+
|
| 270 |
+
# Add a small pause between speakers (0.5 seconds)
|
| 271 |
+
if i < len(audio_files) - 1: # Don't add pause after last segment
|
| 272 |
+
pause = AudioSegment.silent(duration=500) # 500ms pause
|
| 273 |
+
combined_audio += pause
|
| 274 |
+
|
| 275 |
+
print(f"✅ Added segment {i+1}")
|
| 276 |
+
except Exception as e:
|
| 277 |
+
print(f"❌ Error processing audio file {audio_file}: {e}")
|
| 278 |
+
|
| 279 |
+
# Save combined audio
|
| 280 |
+
output_filename = f"combined_podcast_{uuid4().hex[:8]}.wav"
|
| 281 |
+
combined_audio.export(output_filename, format="wav")
|
| 282 |
+
|
| 283 |
+
# Cleanup temporary files
|
| 284 |
+
for f in audio_files:
|
| 285 |
+
try:
|
| 286 |
+
os.unlink(f)
|
| 287 |
+
print(f"🗑️ Cleaned up {f}")
|
| 288 |
+
except:
|
| 289 |
+
pass
|
| 290 |
+
|
| 291 |
+
print(f"✅ Combined audio saved as {output_filename}")
|
| 292 |
+
return output_filename, None
|
| 293 |
+
|
| 294 |
+
elif len(audio_files) == 1:
|
| 295 |
+
# Single audio file, just return it
|
| 296 |
+
return audio_files[0], None
|
| 297 |
+
else:
|
| 298 |
+
return None, "No audio files generated"
|
| 299 |
+
|
| 300 |
+
except Exception as e:
|
| 301 |
+
print(f"❌ Multi-speaker generation error: {str(e)}")
|
| 302 |
+
return None, f"Multi-speaker generation error: {str(e)}"
|
| 303 |
+
|
| 304 |
+
def create_podcast(text, use_gemini, tts_engine, speaker_count, progress=gr.Progress()):
|
| 305 |
+
"""Main function to create podcast from text with multiple speakers"""
|
| 306 |
+
try:
|
| 307 |
+
progress(0.1, "Starting processing...")
|
| 308 |
+
|
| 309 |
+
if not text.strip():
|
| 310 |
+
return None, "❌ Please enter some text first!", ""
|
| 311 |
+
|
| 312 |
+
progress(0.3, "Generating podcast script...")
|
| 313 |
+
podcast_script = generate_podcast_script(text, speaker_count, use_gemini)
|
| 314 |
+
|
| 315 |
+
progress(0.5, "Parsing script for speakers...")
|
| 316 |
+
script_parts = parse_script_for_speakers(podcast_script, speaker_count)
|
| 317 |
+
|
| 318 |
+
progress(0.7, "Generating audio...")
|
| 319 |
+
|
| 320 |
+
# Generate audio based on engine choice
|
| 321 |
+
with tempfile.NamedTemporaryFile(suffix=".wav", delete=False) as tmp_file:
|
| 322 |
+
temp_filename = tmp_file.name
|
| 323 |
+
|
| 324 |
+
if tts_engine == "Multi-Speaker (Edge TTS)" and speaker_count > 1 and EDGE_TTS_AVAILABLE:
|
| 325 |
+
# Use Edge TTS for multi-speaker
|
| 326 |
+
loop = asyncio.new_event_loop()
|
| 327 |
+
asyncio.set_event_loop(loop)
|
| 328 |
+
try:
|
| 329 |
+
audio_file, error = loop.run_until_complete(
|
| 330 |
+
generate_multi_speaker_audio(script_parts, speaker_count)
|
| 331 |
+
)
|
| 332 |
+
finally:
|
| 333 |
+
loop.close()
|
| 334 |
+
elif tts_engine == "gTTS (Online)":
|
| 335 |
+
full_text = " ".join([part[0] for part in script_parts])
|
| 336 |
+
audio_file, error = generate_with_gtts(full_text, temp_filename)
|
| 337 |
+
else: # pyttsx3
|
| 338 |
+
full_text = " ".join([part[0] for part in script_parts])
|
| 339 |
+
audio_file, error = generate_with_pyttsx3(full_text, temp_filename)
|
| 340 |
+
|
| 341 |
+
if error:
|
| 342 |
+
return None, f"❌ {error}", podcast_script
|
| 343 |
+
|
| 344 |
+
progress(0.9, "Finalizing...")
|
| 345 |
+
|
| 346 |
+
# Read the generated audio file
|
| 347 |
+
with open(audio_file, 'rb') as f:
|
| 348 |
+
audio_data = f.read()
|
| 349 |
+
|
| 350 |
+
# Clean up
|
| 351 |
+
try:
|
| 352 |
+
os.unlink(audio_file)
|
| 353 |
+
except:
|
| 354 |
+
pass
|
| 355 |
+
|
| 356 |
+
progress(1.0, "Complete!")
|
| 357 |
+
return audio_data, "✅ Podcast generated successfully!", podcast_script
|
| 358 |
+
|
| 359 |
+
except Exception as e:
|
| 360 |
+
return None, f"❌ Audio generation failed: {str(e)}", ""
|
| 361 |
+
|
| 362 |
+
def get_speaker_info(speaker_count):
|
| 363 |
+
"""Get speaker information for display"""
|
| 364 |
+
if speaker_count == 1:
|
| 365 |
+
return "**Single Speaker Mode**: Solo narration with one voice"
|
| 366 |
+
|
| 367 |
+
voice_config = VOICE_CONFIGS[f"{speaker_count}_speakers"]
|
| 368 |
+
info = f"**{speaker_count} Speaker Mode**:\n"
|
| 369 |
+
|
| 370 |
+
for i, config in enumerate(voice_config):
|
| 371 |
+
info += f"🎤 **{config['name']}** ({config['gender']} voice)\n"
|
| 372 |
+
|
| 373 |
+
return info
|
| 374 |
+
|
| 375 |
+
# Create the Gradio interface
|
| 376 |
+
def create_interface():
|
| 377 |
+
with gr.Blocks(title="🎙️ Multi-Speaker Podcast Generator", theme=gr.themes.Soft()) as demo:
|
| 378 |
+
gr.Markdown("# 🎙️ Multi-Speaker Podcast Generator")
|
| 379 |
+
gr.Markdown("Transform your text into engaging podcast conversations with multiple realistic voices!")
|
| 380 |
+
|
| 381 |
+
with gr.Row():
|
| 382 |
+
with gr.Column(scale=2):
|
| 383 |
+
# API Configuration
|
| 384 |
+
gr.Markdown("## 🔑 API Configuration")
|
| 385 |
+
api_key = gr.Textbox(
|
| 386 |
+
label="Gemini API Key (Optional)",
|
| 387 |
+
type="password",
|
| 388 |
+
placeholder="Enter your Google Gemini API key...",
|
| 389 |
+
info="Get a free key from https://aistudio.google.com/"
|
| 390 |
+
)
|
| 391 |
+
api_status = gr.Textbox(
|
| 392 |
+
label="API Status",
|
| 393 |
+
interactive=False,
|
| 394 |
+
value="ℹ️ Add Gemini API key for AI-powered conversations"
|
| 395 |
+
)
|
| 396 |
+
|
| 397 |
+
# Input Text
|
| 398 |
+
gr.Markdown("## 📝 Input Text")
|
| 399 |
+
input_text = gr.Textbox(
|
| 400 |
+
label="Your Content",
|
| 401 |
+
placeholder="Paste your article, blog post, or any text here...",
|
| 402 |
+
lines=6
|
| 403 |
+
)
|
| 404 |
+
|
| 405 |
+
# Configuration
|
| 406 |
+
gr.Markdown("## ⚙️ Configuration")
|
| 407 |
+
speaker_count = gr.Radio(
|
| 408 |
+
label="Number of Speakers",
|
| 409 |
+
choices=[1, 2, 3, 4],
|
| 410 |
+
value=2,
|
| 411 |
+
info="Choose how many voices for your podcast"
|
| 412 |
+
)
|
| 413 |
+
|
| 414 |
+
use_gemini = gr.Checkbox(
|
| 415 |
+
label="Use AI for conversation generation",
|
| 416 |
+
value=True,
|
| 417 |
+
info="Creates natural conversations (requires API key)"
|
| 418 |
+
)
|
| 419 |
+
|
| 420 |
+
tts_engine = gr.Radio(
|
| 421 |
+
label="Voice Engine",
|
| 422 |
+
choices=[
|
| 423 |
+
"Multi-Speaker (Edge TTS)",
|
| 424 |
+
"gTTS (Online)",
|
| 425 |
+
"pyttsx3 (Offline)"
|
| 426 |
+
],
|
| 427 |
+
value="Multi-Speaker (Edge TTS)" if EDGE_TTS_AVAILABLE else "gTTS (Online)",
|
| 428 |
+
info="Edge TTS provides the most realistic conversations"
|
| 429 |
+
)
|
| 430 |
+
|
| 431 |
+
# Generate Button
|
| 432 |
+
generate_btn = gr.Button(
|
| 433 |
+
"🎙️ Generate Podcast",
|
| 434 |
+
variant="primary",
|
| 435 |
+
size="lg"
|
| 436 |
+
)
|
| 437 |
+
|
| 438 |
+
with gr.Column(scale=1):
|
| 439 |
+
# Speaker Info
|
| 440 |
+
speaker_info = gr.Markdown(
|
| 441 |
+
get_speaker_info(2),
|
| 442 |
+
label="Speaker Information"
|
| 443 |
+
)
|
| 444 |
+
|
| 445 |
+
# Status and Results
|
| 446 |
+
status_msg = gr.HTML(
|
| 447 |
+
value="<div style='padding: 10px; background: #e3f2fd; border-radius: 5px; color: #1976d2;'>Ready to generate your podcast!</div>"
|
| 448 |
+
)
|
| 449 |
+
|
| 450 |
+
with gr.Row():
|
| 451 |
+
audio_output = gr.Audio(
|
| 452 |
+
label="Generated Podcast",
|
| 453 |
+
visible=False
|
| 454 |
+
)
|
| 455 |
+
download_btn = gr.DownloadButton(
|
| 456 |
+
"⬇️ Download Podcast",
|
| 457 |
+
visible=False
|
| 458 |
+
)
|
| 459 |
+
|
| 460 |
+
script_output = gr.Textbox(
|
| 461 |
+
label="Generated Script",
|
| 462 |
+
lines=8,
|
| 463 |
+
visible=False
|
| 464 |
+
)
|
| 465 |
+
|
| 466 |
+
# Event handlers
|
| 467 |
+
def update_status(message, success=True):
|
| 468 |
+
color = "#1976d2" if success else "#d32f2f"
|
| 469 |
+
bg_color = "#e3f2fd" if success else "#ffebee"
|
| 470 |
+
return f"<div style='padding: 10px; background: {bg_color}; border-radius: 5px; color: {color};'>{message}</div>"
|
| 471 |
+
|
| 472 |
+
def generate_podcast_wrapper(text, use_gemini, tts_engine, speaker_count, progress=gr.Progress()):
|
| 473 |
+
audio_data, message, script = create_podcast(text, use_gemini, tts_engine, speaker_count, progress)
|
| 474 |
+
|
| 475 |
+
status_html = update_status(message, success=audio_data is not None)
|
| 476 |
+
|
| 477 |
+
if audio_data:
|
| 478 |
+
# Save audio to temporary file
|
| 479 |
+
filename = f"podcast_{speaker_count}speakers_{uuid4().hex[:8]}.wav"
|
| 480 |
+
filepath = os.path.join(tempfile.gettempdir(), filename)
|
| 481 |
+
|
| 482 |
+
with open(filepath, 'wb') as f:
|
| 483 |
+
f.write(audio_data)
|
| 484 |
+
|
| 485 |
+
return [
|
| 486 |
+
status_html,
|
| 487 |
+
gr.Audio(value=filepath, visible=True),
|
| 488 |
+
gr.DownloadButton(value=filepath, visible=True),
|
| 489 |
+
gr.Textbox(value=script, visible=True)
|
| 490 |
+
]
|
| 491 |
+
else:
|
| 492 |
+
return [
|
| 493 |
+
status_html,
|
| 494 |
+
gr.Audio(visible=False),
|
| 495 |
+
gr.DownloadButton(visible=False),
|
| 496 |
+
gr.Textbox(visible=False)
|
| 497 |
+
]
|
| 498 |
+
|
| 499 |
+
# Connect events
|
| 500 |
+
api_key.change(init_gemini, inputs=api_key, outputs=api_status)
|
| 501 |
+
|
| 502 |
+
speaker_count.change(
|
| 503 |
+
get_speaker_info,
|
| 504 |
+
inputs=speaker_count,
|
| 505 |
+
outputs=speaker_info
|
| 506 |
+
)
|
| 507 |
+
|
| 508 |
+
generate_btn.click(
|
| 509 |
+
generate_podcast_wrapper,
|
| 510 |
+
inputs=[input_text, use_gemini, tts_engine, speaker_count],
|
| 511 |
+
outputs=[status_msg, audio_output, download_btn, script_output]
|
| 512 |
+
)
|
| 513 |
+
|
| 514 |
+
return demo
|
| 515 |
+
|
| 516 |
+
if __name__ == "__main__":
|
| 517 |
+
demo = create_interface()
|
| 518 |
+
demo.launch(
|
| 519 |
+
server_name="0.0.0.0",
|
| 520 |
+
server_port=7860,
|
| 521 |
+
share=False,
|
| 522 |
+
show_error=True
|
| 523 |
+
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|