FerrellSyntheticIntelligence
feat: audio ear, cognition modules, dream engine, vitalis IDE, test encoder
63dd1f4 | import argparse | |
| import sys | |
| import time | |
| from pathlib import Path | |
| from audio_ear.recorder import record_to_wav | |
| from audio_ear.feature_extractor import extract_features | |
| from hdc_encoder.encoder import encode | |
| from dream_engine.consolidator import DreamEngine | |
| from dream_engine.helix_memory import HelixMemory | |
| def log_success(intent: str, details: dict) -> None: | |
| from cognition.mind import VitalisMind | |
| mind = VitalisMind() | |
| mind.ledger.append({"type": "success", "intent": intent, "details": details}) | |
| def log_failure(intent: str, error: str) -> None: | |
| from cognition.mind import VitalisMind | |
| mind = VitalisMind() | |
| mind.ledger.append({"type": "failure", "intent": intent, "error": error}) | |
| def cmd_listen(args: argparse.Namespace) -> None: | |
| out_path = Path(args.output or f"/tmp/live_{int(time.time())}.wav") | |
| print(f"π Recording {args.duration}s -> {out_path}") | |
| record_to_wav(duration_sec=args.duration, out_path=out_path) | |
| mfcc, prosody = extract_features(out_path) | |
| hv = encode(mfcc, prosody) | |
| helix_path = Path.home() / ".vitalis_workspace" / "helix_memory.pkl" | |
| helix = HelixMemory(helix_path) | |
| dreamer = DreamEngine(helix) | |
| dreamer.ingest(hv, meta={"source": str(out_path), "prosody": prosody}) | |
| log_success("listen_live", {"file": str(out_path)}) | |
| print("β Ingested into DreamEngine.") | |
| def cmd_dream(args: argparse.Namespace) -> None: | |
| helix_path = Path.home() / ".vitalis_workspace" / "helix_memory.pkl" | |
| helix = HelixMemory(helix_path) | |
| dreamer = DreamEngine(helix) | |
| dreamer.dream(force=True) | |
| print("π€ Consolidation complete.") | |
| def build_parser() -> argparse.ArgumentParser: | |
| parser = argparse.ArgumentParser(prog="vitalis") | |
| sub = parser.add_subparsers(dest="command", required=True) | |
| p_listen = sub.add_parser("listen") | |
| p_listen.add_argument("-d", "--duration", type=int, default=10) | |
| p_listen.add_argument("-o", "--output", type=str) | |
| p_listen.set_defaults(func=cmd_listen) | |
| p_dream = sub.add_parser("dream") | |
| p_dream.set_defaults(func=cmd_dream) | |
| return parser | |
| def main(argv: list | None = None) -> None: | |
| parser = build_parser() | |
| args = parser.parse_args(argv) | |
| try: args.func(args) | |
| except Exception as exc: | |
| log_failure(intent=args.command, error=str(exc)) | |
| print(f"β Failed: {exc}", file=sys.stderr) | |
| sys.exit(1) | |
| if __name__ == "__main__": | |
| main() | |