Example #1
0
        public SeikaStruct(string _name, int _cid)
        {
            this.name = _name;
            this.cid  = _cid;
            parameter = new Dictionary <string, Pram>();

            Dictionary <string, decimal> parameterList = new Dictionary <string, decimal>();
            List <string> pramName = new List <string>();

            foreach (KeyValuePair <string, decimal> kvp in SeikaConnect.Instance().scc.GetAvatorParams_current(cid))
            {
                string  pram  = kvp.Key;
                decimal value = kvp.Value;
                parameterList.Add(pram, value);
                if (Regex.IsMatch(pram, ".*_value$"))
                {
                    string[] vs   = { "_value" };
                    string   name = pram.Split(vs, StringSplitOptions.None)[0];
                    pramName.Add(name);
                    //Console.WriteLine(@"あたり:"+name);
                }
                //Console.WriteLine($"{pram}:{value}");
            }
            foreach (string name in pramName)
            {
                decimal value = parameterList[name + "_value"];
                decimal max   = parameterList[name + "_value_max"];
                decimal min   = parameterList[name + "_value_min"];
                decimal step  = parameterList[name + "_value_step"];
                parameter.Add(name, new Pram(value, max, min, step));
            }
        }
Example #2
0
        public SeikaStruct(string _name, int _cid)
        {
            this.name = _name;
            this.cid  = _cid;
            parameter = new Dictionary <string, Pram>();

            //var avatorParam = SeikaConnect.Instance().scc.GetAvatorParams_current2(cid);
            Task <SeikaGETpram> avatorParam = SeikaConnect.Getpram(@"http://localhost:7180", cid);
            SeikaGETpram        prams       = avatorParam.Result;

            foreach (KeyValuePair <string, Dictionary <string, decimal> > kvp in prams.Effects)
            {
                decimal value = kvp.Value["value"];
                decimal max   = kvp.Value["max"];
                decimal min   = kvp.Value["min"];
                decimal step  = kvp.Value["step"];
                parameter.Add("effect" + "_" + kvp.Key, new Pram(value, max, min, step));
            }

            foreach (KeyValuePair <string, Dictionary <string, decimal> > kvp in prams.Emotions)
            {
                decimal value = kvp.Value["value"];
                decimal max   = kvp.Value["max"];
                decimal min   = kvp.Value["min"];
                decimal step  = kvp.Value["step"];
                parameter.Add("emotion" + "_" + kvp.Key, new Pram(value, max, min, step));
            }
        }
Example #3
0
 public SeikaData()
 {
     Data = new Dictionary <string, SeikaStruct>();
     foreach (KeyValuePair <int, string> kvp in SeikaConnect.Instance().scc.AvatorList)
     {
         int    id   = kvp.Key;
         string name = kvp.Value;
         //Console.WriteLine($"-------------------------------------------------------");
         //Console.WriteLine($"{id}:{name}");
         Data.Add(name, new SeikaStruct(name, id));
     }
 }
Example #4
0
        public SeikaData()
        {
            Data = new Dictionary <string, SeikaStruct>();
            Task <List <SeikaACTOR> > actorList = SeikaConnect.GetActor(@"http://localhost:7180");

            foreach (SeikaACTOR actor in actorList.Result)
            {
                int    id   = actor.ID;
                string name = actor.Name;
                //Console.WriteLine($"-------------------------------------------------------");
                //Console.WriteLine($"{id}:{name}");
                Data.Add(name, new SeikaStruct(name, id));
            }
        }
Example #5
0
        private void SetReturnJSON()
        {
            app.Command("get", (command) =>
            {
                // 説明(ヘルプの出力で使用される)
                command.Description = "SeikaCenterの情報を返す";
                // コマンドについてのヘルプ出力のトリガーとなるオプションを指定
                command.HelpOption("-?|-h|--help");

                command.OnExecute(() =>
                {
                    SeikaData seikaData    = new SeikaData();
                    string json            = SeikaConnect.Serialize(seikaData);
                    Console.OutputEncoding = Encoding.UTF8;
                    Console.WriteLine(json);
                    return(0);
                });
            });
        }
Example #6
0
        public SeikaStruct(string _name, int _cid)
        {
            this.name = _name;
            this.cid  = _cid;
            parameter = new Dictionary <string, Pram>();

            var avatorParam = SeikaConnect.Instance().scc.GetAvatorParams_current2(cid);

            foreach (KeyValuePair <string, Dictionary <string, Dictionary <string, decimal> > > prams in avatorParam)
            {
                foreach (KeyValuePair <string, Dictionary <string, decimal> > effectsEmotions in prams.Value)
                {
                    decimal value = effectsEmotions.Value["value"];
                    decimal max   = effectsEmotions.Value["max"];
                    decimal min   = effectsEmotions.Value["min"];
                    decimal step  = effectsEmotions.Value["step"];
                    parameter.Add(prams.Key + "_" + effectsEmotions.Key, new Pram(value, max, min, step));
                }
            }
        }
