Skip to content

contrivancecompanychicago/charisma-sdk-unity

 
 

Repository files navigation

Charisma SDK for Unity

This Unity plugin is verified to work with projects using Unity versions 2021.3, 2022.1 and 2022.2. If you find the plugin also works in another version, feel free to submit a pull request to update this!

If you have any questions or need a hand, please reach out to us at hello@charisma.ai!

Getting started

Important: Before setting up the Charisma SDK for Unity, you’ll need to have created a web or game story (not an app story!), which requires a Charisma licence. Please visit the licencing docs on our website for more info!

If you haven’t already, go ahead and create an Unity project. Make sure you are using a version of the engine that is supported by this plugin.

Importing / Installing

Open Unity's Package Manager by heading to Window -> Package Manager. Click the plus icon, and select "Add package from Git URL". Enter https://github.com/charisma-ai/charisma-sdk-unity.git and press Add.

Unity will download the Charisma package into your project as a package. This includes an example scene and script which can be found by expanding the "Samples" drop-down when the package is highlighted in the Package Manager, and importing the "Example".

Usage

To create playthrough tokens, you’ll first need to find out your story ID, and optionally an API key and version of the story you want to play.

Story Id

The StoryId is the unique ID of the story that you want to play. To find this, navigate to your story on the Charisma website, and copy the ID number after /stories in the URL.

StoryId

Pass this in the CharismaTokenSettings object.

Story Version

This is the version of the story you want to play.

  • To play the latest published version, keep this at 0.

  • To play a specific, published, version of your story, set the number to that particular version.

  • To play the draft version, set the number to -1. To do this, you must also supply your API key.

Pass this in the CharismaTokenSettings object.

API key

An apiKey can be provided to play an unpublished version of your story that isn't available to the public, including the draft version. API keys do not expire (unless regenerated). Please make sure to not share the API key with anyone you do not trust, and strip the key from any public builds.

API key

Speech Options

To include voice audio in replies, either include SpeechOptions when creating the playthrough, or call setSpeechOptions at some later point.

Two options can be set:

Encoding

The output format of voice audio generated by Charisma. Supported audio formats include ogg, mp3 and wav.

Output type

Audio can be received both as an audio clip (buffer) and a URL. Out of the box, only the buffer option is supported. This is because audio can be both a byte[] and a string depending on what the server sends back, but msgpack only supports deserialising a single type. However, to support url instead, you can adjust byte[] to string in the Speech object in Events.cs, and then uncomment Url in the AudioOutput enum in Audio.cs.

About

Unity SDK for Charisma.ai

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • C# 99.1%
  • JavaScript 0.9%