import gradio as gr import time import uuid from util import ( create_task_v3, get_task_result, ) IP_Dict = {} def generate_spongebob_voice_with_realtime_updates(text, word_num, request: gr.Request): """ Spongebob AI voice generation function with real-time status updates """ client_ip = request.client.host x_forwarded_for = dict(request.headers).get('x-forwarded-for') if x_forwarded_for: client_ip = x_forwarded_for if client_ip not in IP_Dict: IP_Dict[client_ip] = 0 IP_Dict[client_ip] += 1 print(f"client_ip: {client_ip}, count: {IP_Dict[client_ip]}") if IP_Dict[client_ip] > 5: msg = "You have reached the maximum number of requests" # Create "Get More Tries" button HTML get_more_tries_html = f"""
๐Ÿš€ Get More Tries for Free
""" yield msg, None, "", gr.update(value=get_more_tries_html, visible=True), "" return msg, None, "", gr.update(value=get_more_tries_html, visible=True), "" if not text or len(text.strip()) < 3: return "Text too short, please enter at least 3 characters", None, "No task information", gr.update(visible=False), "" try: task_type = "voice" # Create task task_result = create_task_v3(task_type, text.strip(), word_num, is_rewrite=False) if not task_result: return "Failed to create task", None, "Task creation failed", gr.update(visible=False), "" else: yield "Task created successfully", None, "Task creation successful", gr.update(visible=False), "" max_polls = 300 poll_interval = 1 task_url = f"https://trumpaivoice.net/task/{task_result['uuid']}" for i in range(max_polls): time.sleep(poll_interval) task = get_task_result(task_result['uuid']) # print(task, i, "get_task_result") if task.get('data', {}): status = task.get('data').get('status', '') text_final = task.get('data').get('text_final', '') if status in ['completed',]: voice_url = task.get('data').get('voice_url', '') print(voice_url, "===>voice_url") # ไธ‹่ฝฝ้Ÿณ้ข‘ๆ–‡ไปถๅˆฐๆœฌๅœฐไปฅ้ฟๅ…SSRFไฟๆŠค้—ฎ้ข˜ local_audio_path = voice_url # Create action buttons HTML action_buttons_html = f"""
๐ŸŽฌ Generate Video ๐Ÿ‘€ Check Generate Details
""" yield f"โœ… success!!!", local_audio_path, text_final, gr.update(value=action_buttons_html, visible=True), task_url return "โœ… Generation successful!", local_audio_path, "success", gr.update(value=action_buttons_html, visible=True), task_url elif status in ['failed', 'voice_error', 'no_credits']: yield "โŒ Generation failed!", None, None, gr.update(visible=False), "" return "โŒ Generation failed!", None, None, gr.update(visible=False), "" else: yield f"query {i} times, on processing, go to task page {task_url} to check status", None, text_final, gr.update(visible=False), task_url return "โŒ Generation failed!", None, None, gr.update(visible=False), "" except Exception as e: error_msg = f"Generation failed: {str(e)}" yield error_msg, None, f"โŒ Error message: {error_msg}", gr.update(visible=False), "" return error_msg, None, f"โŒ Error message: {error_msg}", gr.update(visible=False), "" # Create Gradio Interface with gr.Blocks(title="Spongebob AI Voice", theme=gr.themes.Soft()) as demo: # Main title - at the top gr.HTML("""

๐Ÿงฝ Spongebob AI Voice

""", padding=False) # Powered by link - small text gr.HTML("""

powered by trumpaivoice.net

""", padding=False) with gr.Row(): with gr.Column(scale=2): text_input = gr.Textbox( label="๐Ÿ“ Input Text", lines=4, placeholder="Enter what you want Spongebob to say...", value="I'm ready! I'm ready! This is a demonstration of the Spongebob AI Voice system with cheerful underwater vibes!" ) with gr.Column(scale=1): word_num_slider = gr.Slider( 20, 60, value=60, step=1, label="โฑ๏ธ Duration Limit" ) submit_btn = gr.Button( "๐Ÿš€ Generate Spongebob AI Voice", variant="primary", size="lg" ) with gr.Row(): status_output = gr.Textbox( label="๐Ÿ“Š Status", interactive=False, placeholder="Waiting for generation..." ) # Action buttons that will show after task completion with gr.Row(): action_links = gr.HTML(visible=False) with gr.Row(): audio_output = gr.Audio( label="๐ŸŽต Spongebob AI Voice", interactive=False ) with gr.Row(): task_info = gr.Textbox( label="๐Ÿ“‹ AI Rewritten Text with Underwater Fun", interactive=False, lines=12, placeholder="AI rewritten text with underwater fun will be shown here..." ) # Comprehensive introduction section gr.HTML("""

๐Ÿงฝ Experience the Fun of AI-Generated Spongebob Voice

Transform any text into authentic Spongebob speech with our cutting-edge AI voice synthesis technology. Whether you're creating content for entertainment, education, or social media, our advanced neural network captures Spongebob's distinctive cheerful style, optimistic intonation, and bubbly underwater patterns with remarkable accuracy.

๐ŸŽฌ Generate Spongebob AI Videos & More โ†’

๐ŸŽฏ Ultra-Realistic Voice

Our AI model is trained on thousands of hours of Spongebob episodes, capturing his unique vocal characteristics, cheerful pronunciation patterns, and enthusiastic speaking rhythm to deliver incredibly lifelike results.

โšก Lightning Fast Generation

Generate high-quality Spongebob AI voice clips in seconds, not minutes. Our optimized infrastructure ensures rapid processing while maintaining exceptional audio quality.

๐ŸŽจ Creative Content Creation

Perfect for memes, podcasts, educational content, entertainment videos, or any creative project that needs an authentic Spongebob voice performance.

๐ŸŽญ Try More Celebrity AI Voices

Explore our premium collection of celebrity AI voices! Our high-quality service delivers lightning-fast results with exceptional audio quality. Experience the best AI voice generation with our reliable and responsive platform.

๐ŸŒŸ Explore Celebrity Voices ๐ŸŽญ View Showcase

๐Ÿ’ก Pro Tips for Best Results

๐Ÿ“– Clear Text: Use proper punctuation and avoid special characters for optimal results.
โฑ๏ธ Length Matters: Shorter texts (20-60 words) typically produce the most natural-sounding results.
๐ŸŽฏ Spongebob Style: Text written in Spongebob's cheerful, enthusiastic style will sound more authentic and natural.
""", padding=False) # Powered by link - small text gr.HTML("""

Click spongebob ai voices showcase to see more videos

""", padding=False) # Hidden state to store task_url task_url_state = gr.State("") # Bind event submit_btn.click( generate_spongebob_voice_with_realtime_updates, inputs=[text_input, word_num_slider], outputs=[status_output, audio_output, task_info, action_links, task_url_state] ) if __name__ == "__main__": demo.launch()