import gradio as gr import random from transformers import pipeline # Predefined words to check SPECIAL_WORDS = ['weather', 'sun', 'middle', 'summer', 'heat'] def generate_circular_text_design(word): """Generate a consistent but randomized text design for a word using CSS animations""" # Controlled randomization parameters font_sizes = [18, 20, 22, 24, 26] letter_spacings = [-3, -2, -4] skew_angles = [-25, -20, -15, -10, 0, 10, 15, 20, 25] # Random single color base_color = f'#{random.randint(0, 0xFFFFFF):06x}' # Fonts with a controlled set fonts = [ "'Dosis', sans-serif", "'Josefin Sans', sans-serif", "'Orbitron', sans-serif", "'Roboto Condensed', sans-serif" ] # Generate a unique animation name for CSS animation_name = f"animation_{random.randint(0, 10000)}" # Create HTML for each letter with dynamic styling letters = list(word) styled_letters = [] # Prepare CSS keyframes for animation keyframes = f""" @keyframes {animation_name} {{ 0% {{ transform: scale(1) rotate(0deg); color: {base_color}; }} 50% {{ transform: scale(1.2) rotate({random.randint(-20, 20)}deg); color: #{random.randint(0, 0xFFFFFF):06x}; }} 100% {{ transform: scale(1) rotate(0deg); color: {base_color}; }} }} """ for i, letter in enumerate(letters): style = { 'font-family': random.choice(fonts), 'line-height': '138%', 'font-size': f'{random.choice(font_sizes)}px', 'letter-spacing': f'{random.choice(letter_spacings)}px', 'text-shadow': '1px 2px 1px', 'transform': f'skew({random.choice(skew_angles)}deg)', 'margin-top': f'{random.uniform(-0.1, 0.1):.2f}cm', 'position': 'relative', 'top': f'{random.randint(3, 11)}px', 'color': base_color, 'animation': f'{animation_name} 2s ease-in-out infinite', } # Convert style to inline CSS style_str = '; '.join([f'{k}: {v}' for k, v in style.items()]) styled_letter = f'