""" ================================================================================ INTERACTIVE FACTORIZATION v1.4 EN ================================================================================ Main Developer: Marcos Autuori | Author: Autuori ================================================================================ """ import gradio as gr import time import wave import struct import math import os # --- CONFIGURATION & DATA --- GRID_NUMBERS = [ 10, 12, 14, 15, 16, 18, 20, 21, 24, 25, 27, 28, 30, 32, 35, 36, 40, 42, 45, 48, 50, 54, 56, 60, 63, 64, 70, 72, 80, 81, 90, 100 ] KEYBOARD_KEYS = [2, 3, 4, 5, 6, 7, 8, 9, 10] MAX_TIME = 150 # --- AUDIO GENERATION ENGINE --- def ensure_sounds(): if not os.path.exists("sounds"): os.makedirs("sounds") # Frequency mapping (Hz) sound_map = { "sounds/click.wav": 440, # A4 "sounds/correct.wav": 880, # A5 "sounds/wrong.wav": 220 # A3 } for filename, freq in sound_map.items(): if not os.path.exists(filename): sample_rate = 44100 duration = 0.15 if "click" not in filename else 0.05 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('