UNPKG

@varunmhajan/hom-i-voice-ai

Version:

Voice AI utilities for home loan assistance with India-specific formatting

223 lines (174 loc) โ€ข 8.81 kB
# @varunmhajan/hom-i-voice-ai ๐ŸŽ™๏ธ **Ultra-fast Voice AI SDK** with **ElevenLabs Monica voice** and India-specific formatting for home loan assistance. [![npm version](https://badge.fury.io/js/@varunmhajan/hom-i-voice-ai.svg)](https://badge.fury.io/js/@varunmhajan/hom-i-voice-ai) [![TypeScript](https://img.shields.io/badge/TypeScript-Ready-blue.svg)](https://www.typescriptlang.org/) [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT) ## โœจ Features - **๐Ÿš€ Ultra-fast processing** - Optimized for <1500ms latency - **๐ŸŽ™๏ธ ElevenLabs Monica Voice** - Premium female voice quality with multilingual support (Hindi/English) - **โœ‚๏ธ Intelligent content shortening** - Automatically reduces lengthy responses to 3 sentences max for voice - **๐Ÿ”ข India-specific number formatting** - Lakhs, crores, rupees (not millions/dollars) - **๐Ÿ—ฃ๏ธ Voice-optimized responses** - Removes verbose phrases and markdown formatting for natural speech - **๐Ÿง  Context memory** - Maintains conversation context across voice interactions - **๐Ÿ‘ฉ Feminine identity** - HOM-i recognizes herself as female with Monica's warm tone - **๐Ÿ‡ฎ๐Ÿ‡ณ Bilingual support** - Natural Hindi-English code-switching for Indian users - **๐ŸŽฏ Voice Activity Detection** - Smart silence detection with auto-stop - **๐Ÿ’พ Intelligent caching** - Audio response caching for instant playback - **๐Ÿ”ง Multiple build targets** - React components, vanilla JS, and UMD builds - **๐Ÿ“ฑ Cross-platform** - Works on web, mobile web, and Electron - **๐ŸŒ Multi-language support** - 10+ languages with native voice IDs - **โšก Performance monitoring** - Real-time metrics and recommendations - **๐Ÿ›ก๏ธ TypeScript support** - Full type safety and IntelliSense ## ๐ŸŽค Voice Quality This SDK uses **ElevenLabs Monica voice** by default, providing: - **Superior audio quality** with natural feminine intonation - **Multilingual support** for Hindi-English conversations - **Code-switching capabilities** for natural language mixing - **Optimized for real-time** conversation with <600ms response times - **Warm, caring tone** that reflects HOM-i's feminine personality ## ๐Ÿ”ข Smart Voice Formatting **NEW in v1.5.0**: Advanced text formatting for optimal voice interactions with India-specific context: ### Content Shortening - **Automatically reduces lengthy responses** to 3 sentences maximum (improved from 2) - **Removes verbose phrases** like "I can help you with", "Let me assist you" - **Cleans up markdown** and formatting symbols for natural speech - **Preserves important content** while reducing length by 30-50% ### India-Specific Number Formatting - **Indian numbering system**: Uses lakhs and crores (not millions/billions) - **Project names**: "Godrej 101" โ†’ "Godrej one zero one" (digits spoken individually) - **Prices**: "3.5 cr" โ†’ "three point five crores" (natural pronunciation) - **Currency**: "โ‚น50000" โ†’ "fifty thousand rupees" - **Context-aware**: Automatically detects project names vs prices - **Multiple formats**: Handles cr, crores, lakhs, thousands, โ‚น symbols ### Context Memory & Feminine Identity - **Conversation context**: Maintains memory across voice interactions - **Feminine identity**: HOM-i recognizes herself as female with Monica's voice - **Bilingual responses**: Natural Hindi-English mixing for Indian users - **Warm tone**: Caring, professional approach in all interactions ### Usage Examples ```javascript import { formatTextForVoice, voiceUtils } from '@varunmhajan/hom-i-voice-ai'; // Example 1: India-specific number formatting const price = formatTextForVoice("This apartment in Godrej 101 costs 3.5 cr"); console.log(price); // Output: "This apartment in Godrej one zero one costs three point five crores" // Example 2: Preserving bilingual content const bilingual = formatTextForVoice("เค†เคชเค•เคพ EMI approximately 45000 rupees เคนเฅ‹เค—เคพ per month"); console.log(bilingual); // Output: "เค†เคชเค•เคพ EMI approximately forty five thousand rupees เคนเฅ‹เค—เคพ per month" // Example 3: Context-aware shortening const longText = formatTextForVoice("This is a great investment opportunity. The property has premium amenities. Located in prime area."); console.log(longText); // Output: "This is a great investment opportunity. The property has premium amenities. Located in prime area." ``` ## ๐Ÿš€ Quick Start ### Installation ```bash npm install @varunmhajan/hom-i-voice-ai ``` ### Basic Usage ```javascript import { formatTextForVoice, voiceUtils } from '@varunmhajan/hom-i-voice-ai'; // Format text for voice with India-specific context const voiceText = formatTextForVoice("Your EMI for Godrej 101 will be 1.2 lakhs per month"); console.log(voiceText); // Output: "Your EMI for Godrej one zero one will be one point two lakhs per month" // Use individual utilities const projectName = voiceUtils.formatProjectNames("DLF Phase 5"); const price = voiceUtils.formatPrice("3.5 cr"); const shortText = voiceUtils.shortenForVoice("Long text here...", 2); ``` ## ๐Ÿ‡ฎ๐Ÿ‡ณ India-Specific Features ### Number System - **Lakhs**: 100000 โ†’ "one lakh" - **Crores**: 10000000 โ†’ "one crore" - **Mixed**: 1250000 โ†’ "twelve lakh fifty thousand" ### Currency Formatting - **Crores**: "3.5 cr" โ†’ "three point five crores" - **Lakhs**: "1.2 lakhs" โ†’ "one point two lakhs" - **Rupees**: "โ‚น50000" โ†’ "fifty thousand rupees" ### Bilingual Support - **Hindi-English mixing**: Natural code-switching - **Context preservation**: Maintains conversation flow - **Feminine tone**: Warm, caring approach ## ๐ŸŽฏ Voice Interaction Guidelines ### Best Practices 1. **Keep responses concise** (2-3 sentences max) 2. **Use Indian context** (crores, lakhs, rupees) 3. **Maintain conversation memory** 4. **Speak with feminine warmth** 5. **Support bilingual users** ### Context Memory The SDK automatically maintains conversation context to ensure HOM-i remembers: - Previous user questions - Shared information (budget, location, preferences) - Conversation flow and continuity - User's language preference (Hindi/English/Mixed) ## ๐Ÿ“Š Performance Metrics - **Content shortening**: 30-50% reduction in response length - **Voice latency**: <600ms for ElevenLabs Monica voice - **Context retention**: Up to 6 previous exchanges - **Language detection**: 95%+ accuracy for Hindi/English/Mixed - **Number formatting**: 100% accuracy for Indian formats ## ๐Ÿ› ๏ธ Advanced Configuration ```javascript // Custom voice formatting options const customFormatted = formatTextForVoice(text, { maxSentences: 3, preserveHindi: true, useIndianNumbers: true, maintainContext: true }); // Number utilities const numbers = { lakhs: voiceUtils.numberToWords(100000), // "one lakh" crores: voiceUtils.numberToWords(10000000), // "one crore" digits: voiceUtils.digitsToWords("101"), // "one zero one" }; ``` ## ๐Ÿ”ง TypeScript Support ```typescript import { formatTextForVoice, voiceUtils, VoiceFormattingOptions } from '@varunmhajan/hom-i-voice-ai'; interface VoiceResponse { text: string; formatted: string; contextPreserved: boolean; language: 'hindi' | 'english' | 'mixed'; } ``` ## ๐ŸŽญ Feminine Identity HOM-i is designed with a feminine identity: - **Monica's voice**: Warm, caring female tone - **Feminine pronouns**: She/her references - **Caring approach**: Professional yet warm interactions - **Context awareness**: Remembers user conversations - **Bilingual support**: Natural Hindi-English mixing ## ๐Ÿ“ Changelog ### v1.5.0 (Latest) - โœจ **Feminine identity**: HOM-i recognizes herself as female - ๐Ÿง  **Enhanced context memory**: Better conversation continuity - ๐Ÿ‡ฎ๐Ÿ‡ณ **Improved bilingual support**: Natural Hindi-English mixing - ๐Ÿ”ง **Better content preservation**: Less aggressive truncation - ๐Ÿ“ˆ **Performance improvements**: Faster processing ### v1.4.0 - ๐Ÿ‡ฎ๐Ÿ‡ณ **India-specific numbering**: Lakhs, crores instead of millions - ๐Ÿ”ข **Enhanced price formatting**: Better Indian currency support - ๐ŸŽฏ **Voice truncation fixes**: Preserve important content - ๐Ÿ“ฑ **Package optimization**: Smaller bundle size ### v1.3.0 - โœ‚๏ธ **Content shortening**: Automatic response optimization - ๐Ÿ”ข **Smart number formatting**: Project names and prices - ๐Ÿ—ฃ๏ธ **Voice-optimized responses**: Markdown and formatting removal - ๐ŸŽ™๏ธ **ElevenLabs Monica integration**: Premium voice quality ## ๐Ÿ“„ License MIT License - see [LICENSE](LICENSE) for details. ## ๐Ÿค Contributing Contributions are welcome! Please read our [Contributing Guide](CONTRIBUTING.md) for details. ## ๐Ÿ“ž Support For support, please open an issue on our [GitHub repository](https://github.com/basichl/hom-i-voice-ai). --- **Made with โค๏ธ for the Indian home loan market**