@sociovate/samvaad
v1.0.0
Published
Samvaad — speech-to-intent SDK for React Native and Web apps
Readme
@sociovate/samvaad
Samvaad — voice-to-intent SDK for React Native and Web. Hold a button, speak a command in Hindi/Hinglish/English, get structured intent JSON.
Install
npm install @sociovate/samvaadQuick Start
import { VoiceSDK, VoiceButton } from '@sociovate/samvaad'
// 1. Init once at app startup
VoiceSDK.init({
apiKey: 'sk_test_...',
apiUrl: 'https://your-samvaad-api.railway.app',
language: 'hinglish',
intents: [
{
name: 'log_order',
description: 'Sales rep logs an order at a shop',
params: [
{ name: 'shop_name', type: 'string' },
{ name: 'items', type: 'array' },
{ name: 'payment', type: 'string', nullable: true }
]
}
]
})
// 2. Handle intents
VoiceSDK.onIntent(intent => {
console.log(intent.name, intent.params)
})
// 3. Drop button in UI
<VoiceButton />VoiceSDK.init(config)
| Field | Type | Required | Default | Description |
|---|---|---|---|---|
| apiKey | string | yes | — | Your API key |
| apiUrl | string | yes | — | Your deployed Samvaad API URL |
| language | string | yes | — | 'hinglish' | 'hi-IN' | 'en-IN' |
| intents | array | yes | — | Intent schema definitions |
| hints | string[] | no | [] | STT hint words |
| confidenceThreshold | number | no | 0.6 | Minimum confidence to fire intent |
| maxRetries | number | no | 3 | Network retry count |
| retryDelay | number | no | 1000 | Base ms between retries |
| timeout | number | no | 30000 | Request timeout in ms |
Callbacks
VoiceSDK.onIntent(intent => { /* intent.name, intent.params, intent.confidence */ })
VoiceSDK.onError(error => { /* error.code, error.message */ })
VoiceSDK.onLoading(state => { /* 'recording' | 'processing' */ })VoiceButton Props
| Prop | Type | Description |
|---|---|---|
| screen | string | Optional screen name for logging |
| disabled | bool | Disable the button |
| style | object | Custom styles |
| onPress | function | Called on press down |
| onRelease | function | Called on release |
Platform Support
- Web: uses MediaRecorder API (Chrome, Firefox, Safari 14.1+)
- React Native: uses
expo-av— addexpo-avandexpo-hapticsas dependencies
Error Codes
| Code | Cause |
|---|---|
| AUDIO_ERROR | Microphone permission denied or recording failed |
| NETWORK_ERROR | Samvaad API unreachable after retries |
| TIMEOUT | Request exceeded timeout |
| API_ERROR | API returned 4xx/5xx |
| INVALID_CONFIG | init() not called or invalid config |