Example #7
0
        private void SetTalk()
        {
            app.Command("talk", (command) =>
            {
                // 説明(ヘルプの出力で使用される)
                command.Description = "SeikaCenterへ発声情報を送る";

                // コマンドについてのヘルプ出力のトリガーとなるオプションを指定
                command.HelpOption("-?|-h|--help");

                var talkArgs     = command.Argument("話者名 text", "発話者の登録名とテキスト", true);
                var effectOption = command.Option("-effect",
                                                  "例:-effect=\"speed,1.0\" -effect=\"pitch,1.3\"",
                                                  CommandOptionType.MultipleValue);
                var emotionOption = command.Option("-emotion",
                                                   "例:-emotion=\"喜び,1.0\"",
                                                   CommandOptionType.MultipleValue);
                var outputOption = command.Option("-o",
                                                  "出力パス 指定しない場合は発声だけとなる",
                                                  CommandOptionType.MultipleValue);

                command.OnExecute(() =>
                {
                    //Console.WriteLine(talkArgs.Value);
                    if (talkArgs.Values.Count != 2)
                    {
                        return(0);
                    }

                    SeikaData seikaData     = new SeikaData();
                    SeikaStruct seikaStruct = seikaData.GetActor(talkArgs.Values[0]);
                    string text             = talkArgs.Values[1];
                    string savePath         = "";
                    int cid = seikaStruct.cid;

                    text = text.Replace("<br>", "\r\n").Replace("\r\r", "\r");

                    SeikaPOSTpram pram = new SeikaPOSTpram();
                    pram.TalkText      = text;
                    foreach (var value in effectOption.Values)
                    {
                        string[] str = value.Split(',');
                        pram.Effects.Add(str[0], decimal.Parse(str[1]));
                        //Console.WriteLine("-effect= " + value);
                    }
                    foreach (var value in emotionOption.Values)
                    {
                        string[] str = value.Split(',');
                        pram.Emotions.Add(str[0], decimal.Parse(str[1]));
                        //Console.WriteLine("-effect= " + value);
                    }
                    if (outputOption.Value() != null)
                    {
                        savePath = outputOption.Value();
                    }
                    if (savePath != "")
                    {
                        Task <Stream> sound = SeikaConnect.SAVE(@"http://*****:*****@"/" + Path.GetFileNameWithoutExtension(savePath) + ".txt", false, Encoding.UTF8);
                        writer.WriteLine(text);
                        writer.Close();

                        return(0);
                    }
                    Task <string> taskString = SeikaConnect.Talk(@"http://localhost:7180", cid, SeikaConnect.Serialize(pram, true));
                    Console.WriteLine(taskString.Result);//ただ待つため

                    return(0);
                });
            });
        }
Example #8
0
        private void SetTalk()
        {
            app.Command("talk", (command) =>
            {
                // 説明(ヘルプの出力で使用される)
                command.Description = "SeikaCenterへ発声情報を送る";

                // コマンドについてのヘルプ出力のトリガーとなるオプションを指定
                command.HelpOption("-?|-h|--help");

                var talkArgs     = command.Argument("cid text", "発話者のcidとテキスト", true);
                var effectOption = command.Option("-effect",
                                                  "例:-effect=\"speed,1.0\" -effect=\"pitch,1.3\"",
                                                  CommandOptionType.MultipleValue);
                var emotionOption = command.Option("-emotion",
                                                   "例:-emotion=\"喜び,1.0\"",
                                                   CommandOptionType.MultipleValue);
                var outputOption = command.Option("-o",
                                                  "出力パス 指定しない場合は発生するだけとなる",
                                                  CommandOptionType.MultipleValue);

                command.OnExecute(() =>
                {
                    //Console.WriteLine(talkArgs.Value);
                    if (talkArgs.Values.Count != 2)
                    {
                        return(0);
                    }

                    SeikaData seikaData     = new SeikaData();
                    SeikaStruct seikaStruct = seikaData.GetActor(talkArgs.Values[0]);
                    string text             = talkArgs.Values[1];
                    string savePath         = "";
                    int cid = seikaStruct.cid;

                    text = text.Replace("<br>", "\r\n").Replace("\r\r", "\r");

                    Dictionary <string, decimal> effects = new Dictionary <string, decimal>();
                    foreach (var value in effectOption.Values)
                    {
                        string[] str = value.Split(',');
                        effects.Add(str[0], decimal.Parse(str[1]));
                        //Console.WriteLine("-effect= " + value);
                    }
                    Dictionary <string, decimal> emotions = new Dictionary <string, decimal>();
                    foreach (var value in emotionOption.Values)
                    {
                        string[] str = value.Split(',');
                        emotions.Add(str[0], decimal.Parse(str[1]));
                        //Console.WriteLine("-effect= " + value);
                    }
                    if (outputOption.Value() != null)
                    {
                        savePath = outputOption.Value();
                    }
                    if (savePath != "")
                    {
                        Encoding utf        = Encoding.UTF8;
                        StreamWriter writer =
                            new StreamWriter(Path.GetDirectoryName(savePath) + @"/" + Path.GetFileNameWithoutExtension(savePath) + ".txt", false, utf);
                        writer.WriteLine(text);
                        writer.Close();
                    }

                    SeikaConnect.Instance().scc.Talk(cid, text, savePath, effects, emotions);
                    //SeikaConnect.Instance().scc.Talk(cid, "", "",new Dictionary<string, decimal>(), new Dictionary<string, decimal>());


                    return(0);
                });
            });
        }