UNPKG

mbz-voice-sdk

Version:

šŸŽ™ļø MBZ Voice SDK: Easily add voice recognition, Gemini-based AI replies, and TTS to any web app.

79 lines (61 loc) • 2.88 kB
#!/usr/bin/env node import fs from 'fs'; import path from 'path'; import readline from 'readline'; import { fileURLToPath } from 'url'; // Compatibility for ES module __dirname const __filename = fileURLToPath(import.meta.url); const __dirname = path.dirname(__filename); // CLI prompt setup const rl = readline.createInterface({ input: process.stdin, output: process.stdout }); // Template paths const templatesDir = path.join(__dirname, "templates"); const backendSrc = path.join(templatesDir, "backend"); const frontendSrc = path.join(templatesDir, "frontend"); // Helper to copy all files from one folder to another function copyFolderContents(srcDir, destDir) { if (!fs.existsSync(destDir)) fs.mkdirSync(destDir, { recursive: true }); const files = fs.readdirSync(srcDir); files.forEach((file) => { const srcFile = path.join(srcDir, file); const destFile = path.join(destDir, file); fs.copyFileSync(srcFile, destFile); }); } // Prompt user to scaffold rl.question("šŸ”§ Create MBZ Voice SDK project with backend and frontend? (y/n): ", (answer) => { if (answer.toLowerCase() === 'y') { copyFolderContents(backendSrc, path.resolve("backend")); console.log("āœ… backend/ created"); copyFolderContents(frontendSrc, path.resolve("frontend")); console.log("āœ… frontend/ created"); console.log("\nšŸŽ‰ MBZ Voice SDK setup complete!\n"); console.log("šŸ“ Created:"); console.log(" └── backend/ → FastAPI Gemini server"); console.log(" └── frontend/ → HTML + JS voice client\n"); console.log("šŸ”‘ Backend Setup:"); console.log("1ļøāƒ£ cd backend"); console.log(" pip install -r requirements.txt"); console.log(" cp .env.example .env # Add your Gemini API key from https://makersuite.google.com/app/apikey"); console.log(" uvicorn main:app --reload\n"); console.log("🌐 Frontend Setup:"); console.log("2ļøāƒ£ cd frontend"); console.log(" āš ļø Do NOT double-click index.html — it will block script.js due to CORS."); console.log("\nāœ… Recommended Way (Live Server):"); console.log(" - Open folder in VS Code"); console.log(" - Install 'Live Server' extension by Ritwick Dey"); console.log(" - Right-click index.html → Open with Live Server"); console.log("\nšŸ’” Or Use Python Server:"); console.log(" python -m http.server 8000"); console.log(" Open http://localhost:8000 in Chrome"); console.log("\nšŸ–¼ Make sure logo.png exists in /frontend and matches this file name exactly."); console.log("šŸŽ™ Click 'Start Talking' to test the AI voice SDK."); console.log("\nšŸš€ You're now ready to build with MBZ Voice SDK!"); } else { console.log("āŒ Cancelled."); } rl.close(); });