import gradio as gr import os import wave import struct import math # Função para garantir que os arquivos existam (mesma lógica do jogo) def ensure_sounds(): if not os.path.exists("sounds"): os.makedirs("sounds") sounds = { "sounds/click.wav": 440, "sounds/correct.wav": 880, "sounds/wrong.wav": 220 } for filename, freq in sounds.items(): if not os.path.exists(filename): sample_rate = 44100 duration = 0.2 volume = 0.3 n_samples = int(sample_rate * duration) with wave.open(filename, 'w') as f: f.setnchannels(1) f.setsampwidth(2) f.setframerate(sample_rate) for i in range(n_samples): val = int(volume * 32767.0 * math.sin(2.0 * math.pi * freq * i / sample_rate)) f.writeframesraw(struct.pack('