The VmonsterRoom
instance provides a variety of methods to manage and control the interactions and functionalities within the virtual space.
These methods enable developers to automate tasks and enhance user engagement efficiently.
The following are the instance methods.
This method is used to connect to a VmonsterRoom
.
If the method operates successfully, the joined
event will be triggered.
The config parameter accepts an object of type JoinOptions.
Error Occurrence
joining
or joined
events have already occurred.This method requests the AI Avatar to speak based on the provided text or text stream. You can receive the AI Avatar’s video stream data based on the input text. You can optionally configure the background, position, and scale of the AI Avatar for each request. It supports standard text input as well as streaming input(AsyncIterable), allowing for real-time speech generation.
The config parameter accepts an object of type MessageConfig
, which is a union of the following: TextMessageConfig
and StreamMessageConfig
.
When speak() is called, the following steps occur sequentially.
The AIAvatarState
transitions to loading
.
When the AIAvatar begins speaking:
a. The aiavatar-start-speaking
event is triggered.
b. The AIAvatarState
transitions to speaking
.
When the AI Avatar finishes speaking:
a. The aiavatar-stop-speaking
event is triggered.
b. The AIAvatarState
transitions to idle
.
The AIAvatar’s speech text can be verified through the callback argument of the aiavatar-message
event.
Error Occurrence
RoomState
is not joined
when the method is called.AIAvatarState
is not idle
when the method is called.This method is requests the AI Avatar to stop speaking
You can request to when the AI Avatar is speaking.
After the request, the speaking stops after 1 ~ 2 seconds.
aiavatar-stop-speaking
event is triggered.AIAvatarState
transitions to idle.Error Occurrence:
AIAvatarState
is not speaking when the method is called.This method is used to exit the VmonsterRoom
.
Upon execution, the left
event is triggered immediately.
Error Occurrence
joined
event has occurred.This method adds an AI Avatar Video Element to the DOM.
It checks for the presence of a <video>
element with the id “aiavatar-video” and adds it if it doesn’t already exist.
Parent Element Determination:
Styling:
This method removes the AIAvatar Video Element from the DOM.
Note that even after the element is removed, the audio will continue to play.
Connects the user’s audio track. STT starts immediately.
This method mutes the user’s audio track.
The track remains connected, so STT can resume with minimal delay when the audio is unmuted again.
This method unpublishes the user’s audio track.
The track is disconnected, and STT can be restarted by unmuteUserAudio()
.
This method converts a voice Blob into text.
This converts audio to text in a non-real-time manner, separately from the user’s audio track connection.
Error Occurrence
joined
event has occurred.This method initiates audio recording using navigator.mediaDevices.getUserMedia. Use this when calling the non-real-time stt() method.
Error Occurrence:
This method stops the audio recording and returns the recorded audio as a Blob. Use this when calling the non-real-time stt() method.
Error Occurrence:
The VmonsterRoom
instance provides a variety of methods to manage and control the interactions and functionalities within the virtual space.
These methods enable developers to automate tasks and enhance user engagement efficiently.
The following are the instance methods.
This method is used to connect to a VmonsterRoom
.
If the method operates successfully, the joined
event will be triggered.
The config parameter accepts an object of type JoinOptions.
Error Occurrence
joining
or joined
events have already occurred.This method requests the AI Avatar to speak based on the provided text or text stream. You can receive the AI Avatar’s video stream data based on the input text. You can optionally configure the background, position, and scale of the AI Avatar for each request. It supports standard text input as well as streaming input(AsyncIterable), allowing for real-time speech generation.
The config parameter accepts an object of type MessageConfig
, which is a union of the following: TextMessageConfig
and StreamMessageConfig
.
When speak() is called, the following steps occur sequentially.
The AIAvatarState
transitions to loading
.
When the AIAvatar begins speaking:
a. The aiavatar-start-speaking
event is triggered.
b. The AIAvatarState
transitions to speaking
.
When the AI Avatar finishes speaking:
a. The aiavatar-stop-speaking
event is triggered.
b. The AIAvatarState
transitions to idle
.
The AIAvatar’s speech text can be verified through the callback argument of the aiavatar-message
event.
Error Occurrence
RoomState
is not joined
when the method is called.AIAvatarState
is not idle
when the method is called.This method is requests the AI Avatar to stop speaking
You can request to when the AI Avatar is speaking.
After the request, the speaking stops after 1 ~ 2 seconds.
aiavatar-stop-speaking
event is triggered.AIAvatarState
transitions to idle.Error Occurrence:
AIAvatarState
is not speaking when the method is called.This method is used to exit the VmonsterRoom
.
Upon execution, the left
event is triggered immediately.
Error Occurrence
joined
event has occurred.This method adds an AI Avatar Video Element to the DOM.
It checks for the presence of a <video>
element with the id “aiavatar-video” and adds it if it doesn’t already exist.
Parent Element Determination:
Styling:
This method removes the AIAvatar Video Element from the DOM.
Note that even after the element is removed, the audio will continue to play.
Connects the user’s audio track. STT starts immediately.
This method mutes the user’s audio track.
The track remains connected, so STT can resume with minimal delay when the audio is unmuted again.
This method unpublishes the user’s audio track.
The track is disconnected, and STT can be restarted by unmuteUserAudio()
.
This method converts a voice Blob into text.
This converts audio to text in a non-real-time manner, separately from the user’s audio track connection.
Error Occurrence
joined
event has occurred.This method initiates audio recording using navigator.mediaDevices.getUserMedia. Use this when calling the non-real-time stt() method.
Error Occurrence:
This method stops the audio recording and returns the recorded audio as a Blob. Use this when calling the non-real-time stt() method.
Error Occurrence: