AACVoiceAPI
Defined in: AACVoiceAPI.ts:49
Constructors
Constructor
new AACVoiceAPI(): AACVoiceAPI;
Defined in: AACVoiceAPI.ts:55
Returns
AACVoiceAPI
Methods
addVoiceCommand()
addVoiceCommand(
name,
action,
options?): Promise`<CommandAddResult>`;
Defined in: AACVoiceAPI.ts:258
Adds a voice command to the system. Optionally fetches and registers synonyms from DataMuse API.
Parameters
| Parameter | Type |
|---|---|
|
|
| () => |
| { |
|
|
|
|
|
|
|
|
Returns
Promise<CommandAddResult>
Promise<CommandAddResult> Result object with command and synonym information
clearCommands()
clearCommands(): void;
Defined in: AACVoiceAPI.ts:314
Allows user to remove all game commands from system
Returns
void
clearSessionLogs()
clearSessionLogs(): void;
Defined in: AACVoiceAPI.ts:452
Clears all session logs. Removes all stored transcriptions, matched commands, and resets the log counter.
Note: This does NOT clear CommandHistory. Use displayCommandHistory() to access the separate command-only history.
Returns
void
Example
api.clearSessionLogs();
console.log('Session logs cleared');
displayCommandHistory()
displayCommandHistory(): void;
Defined in: AACVoiceAPI.ts:243
Displays all game Commands in a toggleable modal
Returns
void
downloadLogsAsJSON()
downloadLogsAsJSON(filename): void;
Defined in: AACVoiceAPI.ts:405
Downloads session logs as a JSON file (browser only). Triggers a browser download with the specified filename.
Note: This method only works in browser environments.
For Node.js, use getSessionLogsData() instead.
Parameters
| Parameter | Type | Default value | Description |
|---|---|---|---|
|
|
| Name of the file to download (default: 'aac-session-log.json') |
Returns
void
Example
// Download logs with default filename
api.downloadLogsAsJSON();
// Download with custom filename
api.downloadLogsAsJSON('my-session-2024-01-15.json');
exportSessionLogs()
exportSessionLogs(): string;
Defined in: AACVoiceAPI.ts:365
Exports all finalized session logs as a formatted JSON string.
Use this method to get comprehensive analytics data including:
- Full transcription text with timestamps
- Matched commands with confidence scores
- Synonym resolution details (library vs API)
- Error messages for failed command executions
- Speaker IDs (in multi-speaker mode)
Returns
string
Pretty-printed JSON string of all session logs
Example
const json = api.exportSessionLogs();
console.log(json);
getCommands()
getCommands(): string[] | [];
Defined in: AACVoiceAPI.ts:307
Allows user to see a list of all known game commands
Returns
string[] | []
a list of all known game commands
getMode()
getMode(): string;
Defined in: AACVoiceAPI.ts:323
Gets the current mode of operation
Returns
string
The current mode ('offline' or 'online'), or null if not initialized
getSessionLogs()
getSessionLogs(): LogEntry[];
Defined in: AACVoiceAPI.ts:435
Gets all finalized session logs. Returns detailed information about each transcription and matched commands.
Use Logger for comprehensive analytics data.
Use CommandHistory (via displayCommandHistory()) for simple UI display.
Returns
LogEntry[]
Array of finalized log entries
Example
const logs = api.getSessionLogs();
logs.forEach(log => {
console.log(`[${log.timestamp}] "${log.transcriptionText}"`);
console.log(` Matched ${log.matchedCommands.length} command(s)`);
});
getSessionLogsData()
getSessionLogsData(): LogEntry[];
Defined in: AACVoiceAPI.ts:383
Gets the raw log data as a JavaScript object. Useful for Node.js environments where manual file operations are needed.
Returns
LogEntry[]
Array of log entry objects
Example
// Node.js usage
const fs = require('fs');
const logData = api.getSessionLogsData();
fs.writeFileSync('session-logs.json', JSON.stringify(logData, null, 2));
getTranscriptionLogs()
getTranscriptionLogs(): string[];
Defined in: AACVoiceAPI.ts:235
Retrieves the full transcription history from the Whisper module.
Returns
string[]
An array of transcription log entries, each containing the transcribed text and its corresponding timestamp.
initiate()
initiate(config): Promise`<void>`;
Defined in: AACVoiceAPI.ts:82
Parameters
| Parameter | Type | Description |
|---|---|---|
| Configuration object used to initialize the API. |
Returns
Promise<void>
Throws
Throws an error if modelUrl is not provided when initiating in online mode.
initiateOnlineMultiSpeaker()
initiateOnlineMultiSpeaker(domainName): Promise`<void>`;
Defined in: AACVoiceAPI.ts:141
Initialize online mode with speaker separation
Parameters
| Parameter | Type |
|---|---|
|
|
Returns
Promise<void>
initiateOnlineSingleSpeaker()
initiateOnlineSingleSpeaker(domainName): Promise`<void>`;
Defined in: AACVoiceAPI.ts:129
Initialize online mode for single speaker