using System; using System.Collections.Generic; namespace ScDriver.CeVio { public class CevioProxy : MarshalByRefObject { dynamic CevioTalkerProd; double Timeout = 3 * 60 * 1000; public string[] AvailableCasts { get { List x = new List(); dynamic ac = CevioTalkerProd.AvailableCasts; for (int i = 0; i < ac.Length; i++) { x.Add(ac[i]); } return x.ToArray(); } } public string Cast { get { return CevioTalkerProd.Cast; } set { CevioTalkerProd.Cast = value; } } public uint Volume { get { return CevioTalkerProd.Volume; } set { CevioTalkerProd.Volume = value; } } public uint Speed { get { return CevioTalkerProd.Speed; } set { CevioTalkerProd.Speed = value; } } public uint Tone { get { return CevioTalkerProd.Tone; } set { CevioTalkerProd.Tone = value; } } public uint Alpha { get { return CevioTalkerProd.Alpha; } set { CevioTalkerProd.Alpha = value; } } public uint ToneScale { get { return CevioTalkerProd.ToneScale; } set { CevioTalkerProd.ToneScale = value; } } public Dictionary Components { get { var emo = CevioTalkerProd.Components; Dictionary param = new Dictionary(); for (int i = 0; i < emo.Length; i++) { param.Add(emo[i].Name, emo[i].Value); } return param; } } public void SetComponent(string emoName, uint emoValue) { CevioTalkerProd.Components[emoName].Value = emoValue; } public string GetComponent(string emoName) { return CevioTalkerProd.Components[emoName].Value; } public void Speak(string text) { dynamic status = CevioTalkerProd.Speak(text); //SpeakingState status = cevioTalker.Speak(TalkText); status.Wait(Timeout); CevioTalkerProd.Stop(); } public void Save(string text, string WavFilePath) { CevioTalkerProd.OutputWaveToFile(text, WavFilePath); } public override object InitializeLifetimeService() { return null; } public CevioProxy() { try { CevioTalkerProd = Activator.CreateInstance(Type.GetTypeFromProgID("CeVIO.Talk.RemoteService.Talker")); // 遅延バインドで使用しますCeVIO AI だと "CeVIO.Talk.RemoteService2.Talker2" } catch(Exception) { CevioTalkerProd = null; } } } }