{"id":22951306,"url":"https://github.com/agoraio-community/ten_ai_unityplugin","last_synced_at":"2026-05-06T03:31:58.831Z","repository":{"id":261889645,"uuid":"859965212","full_name":"AgoraIO-Community/TEN_AI_UnityPlugin","owner":"AgoraIO-Community","description":"A plugin helps quickly integrate TEN AI Agent into Unity","archived":false,"fork":false,"pushed_at":"2024-11-15T00:18:09.000Z","size":248,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2024-12-14T15:08:36.626Z","etag":null,"topics":["azure","openai","unity","voice-agent"],"latest_commit_sha":null,"homepage":"","language":"C#","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/AgoraIO-Community.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-09-19T15:23:45.000Z","updated_at":"2024-11-15T00:20:36.000Z","dependencies_parsed_at":"2024-11-09T03:26:50.139Z","dependency_job_id":"9a19b5e8-939e-4aab-9aea-022dd7cad173","html_url":"https://github.com/AgoraIO-Community/TEN_AI_UnityPlugin","commit_stats":null,"previous_names":["icywind/ten_ai_unityplugin","agoraio-community/ten_ai_unityplugin"],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AgoraIO-Community%2FTEN_AI_UnityPlugin","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AgoraIO-Community%2FTEN_AI_UnityPlugin/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AgoraIO-Community%2FTEN_AI_UnityPlugin/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AgoraIO-Community%2FTEN_AI_UnityPlugin/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/AgoraIO-Community","download_url":"https://codeload.github.com/AgoraIO-Community/TEN_AI_UnityPlugin/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":229717754,"owners_count":18113400,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["azure","openai","unity","voice-agent"],"created_at":"2024-12-14T15:08:45.939Z","updated_at":"2026-05-06T03:31:58.769Z","avatar_url":"https://github.com/AgoraIO-Community.png","language":"C#","funding_links":[],"categories":[],"sub_categories":[],"readme":"# TEN AI Agent Demo\n\n  \n\n![TENDemoIOS](https://github.com/user-attachments/assets/8ea3df82-61ba-4fa2-ba43-52b85040a27f)\n  \n\nThis app is powered by the technology of Realtime Communication, Realtime Transcription, a Large Language Model (LLM), and Text to Speech extensions. The TEN Framework makes the workflow super easy! The Unity Demo resembles the web demo and acts as the mobile frontend to the AI Agent. You may ask the Agent any general question.\n\nThe Plugin is exported as a reusable package that can be imported on any Agora RTC projects. Download the package and import into your project.\n\n\n## Prerequisites:\n\n- Agora Developer account\n- Agora Video SDK for Unity (v4.2.6 or up)\n- [TEN Frameworks Agent](https://github.com/TEN-framework/TEN-Agent)\n- Unity 2021 or up\n\n  \n\n### Implicit requirements by TEN Framework:\n\n- Text to Speech Support (API Key from [Azure Speech Service](https://portal.azure.com/#view/Microsoft_Azure_ProjectOxford/CognitiveServicesHub/~/SpeechServices))\n\n- LLM Support (e.g. [API key from OpenAI](https://platform.openai.com/api-keys))\n\n## Setups\n\n### TEN Agent Server\n\nFirst you should have gotten the TEN Agent working in your environment. You will just need the Server (ten_agent_dev) running for this application.\n\n![docker](https://github.com/user-attachments/assets/f292ad45-7be7-458a-b40a-46cce847809f)\n\nNote, the last verified commit is `ac7fd7a7a76d09d018513989d32b37ba7685e652`.\n\n  \n\n## To run this Demo\n0. Clone this project.\n1. Download and import the [Agora Video SDK](https://docs.agora.io/en/sdks?platform=unity) for Unity.\n2. Add both **TENEntryScreen** scene and **TENDemoScene** to the Build Settings. The TENEntryScreen scene should be on top.\n3. Fill out the information for Config input asset.\n![ten config](https://github.com/user-attachments/assets/4eab50db-a885-4d06-a349-64c3cadd188f)\n\n4. Play the demo on Editor or build it to device platform of your choice.  \n\n### Alternatively, Android apk\nGo to the Release section, download the apk file and experience the AI Agent.\n\n## To use the prefab for your own project\n0. Download the TENClientFramework.unitypackage file from the **Releases** section; import it to your project.\n1. Download and import the [Agora Video SDK](https://docs.agora.io/en/sdks?platform=unity) for Unity.\n2. Drag the prefabs into your project and use them connect to your controller code.\n\t- ChatController\n\t- SphereVisual\n\t- TENManager\n3. Follow the [Modification Steps](#modification-steps-to-an-existing-project) below.\n4. Fill out the information for Config input asset.\n\n5. Play the demo on Editor or build it to device platform of your choice. \n\n## Modification Steps to An Existing Project\n\n1. Pass Scriptable object to AppConfig:\n\n```csharp\nusing Agora.TEN.Client;\n```\n```csharp\n[SerializeField]\nTENConfigInput TENConfig; // input from Editor\n\n// Call this function in your Init step\nvoid  SetConfig()\n{\n\tAppConfig.Shared.SetValue(TENConfig);\n\t// obtain channel name before this call\n\tAppConfig.Shared.Channel = UtilFunctions.GenRandomString(\"agora_\", 5);\n}\n```\nNote you should provide a channel name in your app logic to use among the participanting users.  In this 1-to-1 chat project, we provide an util function GenRandomString() to ganerate the channel name.\n\nDon't forget to drop the TENConfigInput Asset into Inspector field for TENConfig. See demo picture in the previous section.\n\n\n2. Hook the prefabs up in your main logic:\n\n```csharp\n[SerializeField]\ninternal  IChatTextDisplay  TextDisplay;  // ChatController\n[SerializeField]\ninternal  TENSessionManager  TENSession;  // TENManager\n[SerializeField]\ninternal  SphereVisualizer  Visualizer;   // SphereVisual\n```\n\n3. Use `TENSession.GetToken()` to get token before joining channel\n```csharp\nasync void GetTokenAndJoin()\n{\n    AppConfig.Shared.RtcToken = await TENSession.GetToken();\n    JoinChannel();  // your join channel call that uses the rtc token\n}\n```\n\n4. In your initialization step, setup sound visualization, which will automatically configure the Agora RTC engine for audio data capture.\n\n```csharp\n\tVisualizer?.Init(RtcEngine);\n```\n\n5. Start the TEN session on OnJoinChannelSuccess()\n```csharp\n// _app is the instance of your controller class\n_app.TENSession.StartSession(connection.localUid);\n```\n\n6. Disable/Enable the sound visualizer, a component of a gameobject that represents the AI Agent:\n- Disable it during initialization, e.g. SetupUI() or Start()\n```csharp\n\tVisualizer?.gameObject.SetActive(false);\n```\n- Enable it when the AI Agent user joins the channel:\n```csharp\npublic override void OnUserJoined(RtcConnection connection, uint uid, int elapsed)\n{\n    if (uid == AppConfig.Shared.AgentUid) {\n        _app.Visualizer?.gameObject.SetActive(true);\n\t}\n}\n```\n\n7. Register handler OnStreamMessage:\n- SDK ver 4.4.0\n```csharp\npublic  override  void  OnStreamMessage(RtcConnection  connection, uint  remoteUid, int  streamId, byte[] data, ulong  length, ulong  sentTs)\n{\n\tstring  str = System.Text.Encoding.UTF8.GetString(data, 0, (int)length);\n\t_app.TextDisplay.ProcessTextData(remoteUid, str);\n\t_app.TextDisplay.DisplayChatMessages(_app.LogText.gameObject);\n}\n\n```\n- SDK ver 4.2.6\n```csharp\npublic override void OnStreamMessage(RtcConnection connection, uint remoteUid, int streamId, byte[] data, uint length, System.UInt64 sentTs)\n{\n    string str = System.Text.Encoding.UTF8.GetString(data, 0, (int)length);\n    _app.TextDisplay.ProcessTextData(remoteUid, str);\n    _app.TextDisplay.DisplayChatMessages(_app.LogText.gameObject);\n}\n\n```\n8. OnDestroy() or logic to stop.\n\n```csharp\nTENSession.StopSession();\n```\n\n## References\n\nFor reference, it is worthwhile to check out the following resources:\n\n* [TEN Framework docs](https://doc.theten.ai/)\n* [TEN IOS Client](https://github.com/AgoraIO-Community/TEN-AI-Demo-IOS)\n* [Agora SDK API references](https://api-ref.agora.io/en/voice-sdk/ios/4.x/documentation/agorartckit).\n\n\n  \n\n## License\n\n[MIT License](https://github.com/icywind/TEN-AI-Demo-IOS/blob/main/LICENSE)","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fagoraio-community%2Ften_ai_unityplugin","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fagoraio-community%2Ften_ai_unityplugin","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fagoraio-community%2Ften_ai_unityplugin/lists"}