EchoTrio
 
Loading...
Searching...
No Matches
Authentication.cs
Go to the documentation of this file.
1using OpenAI;
2using ElevenLabs;
3using UnityEngine;
4using Microsoft.Extensions.Configuration;
5
6namespace EchoTrio {
7 /// Helper class to load the authentication file and retrieve API keys.
8 public class Authentication {
9 private const string FileName = "Authentication.ini";
10
11 public static bool AuthenticationFileExists() {
12 return System.IO.File.Exists($"{Application.streamingAssetsPath}/Configs/{FileName}");
13 }
14
15 public static OpenAIAuthentication GetOpenAIAuthentication() {
16 IConfiguration config = new ConfigurationBuilder().AddIniFile($"{Application.streamingAssetsPath}/Configs/{FileName}").Build();
17 IConfigurationSection section = config.GetSection("OpenAI");
18 string apiKey = section["api_key"];
19 string orgId = section["org_id"];
20 string projId = section["proj_id"];
21 return new OpenAIAuthentication(apiKey, orgId, projId);
22 }
23
24 public static ElevenLabsAuthentication GetElevenLabsAuthentication() {
25 IConfiguration config = new ConfigurationBuilder().AddIniFile($"{Application.streamingAssetsPath}/Configs/{FileName}").Build();
26 IConfigurationSection section = config.GetSection("ElevenLabs");
27 string apiKey = section["api_key"];
28 return new ElevenLabsAuthentication(apiKey);
29 }
30 }
31}
Helper class to load the authentication file and retrieve API keys.
static bool AuthenticationFileExists()
static ElevenLabsAuthentication GetElevenLabsAuthentication()
static OpenAIAuthentication GetOpenAIAuthentication()