private void OnReceiveRequestHandler(HttpListenerRequest req, HttpListenerResponse res)
        {
            var query    = req.QueryParse();
            var talkData = CreateDataFromQuery(query);

            Pub.AddTalkTask(talkData.Message, talkData.Speed, talkData.Tone, talkData.Volume, talkData.Voice);
        }
Exemple #2
0
 public void Stop()
 {
     active = false;
     server.Close();
     thread.Abort();
     Pub.AddTalkTask("ソケット受付を終了しました。", -1, -1, VoiceType.Default);
 }
        private void OnMessage(string message)
        {
            Pub.AddTalkTask(message);
            string kujiMsg = KujiFind(message);

            if (kujiMsg.Length > 0)
            {
                Thread.Sleep(_setting.Interval);
                Pub.AddTalkTask(kujiMsg);
            }
        }
        /// <summary>
        /// データを受信した
        /// </summary>
        /// <param name="client"></param>
        /// <param name="data"></param>
        private void Server_OnDataReceived(System.Net.Sockets.TcpClient client, byte[] data)
        {
            System.Diagnostics.Debug.WriteLine("Server_OnDataReceived {data.Length:{0}", data.Length.ToString());

            short command; //[0-1]  (16Bit) コマンド          ( 0:メッセージ読み上げ)
            short speed;   //[2-3]  (16Bit) 速度              (-1:棒読みちゃん画面上の設定)
            short tone;    //[4-5]  (16Bit) 音程              (-1:棒読みちゃん画面上の設定)
            short volume;  //[6-7]  (16Bit) 音量              (-1:棒読みちゃん画面上の設定)
            short voice;   //[8-9]  (16Bit) 声質              ( 0:棒読みちゃん画面上の設定、1:女性1、2:女性2、3:男性1、4:男性2、5:中性、6:ロボット、7:機械1、8:機械2、10001~:SAPI5)
            byte  code;    //[10]   ( 8Bit) 文字列の文字コード( 0:UTF-8, 1:Unicode, 2:Shift-JIS)
            long  len;     //[11-14](32Bit) 文字列の長さ

            byte[] buf;    // 文字列

            int pos = 0;

            command = (short)(data[pos++] + (data[pos++] << 8));
            speed   = (short)(data[pos++] + (data[pos++] << 8));
            tone    = (short)(data[pos++] + (data[pos++] << 8));
            volume  = (short)(data[pos++] + (data[pos++] << 8));
            voice   = (short)(data[pos++] + (data[pos++] << 8));
            code    = data[pos++];
            len     = data[pos++] + (data[pos++] << 8) +
                      (data[pos++] << 16) + (data[pos++] << 24);
            buf = new byte[len];
            for (int i = 0; i < len; i++)
            {
                buf[i] = data[pos++];
            }
            var text = Encoding.UTF8.GetString(buf);

            System.Diagnostics.Debug.WriteLine("command = {0}", command.ToString());
            System.Diagnostics.Debug.WriteLine("speed = {0}", speed.ToString());
            System.Diagnostics.Debug.WriteLine("tone = {0}", tone.ToString());
            System.Diagnostics.Debug.WriteLine("volume = {0}", volume.ToString());
            System.Diagnostics.Debug.WriteLine("voice = {0}", voice.ToString());
            System.Diagnostics.Debug.WriteLine("code = {0}", code.ToString());
            System.Diagnostics.Debug.WriteLine("len = {0}", len.ToString());
            System.Diagnostics.Debug.WriteLine("text = " + text);

            Pub.AddTalkTask(text, speed, tone, volume, (VoiceType)voice);

            client.Close();
        }
Exemple #5
0
        private void Talk(string n, string l)
        {
            int speed  = -1;
            int volume = -1;
            int type   = 0;

            if (_Settings.Name)
            {
                speed  = _Settings.Chat[1].Speed;
                volume = _Settings.Chat[1].Volume;
                type   = _Settings.Chat[1].Type;
                Pub.AddTalkTask(n, speed, volume, (FNF.Utility.VoiceType)type);
            }

            speed  = _Settings.Chat[0].Speed;
            volume = _Settings.Chat[0].Volume;
            type   = _Settings.Chat[0].Type;
            Pub.AddTalkTask(l, speed, volume, (FNF.Utility.VoiceType)type);
        }
Exemple #6
0
        //時刻を読み上げる
        private void AddTimeTalk(DateTime dt, bool bJustTime)
        {
            StringBuilder sb = new StringBuilder();

            if (bJustTime)
            {
                sb.Append("ポッ  ポッ  ポッ  パアアアアン ");
                sb.Append("ぼうよみちゃん/が");
                sb.Append(dt.Hour);
                sb.Append("時を、おつたえしま'す。");
            }
            else
            {
                sb.Append(dt.Hour);
                sb.Append("時");
                sb.Append(dt.Minute);
                sb.Append("分");
                sb.Append(dt.Second);
                sb.Append("秒です。");
            }
            Pub.AddTalkTask(sb.ToString(), -1, -1, VoiceType.Default);
        }
