API
<dxr-npc>
DeepXRLab AI NPC Component
Attributes
| Name | Description | Type | Default |
| api-origin | API Origin | string | "https://dxrainpc.aiware.io" |
| room-id | The value obtained through `POST /api/rooms` API call | string | "" |
| auto-connect | Whether the dxr-npc component should start connecting as soon as it is initialized. | boolean | false |
| spinner-size | Size of the loading spinner. | number | 64 |
| show-unmute | Show the unmute button when muted. | boolean | false |
Methods
| Name | Parameters | Description | Return |
| disconnect | | Disconnect from the server. Video and audio will be stopped.
Calling this method will immediately release server's resources and make reconnection impossible.
It is recommended to call it when leaving the page. | |
| updateRoom |
| Name | Description | Type |
| data | The parameters to update the room. (e.g. `{"npc": {"template": "woman"}}`) | string |
| Send room modification data to NPC Studio. The data should be a valid JSON string. | |
| speak |
| Name | Description | Type |
| msg | The text to speak | string |
| Let NPC speak the `msg` so that generated audio will be played with lip-sync animation. | |
| unmute | | Unmute the audio.
(When the webpage is initially loaded, it is muted by default, and it can be unmuted after user interaction.)
Call this method only after the user interaction, otherwise it will not work. | |
| connect | | Connect to the server. apiOrigin and roomId must be set before calling this method. | |
Events
| Name | Description |
| connected | Fires when the connection made (Video will start playing soon) |
| chat | Fires when a chat message received |
| warn | Fires when unexpected situation happened which can be ignored |
| error | Fires when something went wrong |