0.1.4 • Published 11 months ago
@aiola/web-sdk-stt v0.1.4
@aiola/web-sdk-stt
Aiola Speech-To-Text JavaScript SDK
example code can be found here
Installation
npm install @aiola/web-sdk-stt
# or
yarn add @aiola/web-sdk-sttUsage
Node.js (CommonJS)
const { AiolaStreamingClient } = require("@aiola/web-sdk-stt");
const stt = new AiolaStreamingClient({
// configuration options
});Modern JavaScript (ES Modules)
import { AiolaStreamingClient } from "@aiola/web-sdk-stt";
const stt = new AiolaStreamingClient({
// configuration options
});Browser (Direct Usage)
<script type="importmap">
{
"imports": {
"@aiola/web-sdk-stt": "./node_modules/@aiola/web-sdk-stt/dist/bundle/index.js"
}
}
</script>API Documentation
npm install @aiola/web-sdk-sttimport {
AiolaStreamingClient,
AiolaSocketNamespace,
AiolaSocketConfig,
} from "@aiola/web-sdk-stt";
const client = new AiolaStreamingClient({
baseUrl: "https://your-aiola-endpoint.com",
namespace: AiolaSocketNamespace.EVENTS, // Available namespaces: EVENTS
bearer: "your-auth-token",
queryParams: {
flow_id: "your-flow-id",
execution_id: "your-execution-id",
lang_code: "en_US",
time_zone: "UTC",
},
// micConfig is optional - defaults to:
// micConfig: {
// sampleRate: 16000,
// chunkSize: 4096,
// channels: 1
// }
events: {
onTranscript: (data) => {
console.log("Transcript:", data);
},
onEvents: (data) => {
console.log("Event:", data);
},
onError: (error) => {
console.error("Error:", error);
},
onStartRecord: () => {
console.log("Recording started");
},
onStopRecord: () => {
console.log("Recording stopped");
},
},
});
// Connect to the service
client.connect();
// Or connect and start recording automatically
client.connect(true);Configuration Reference
AiolaSocketNamespace
enum AiolaSocketNamespace {
EVENTS = "/events",
}AiolaSocketConfig
interface AiolaSocketConfig {
baseUrl: string; // The base URL of the Aiola API
namespace: AiolaSocketNamespace; // The namespace to connect to
bearer: string; // Authentication token
queryParams: {
// Query parameters for the connection
flow_id: string; // The flow ID to use
execution_id: string; // Execution ID for the session
lang_code: string; // Language code (e.g., "en_US")
time_zone: string; // Time zone (e.g., "UTC")
[key: string]: string; // Additional custom parameters
};
micConfig?: {
// Optional microphone configuration
sampleRate: number; // Default: 16000
chunkSize: number; // Default: 4096
channels: number; // Default: 1
};
events: {
// Event handlers
onTranscript: (data: any) => void; // Called when transcript is received
onEvents: (data: any) => void; // Called for other events
onConnect?: () => void; // Called when connected
onStartRecord?: () => void; // Called when recording starts (only after permissions are granted)
onStopRecord?: () => void; // Called when recording stops (only if recording was started)
onKeyWordSet?: (keywords: string[]) => void; // Called when keywords are set
onError?: (error: AiolaSocketError) => void; // Called on errors, including permission denied
};
transports?: "polling" | "websocket" | "all"; // Transport method to use
}Development
# Install dependencies
npm install
# Build the package
npm run build
# Run tests
npm test
# Run tests in watch mode
npm run test:watchLicense
See LICENSE file for details.
Support
For any issues or questions regarding the aiOla STT SDK, please contact us