Skip to content

Commit

Permalink
Narrative design (#10)
Browse files Browse the repository at this point in the history
* TIVO temp fix

* custom actions code

* narrative endpoints and microphone access

* audio controls tested

* readme updated
  • Loading branch information
AirSurfer09 authored Nov 7, 2024
1 parent 57bc9d8 commit c88f3f2
Show file tree
Hide file tree
Showing 8 changed files with 97 additions and 14 deletions.
15 changes: 10 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,16 @@ import { GetResponseResponse } from "convai-web-sdk/dist/_proto/service/service_
// Initiate the convai client.
const convaiClient = useRef(null);
convaiClient.current = new ConvaiClient({
apiKey: string //Enter your API Key here,
characterId: string //Enter your Character ID,
enableAudio: boolean, //use false for text only.
sessionId: string //current conversation session. Can be used to retrieve chat history.
disableAudioGeneration: boolean false, //Optional parameter for chat only applications
apiKey: string, //Enter your API Key here,
characterId: string, //Enter your Character ID,
enableAudio: boolean, //No chareacter audio will be played but will be generated.
sessionId: string, //current conversation session. Can be used to retrieve chat history.
languageCode?: string,
textOnlyResponse?: boolean, //Optional parameter for chat only applications (No audio response from chareacter)
micUsage?: boolean, // Option parameter for no microphone usage and access
enableFacialData?: boolean, // Optional for viseme data generation used for lipsync and expression
faceModel?: 3,
narrativeTemplateKeysMap: Map<string, string>, //dynamically pass variables to the Narrative Design section and triggers
})

// Set a response callback. This may fire multiple times as response
Expand Down
2 changes: 1 addition & 1 deletion dist/cjs/convai-web-client.js

Large diffs are not rendered by default.

14 changes: 11 additions & 3 deletions dist/typings/convai_client.d.ts
Original file line number Diff line number Diff line change
@@ -1,17 +1,19 @@
import { GetResponseResponse } from '../Proto/service/service_pb';
import { ActionConfigParamsType, ConvaiGRPCClientConfigType } from './types';
import * as narrativeDesign from "./narrativeDesign";
export interface ConvaiClientParams {
apiKey: string;
characterId: string;
speaker: string;
speakerId: string;
enableAudio: boolean;
speakerId: string;
sessionId: string;
languageCode?: string;
disableAudioGeneration?: boolean;
enableFacialData?: boolean;
faceModel?: 0 | 1 | 2 | 3;
narrativeTemplateKeysMap: Map<string, string>;
textOnlyResponse?: boolean;
micUsage?: boolean;
}
export declare class ConvaiClient {
private sessionId;
Expand All @@ -31,6 +33,7 @@ export declare class ConvaiClient {
private disableAudioGeneration;
private enableFacialData;
private faceModel;
private micUsage?;
private narrativeTemplateKeysMap;
private actionConfig;
convaiConfig: ConvaiGRPCClientConfigType;
Expand All @@ -41,13 +44,18 @@ export declare class ConvaiClient {
setErrorCallback(fn: (type: string, statusMessage: string, status: string) => void): void;
sendTextChunk(text: string): void;
startAudioChunk(): void;
invokeTrigger(name: string, message?: string): void;
invokeTrigger(name: string | null, message?: string | null, preload?: boolean): void;
sendFeedback(interaction_id: string, character_id: string, session_id: string, thumbs_up: boolean, feedback_text: string): void;
endAudioChunk(): void;
toggleAudioVolume(): void;
getAudioVolume(): number;
stopCharacterAudio(): void;
onAudioPlay(fn: () => void): void;
onAudioStop(fn: () => void): void;
pauseAudio(): void;
resumeAudio(): void;
onAudioStateChange(fn: () => void): void;
playAudio(): void;
setActionConfig(actionConfig: ActionConfigParamsType): void;
}
export { narrativeDesign };
4 changes: 2 additions & 2 deletions dist/typings/convai_grpc_client.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@ import { ActionConfigParamsType } from './types';
export declare class ConvaiGRPCClient {
client: grpc.Client<any, any>;
private feedbackClient;
private apiKey;
apiKey: string;
private languageCode;
private sessionId;
private characterId;
characterId: string;
private speaker;
private inputMode;
private isStarted;
Expand Down
56 changes: 56 additions & 0 deletions dist/typings/narrativeDesign.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
declare const createSection: ({ objective, sectionName, behaviorTreeCode, btConstants, apiKey, characterId }: {
objective: any;
sectionName: any;
behaviorTreeCode?: any;
btConstants?: any;
apiKey: any;
characterId: any;
}) => Promise<any>;
declare const editSection: ({ updatedCharacterData, sectionId, apiKey, characterId }: {
updatedCharacterData: any;
sectionId: any;
apiKey: any;
characterId: any;
}) => Promise<any>;
declare const getSection: ({ sectionId, apiKey, characterId }: {
sectionId: any;
apiKey: any;
characterId: any;
}) => Promise<any>;
declare const listSection: ({ apiKey, characterId }: {
apiKey: any;
characterId: any;
}) => Promise<any>;
declare const deleteSection: ({ sectionId, apiKey, characterId }: {
sectionId: any;
apiKey: any;
characterId: any;
}) => Promise<any>;
declare const createTrigger: ({ triggerName, triggerMessage, destinationSection, apiKey, characterId }: {
triggerName: any;
triggerMessage: any;
destinationSection: any;
apiKey: any;
characterId: any;
}) => Promise<any>;
declare const updateTrigger: ({ triggerId, updatedTriggerData, apiKey, characterId }: {
triggerId: any;
updatedTriggerData: any;
apiKey: any;
characterId: any;
}) => Promise<any>;
declare const deleteTrigger: ({ triggerId, apiKey, characterId }: {
triggerId: any;
apiKey: any;
characterId: any;
}) => Promise<any>;
declare const getTrigger: ({ triggerId, apiKey, characterId }: {
triggerId: any;
apiKey: any;
characterId: any;
}) => Promise<any>;
declare const listTriggers: ({ apiKey, characterId }: {
apiKey: any;
characterId: any;
}) => Promise<any>;
export { createSection, editSection, getSection, listSection, deleteSection, createTrigger, updateTrigger, deleteTrigger, getTrigger, listTriggers };
16 changes: 15 additions & 1 deletion dist/typings/streaming_audio_player.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,30 @@ export declare class AudioPlayer {
private gainNode;
private isMuted;
private isPlaying;
private isPaused;
private pausedAt;
private startTime;
private currentBuffer;
private preloading;
private channels;
private sampleRate;
private onPlay;
private onStop;
private onStateChangeCallback;
constructor(sampleRate: number);
private initializeAudioContext;
preload(): void;
addChunk(data: Uint8Array, sampleRate?: number | null): void;
playAudio(): void;
private playNextChunk;
private playBuffer;
pauseAudio(): void;
resumeAudio(): void;
stopAudio(): void;
private notifyStateChange;
getVolume(): number;
setAudioVolume(volume: number): void;
stopAudio(): void;
onPlayStart(fn: () => void): void;
onPlayStop(fn: () => void): void;
onStateChange(fn: (state: string) => void): void;
}
2 changes: 1 addition & 1 deletion dist/umd/convai-web-client.umd.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"interactive web experiences",
"interactive avatars"
],
"version": "0.1.2",
"version": "0.1.3",
"homepage": "https://www.convai.com/",
"main": "dist/cjs/convai-web-client.js",
"browser": "dist/umd/convai-web-client.umd.js",
Expand Down

0 comments on commit c88f3f2

Please sign in to comment.