Make your game characters talk in minutes with next generation artificial intelligence. This package is still under active development and is not yet ready for production use.
This package uses the web socket protocol under the hood. To get started you will first need to install SocketIOUnity:
To do this, go to: Window -> Package Manager -> Click the (+) add package from git URL -> Paste:
https://github.com/itisnajim/SocketIOUnity.git
Then install the Carter Package! To do this, go to: Window -> Package Manager -> Click the (+) add package from git URL -> Paste:
https://github.com/Carter-Labs-Ltd/carter-unity.git
Getting started with Carter is easy. First configure your agent here. Once you've got your agent's API Key come back here and add Carter to your game as below.
using Carter;
public class MyExampleScript : MonoBehaviour
{
Agent mika;
// Define Event Handlers //
void onConnect(){
Debug.Log("Connected to agent!");
}
void onDisconnect(){
Debug.Log("Disconnected from agent!");
}
void onMessage(string message){
Debug.Log("Message from agent: " + message);
}
void onVoice(string audioId){
// Make your agent speak the response!
mika.say(audioId);
}
void Start()
{
mika = gameObject.AddComponent<Agent>();
mika.init("API_KEY", "PLAYER_ID", "https://dev-api.carterapi.com", onConnect, onDisconnect, onMessage, onVoice);
}
void Update()
{
// ... on button click etc
mika.send("Hello");
// ... OTHER OPTIONS
mika.connected // true/false
mika.connect(); // reconnect
mika.disconnect(); // disconnect
}
}
using Carter;
public class MyExampleScript : MonoBehaviour
{
Agent mika;
// Define Event Handlers //
void onConnect(){
Debug.Log("Connected to agent!");
}
void onDisconnect(){
Debug.Log("Disconnected from agent!");
}
void onMessage(string message){
Debug.Log("Message from agent: " + message);
}
void onVoice(string audioId){
// Make your agent speak the response!
mika.say(audioId);
}
void Start()
{
mika = gameObject.AddComponent<Agent>();
mika.init("API_KEY", "PLAYER_ID", "https://dev-api.carterapi.com", onConnect, onDisconnect, onMessage, onVoice);
mika.StartListening(); //activate microphone access
}
void Update()
{
if (Input.GetKey("space"))
{
// start recording audio (won't trigger more than once before stopRecording() is called)
mika.listen();
}
if (!Input.GetKey("space"))
{
// stop recording audio and send to agent
mika.sendAudio();
}
}
}
Join our awesome Discord community.
Follow us on TikTok
Binge & Learn on YouTube