Exemple #7
0
        private void Button_Click(object sender, EventArgs e)
        {
            string textSample = Pub.FormMain.textBoxSource.Text;

            VoiceType voicetype         = FNF.Utility.VoiceType.Default;
            int       volume            = Pub.FormMain.trackBarVolume.Value;
            int       speed             = Pub.FormMain.trackBarSpeed.Value;
            int       tone              = Pub.FormMain.trackBarTone.Value;
            string    comboBoxVoiceType = Pub.FormMain.comboBoxVoiceType.SelectedItem.ToString();

            string   FilePath = _SettingFormData.PBase.FilePath;
            DateTime dt       = DateTime.Now;

            string Speaker  = comboBoxVoiceType + "_V@" + volume.ToString() + "_S@" + speed.ToString() + "_T@" + tone.ToString();
            string FileName = dt.ToString("yyMMdd_HHmmss") + "_" + Speaker + "_" + textSample;

            StreamWriter sw = new StreamWriter(Path.Combine(@FilePath, FileName + ".txt"), false, Encoding.GetEncoding("shift_jis"));

            sw.Write(textSample);
            sw.Close();

            Pub.AddTalkTask(textSample, speed, tone, volume, voicetype, Path.Combine(FilePath, FileName + ".wav"));
            return;
        }
Exemple #8
0
 public void AddTalkTask()
 {
     Pub.AddTalkTask(MessageProp.Message, Speed, Tone, Volume, (VoiceType)Voice);
 }
Exemple #9
0
 private int CorePushMessage(string message, int speechSpeed, int volume, VoiceType voice)
 {
     return(Pub.AddTalkTask(message, speechSpeed, volume, (VoiceType)voice));
 }
Exemple #10
0
        private void AddCommentTalk(long lastCommentIndex)
        {
            if (this._LastCommentIndexTmp != lastCommentIndex)
            {
                this._LastCommentIndexTmp = lastCommentIndex;
                try {
                    CommentData commentData = sendRequest(lastCommentIndex);
                    this._LastCommentIndexTmp = -2;
                    switch (commentData.status)
                    {
                    case 0:
                        if (lastCommentIndex >= commentData.last_comment_index)
                        {
                            break;
                        }
                        this._LastCommentIndex = commentData.last_comment_index;
                        if (lastCommentIndex >= 0)
                        {
                            foreach (Comment comment in commentData.comments)
                            {
                                if (comment.anonymous == 1)
                                {
                                    long anonymousIndex = this.getAnonymousIndex(comment.hash);
                                    comment.user_name = this._Settings.AnonymousString.Replace("%d", anonymousIndex.ToString());
                                }
                                string commentText;
                                if (comment.system_comment == null)
                                {
                                    if (!this._Settings.CommentFlg || comment.ng_comment_user == 1 || comment.comment.Length <= 0)
                                    {
                                        continue;
                                    }
                                    commentText = this._Settings.CommentString.Replace("%1$s", comment.user_name).Replace("%2$s", comment.comment);
                                }
                                else
                                {
                                    switch (comment.system_comment.type)
                                    {
                                    case "gift":
                                        if (!this._Settings.GiftFlg)
                                        {
                                            continue;
                                        }
                                        if (comment.system_comment.tip_amount > 0)
                                        {
                                            commentText = this._Settings.GiftPointString;
                                        }
                                        else
                                        {
                                            commentText = this._Settings.GiftString;
                                        }
                                        commentText = commentText.Replace("%1$s", comment.user_name)
                                                      .Replace("%2$s", this.getGiftItemName(comment.system_comment.gift_id))
                                                      .Replace("%1$d", comment.system_comment.tip_amount.ToString())
                                                      .Replace("%2$d", comment.system_comment.tip_total.ToString());
                                        break;

                                    case "tip":
                                        if (!this._Settings.TipFlg)
                                        {
                                            continue;
                                        }
                                        commentText = this._Settings.TipString.Replace("%1$s", comment.user_name)
                                                      .Replace("%1$d", comment.system_comment.tip_amount.ToString())
                                                      .Replace("%2$d", comment.system_comment.tip_total.ToString());
                                        break;

                                    default:
                                        continue;
                                    }
                                }
                                Pub.AddTalkTask(commentText, -1, -1, VoiceType.Default);
                            }
                        }
                        else
                        {
                            this.ChangeIcon(true);
                            this._SettingStatus = true;
                            //Pub.AddTalkTask("FC2ライブの読み上げを開始します", -1, -1, VoiceType.Default);
                        }
                        break;

                    case 10:
                        this._Settings.TimeSignal = false;
                        Pub.AddTalkTask("FC2ライブの読み上げを終了します", -1, -1, VoiceType.Default);
                        Pub.AddTalkTask("APIアクセスパラメーターが足りていません", -1, -1, VoiceType.Default);
                        break;

                    case 11:
                        this._Settings.TimeSignal = false;
                        this._SettingStatus       = false;
                        Pub.AddTalkTask("FC2ライブの読み上げを終了します", -1, -1, VoiceType.Default);
                        Pub.AddTalkTask("トークンが正しくありません", -1, -1, VoiceType.Default);
                        break;

                    case 12:
                        this._Settings.TimeSignal = false;
                        this._SettingStatus       = false;
                        Pub.AddTalkTask("FC2ライブの読み上げを終了します", -1, -1, VoiceType.Default);
                        Pub.AddTalkTask("チャンネルが見つかりません", -1, -1, VoiceType.Default);
                        break;

                    case 13:
                        this._Settings.TimeSignal = false;
                        Pub.AddTalkTask("FC2ライブの読み上げを終了します", -1, -1, VoiceType.Default);
                        Pub.AddTalkTask("視聴していないチャンネルです", -1, -1, VoiceType.Default);
                        break;

                    case 99:
                        if (!this._Settings.Discard99Flg)
                        {
                            this._Settings.TimeSignal = false;
                            Pub.AddTalkTask("FC2ライブの読み上げを終了します", -1, -1, VoiceType.Default);
                            Pub.AddTalkTask("エラーが発生しました", -1, -1, VoiceType.Default);
                        }
                        break;

                    case 98:
                    default:
                        this._Settings.TimeSignal = false;
                        Pub.AddTalkTask("FC2ライブの読み上げを終了します", -1, -1, VoiceType.Default);
                        Pub.AddTalkTask("エラーが発生しました", -1, -1, VoiceType.Default);
                        break;
                    }
                } catch (Exception e) {
                    this._LastCommentIndexTmp = -2;
                    this.PrintException(e);
                }
            }
        }
