import gradio as gr import numpy as np import time from typing import Generator, Tuple def process_audio(audio: Tuple[int, np.ndarray]) -> Generator[np.ndarray, None, None]: """Process audio in real-time with shadow effects""" if audio is None: return sample_rate, audio_data = audio # Simulate real-time processing with shadow effect for i in range(0, len(audio_data), 1024): chunk = audio_data[i:i+1024] # Apply shadow effect (attenuate and delay simulation) shadow_effect = chunk * 0.7 if i > 512: shadow_effect += audio_data[i-512:i-512+len(chunk)] * 0.3 yield shadow_effect def get_audio_info(audio: Tuple[int, np.ndarray]) -> str: """Get audio information""" if audio is None: return "No audio detected" sample_rate, audio_data = audio duration = len(audio_data) / sample_rate return f"Sample Rate: {sample_rate} Hz\nDuration: {duration:.2f} seconds\nChannels: Mono" # Custom dark theme with shadow effects custom_dark_theme = gr.themes.Soft( primary_hue="purple", secondary_hue="indigo", neutral_hue="gray", font=gr.themes.GoogleFont("Inter"), text_size="lg", spacing_size="lg", radius_size="md" ).set( body_background_fill="*neutral_950", block_background_fill="*neutral_900", block_border_width="1px", block_border_color="*neutral_800", block_shadow="0 4px 6px -1px rgba(0, 0, 0, 0.3), 0 2px 4px -1px rgba(0, 0, 0, 0.2)", block_title_text_weight="600", block_title_text_color="*neutral_50", block_label_text_color="*neutral_300", input_background_fill="*neutral_800", input_border_color="*neutral_700", input_text_color="*neutral_100", button_primary_background_fill="*primary_600", button_primary_background_fill_hover="*primary_700", button_primary_text_color="white", button_secondary_background_fill="*neutral_800", button_secondary_background_fill_hover="*neutral_700", button_secondary_text_color="*neutral_100", prose_text_color="*neutral_200", prose_header_text_color="*neutral_50" ) # Custom CSS for additional shadow effects custom_css = """ /* Enhanced shadow effects */ .gradio-container { background: linear-gradient(135deg, #0f0f0f 0%, #1a1a1a 100%); } /* Card shadow effects */ .shadow-card { box-shadow: 0 10px 25px rgba(0, 0, 0, 0.5), 0 6px 10px rgba(0, 0, 0, 0.3); border: 1px solid #333; background: rgba(30, 30, 30, 0.8); backdrop-filter: blur(10px); } /* Button shadow effects */ .btn-shadow { box-shadow: 0 4px 15px rgba(139, 92, 246, 0.3), 0 2px 4px rgba(0, 0, 0, 0.2); transition: all 0.3s ease; } .btn-shadow:hover { box-shadow: 0 6px 20px rgba(139, 92, 246, 0.4), 0 3px 6px rgba(0, 0, 0, 0.3); transform: translateY(-2px); } /* Audio component shadow */ audio { box-shadow: 0 8px 20px rgba(0, 0, 0, 0.4); border-radius: 8px; } /* Text shadow for headings */ h1, h2, h3 { text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.5); } /* Glow effect for active elements */ .glow { box-shadow: 0 0 20px rgba(139, 92, 246, 0.5), 0 0 40px rgba(139, 92, 246, 0.3); } /* Animation for recording */ @keyframes pulse { 0% { box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.7); } 70% { box-shadow: 0 0 0 10px rgba(239, 68, 68, 0); } 100% { box-shadow: 0 0 0 0 rgba(239, 68, 68, 0); } } .recording { animation: pulse 2s infinite; } """ with gr.Blocks() as demo: # Header with shadow effect gr.HTML("""
Experience audio with dynamic shadow effects in real-time
Built with anycoderđ´ Status: Ready
đ´ Status: Ready
đĸ Status: Processing | Volume: {volume:.1f}%
đī¸ Real-time voice processing with shadow effects | Dark mode interface