Exemple #11
0
 public void Start()
 {
     thread = new Thread(Run);
     Pub.AddTalkTask("ソケット受付を開始しました。", -1, -1, VoiceType.Default);
     thread.Start();
 }
Exemple #12
0
            // WebSocketメイン
            private void doWebSocketMain(String header)
            {
                String key = "Sec-WebSocket-Key: ";
                int    pos = header.IndexOf(key);

                if (pos < 0)
                {
                    return;
                }

                // "Sec-WebSocket-Accept"に設定する文字列を生成
                String value = header.Substring(pos + key.Length, (header.IndexOf("\r\n", pos) - (pos + key.Length)));

                byte[] byteValue = Encoding.UTF8.GetBytes(value + "258EAFA5-E914-47DA-95CA-C5AB0DC85B11");
                SHA1   crypto    = new SHA1CryptoServiceProvider();

                byte[] hash     = crypto.ComputeHash(byteValue);
                String resValue = Convert.ToBase64String(hash);

                // 応答内容送信
                byte[] buffer = Encoding.UTF8.GetBytes(
                    "HTTP/1.1 101 OK\r\n" +
                    "Upgrade: websocket\r\n" +
                    "Connection: Upgrade\r\n" +
                    "Sec-WebSocket-Accept: " + resValue + "\r\n" +
                    "\r\n");

                mClient.Send(buffer);

                // クライアントからテキストを受信
                int bsize = mClient.ReceiveBufferSize;

                byte[] request = new byte[bsize];
                mClient.Receive(request);

                // マスク解除
                Int64 payloadLen = request[1] & 0x7F;
                bool  masked     = ((request[1] & 0x80) == 0x80);
                int   hp         = 2;

                switch (payloadLen)
                {
                case 126: payloadLen = request[2] * 0x100 + request[3]; hp += 2; break;

                case 127: payloadLen = request[2] * 0x100000000000000 + request[3] * 0x1000000000000 + request[4] * 0x10000000000 + request[5] * 0x100000000 + request[6] * 0x1000000 + request[7] * 0x10000 + request[8] * 0x100 + request[9]; hp += 8; break;

                default:  break;
                }
                if (masked)
                {
                    for (int i = 0; i < payloadLen; i++)
                    {
                        request[hp + 4 + i] ^= request[hp + (i % 4)];
                        //Console.WriteLine(buffer[6 + i]);
                    }
                    hp += 4;
                }

                // 受け取ったリクエストの解析
                String fromClient = Encoding.UTF8.GetString(request, hp, (int)payloadLen);

                String[]  delim = { "<bouyomi>" };
                String[]  param = fromClient.Split(delim, 5, StringSplitOptions.None);
                VoiceType vt    = VoiceType.Default;

                if (param.Length == 5)
                {
                    switch (int.Parse(param[3]))
                    {
                    case 0: vt = VoiceType.Default; break;

                    case 1: vt = VoiceType.Female1; break;

                    case 2: vt = VoiceType.Female2; break;

                    case 3: vt = VoiceType.Male1; break;

                    case 4: vt = VoiceType.Male2; break;

                    case 5: vt = VoiceType.Imd1; break;

                    case 6: vt = VoiceType.Robot1; break;

                    case 7: vt = VoiceType.Machine1; break;

                    case 8: vt = VoiceType.Machine2; break;

                    default: vt = (VoiceType)int.Parse(param[3]); break;
                    }
                }

                // 読み上げ
                Pub.AddTalkTask(param[4], int.Parse(param[0]), int.Parse(param[1]), int.Parse(param[2]), vt);
            }
Exemple #13
0
 protected override void OnMessage(MessageEventArgs e)
 {
     base.OnMessage(e);
     Pub.AddTalkTask(e.Data);
 }