Esempio n. 1
0
        /// <summary>
        /// メッセージを受け取った時の処理
        /// </summary>
        static async Task MessageReceived(SocketMessage arg)
        {
            await Task.Run(() =>
            {
                // 棒読みちゃんに読み上げさせる
                // using を使うとリソース解放してくれるので Dispose() しなくてすむ
                using (var bc = new BouyomiChanClient())
                {
                    bc.AddTalkTask(arg.Content);
                }

                /*/
                 * // チャンネル一覧にある・ユーザーID一覧にあるなら
                 * if (Properties.Settings.Default.TextChannels.IndexOf(arg.Channel.Id.ToString()) >= 0 ||
                 * Properties.Settings.Default.UserIDs.IndexOf(arg.Author.Id.ToString()) >= 0)
                 * {
                 *  // 読み上げ
                 *  using (var bc = new BouyomiChanClient())
                 *  {
                 *      bc.AddTalkTask(arg.Content);
                 *  }
                 * }
                 * //*/
            });
        }
Esempio n. 2
0
 /// <summary>
 /// メッセージを受け取った時の処理
 /// </summary>
 private async Task Talk(SocketMessage message)
 {
     await Task.Run(() =>
     {
         // チャンネル一覧に存在するなら
         foreach (var idInfo in iDList.ChannelIDList)
         {
             if (idInfo.ID == message.Channel.Id.ToString())
             {
                 // 読み上げ
                 using (var bc = new BouyomiChanClient())
                 {
                     bc.AddTalkTask(message.Content);
                 }
                 return;
             }
         }
         // ユーザ一覧に存在するなら
         foreach (var idInfo in iDList.UserIDList)
         {
             if (idInfo.ID == message.Author.Id.ToString())
             {
                 // 読み上げ
                 using (var bc = new BouyomiChanClient())
                 {
                     bc.AddTalkTask(message.Content);
                 }
                 return;
             }
         }
     });
 }
Esempio n. 3
0
        /// <summary>
        /// 棒読みちゃんで読み上げ
        /// </summary>
        private void Bouyomi(string text)
        {
            var bouyomiChanClient = new BouyomiChanClient();

            bouyomiChanClient.AddTalkTask(text);
            bouyomiChanClient.Dispose();
        }
Esempio n. 4
0
 public void output(string mes, int speed)
 {
     try
     {
         bcc.AddTalkTask(mes, speed, -1, VoiceType.Default);
     }
     catch { }
 }
Esempio n. 5
0
        private void writeToTextfile(double refreshSecond)
        {
            string          trimedFileName = fileName.Trim();
            Action <string> writeToFile    = (string t) =>
            {
                if (trimedFileName != "")
                {
                    System.IO.File.WriteAllText(trimedFileName, t, Encoding.UTF8);
                }
            };
            Action <string> talk = (string t) => {
                if (bouyomiChan != null)
                {
                    bouyomiChan.AddTalkTask(t);
                }
            };

            string    text;
            Stopwatch stopwatch = new Stopwatch();

            stopwatch.Start();

            while (isListening == true)
            {
                if (textQueue.TryDequeue(out text))
                {
                    try
                    {
                        writeToFile(text);
                        talk(text);
                        stopwatch.Restart();
                    }
                    catch (Exception)
                    {
                        break;
                    }
                }

                if (refreshSecond > 0 && (stopwatch.ElapsedMilliseconds > (refreshSecond * 1000)))
                {
                    try
                    {
                        writeToFile("");
                        stopwatch.Restart();
                    }
                    catch (Exception)
                    {
                        break;
                    }
                }
            }

            stopwatch.Stop();
        }
Esempio n. 6
0
 /// <summary>
 /// メッセージを受け取った時の処理
 /// </summary>
 static async Task Talk(SocketMessage arg)
 {
     await Task.Run(() =>
     {
         // チャンネル一覧にある・ユーザーID一覧にあるなら
         if (Properties.Settings.Default.TextChannels.IndexOf(arg.Channel.Id.ToString()) >= 0 ||
             Properties.Settings.Default.UserIDs.IndexOf(arg.Author.Id.ToString()) >= 0)
         {
             // 読み上げ
             using (var bc = new BouyomiChanClient())
             {
                 bc.AddTalkTask(arg.Content);
             }
         }
     });
 }
Esempio n. 7
0
        /// <summary>
        /// 指定されたテキストの音声を出力する
        /// (スレッドにタスクをキューイングする)
        /// </summary>
        /// <param name="text">テキスト</param>
        /// <returns></returns>
        public bool Talk(string text)
        {
            System.Diagnostics.Debug.WriteLine("BouyomiChan::Talk:" + text);

            int       speed     = -1;
            int       tone      = -1;
            int       volume    = -1;
            VoiceType voiceType = VoiceType.Default;

            try
            {
                // 棒読みちゃん本体へタスク追加
                bouyomiChanClient.AddTalkTask(text, speed, tone, volume, voiceType);
            }
            //catch (System.Runtime.Remoting.RemotingException exception)
            catch (Exception exception)
            {
                System.Diagnostics.Debug.WriteLine(exception.Message + " " + exception.StackTrace);
            }

            return(true);
        }
Esempio n. 8
0
        /// <summary>
        /// 非同期Mainメソッド
        /// </summary>
        static async Task MainAsync()
        {
            // トークンのチェック
            await CheckTokenAsync();

            // ログイン処理
            Console.WriteLine("ログイン中…");
            var client = new DiscordSocketClient();
            await client.LoginAsync(TokenType.User, Properties.Settings.Default.Token);

            await client.StartAsync();

            Console.WriteLine("ログイン完了");
            // 始めのあいさつ(大事)
            var task = Task.Run(() =>
            {
                using (var start = new BouyomiChanClient())
                {
                    start.AddTalkTask("棒読みちゃん起動~!");
                }
            });

            // メッセージ受信時のイベントを追加
            client.MessageReceived += Talk;
            // 各種コマンド
            InputCommand();
            // 終わりのあいさつ(大事)
            task = Task.Run(() =>
            {
                using (var end = new BouyomiChanClient())
                {
                    end.AddTalkTask("棒読みちゃん終了~!");
                }
            });
            Console.WriteLine("キー入力で終了");
            Console.ReadLine();
        }
Esempio n. 9
0
        // 読み上げ 開始/停止 ボタンを押したときの処理
        // チェックボックスにチェックが入っているかどうかを、スイッチのON/OFFに見立ててトグル式のボタンにできる
        // AppearanceプロパティをButtonにする
        private async void checkBox1_CheckedChangedAsync(object sender, EventArgs e)
        {
            CheckBox chkBox = (CheckBox)sender;

            if (chkBox.Checked)
            {
                // 起動時はチェックが入っておらず、表示が開始になっている
                // チェックが入ると表示を停止に変更
                chkBox.Text = "停止";

                // テキストボックスに入力してあるメールアドレスを取得
                string email = textBox1.Text;
                Console.Write("メールアドレス : " + email);

                // テキストボックスに入力してあるパスワードを取得
                string password = textBox2.Text;
                Console.Write("\nパスワード : " + password);

                // メールアドレスとパスワードでトークンを取得する処理
                // 入力ミスでトークンを取得できなかった時などの例外処理が必要かも?
                await CheckTokenAsync(email, password);

                // ログイン処理
                // 「TokenType.User は旧形式です」という警告がでてるけど、どうしたらいいかわからない
                Console.WriteLine("ログイン処理中…");
                await client.LoginAsync(TokenType.User, Properties.Settings.Default.Token);

                await client.StartAsync();

                Console.WriteLine("ログイン完了");

                // ログインしたことがわかるように、読み上げ開始のお知らせ
                var task = Task.Run(() =>
                {
                    using (var start = new BouyomiChanClient())
                    {
                        Console.WriteLine("ディスコードの読み上げを開始しました。");
                        start.AddTalkTask("ディスコードの読み上げを開始しました。");
                    }
                });
            }
            else
            {
                // チェックを外した状態は停止中、表示を開始するためのボタンに変更する
                chkBox.Text = "開始";

                // ログアウト処理
                Console.WriteLine("ログアウト処理中…");
                await client.StopAsync();

                await client.LogoutAsync();

                Console.WriteLine("ログアウト完了");

                // ログアウトしたことがわかるように、読み上げ終了のお知らせ
                var task = Task.Run(() =>
                {
                    using (var end = new BouyomiChanClient())
                    {
                        Console.WriteLine("ディスコードの読み上げを終了しました。");
                        end.AddTalkTask("ディスコードの読み上げを終了しました。");
                    }
                });
            }
        }
Esempio n. 10
0
 public void Speak(string message)
 {
     Client.AddTalkTask(message);
 }
Esempio n. 11
0
        private void buttonAddSample_Click(object sender, EventArgs e)
        {
            try {
                //棒読みちゃん側で選んでいる、声質・速さ・音量で読み上げる
                BouyomiChan.AddTalkTask("デフォルト1");

                //棒読みちゃん側で選んでいる、声質・速さ・音量で読み上げる(上記と同等)
                BouyomiChan.AddTalkTask("デフォルト2", -1, -1, -1, VoiceType.Default);

                //声質(女性1)
                BouyomiChan.AddTalkTask("女性1", -1, -1, -1, VoiceType.Female1);

                //声質(女性2)
                BouyomiChan.AddTalkTask("女性2", -1, -1, -1, VoiceType.Female2);

                //声質(男性1)
                BouyomiChan.AddTalkTask("男性1", -1, -1, -1, VoiceType.Male1);

                //声質(男性2)
                BouyomiChan.AddTalkTask("男性2", -1, -1, -1, VoiceType.Male2);

                //声質(中性)
                BouyomiChan.AddTalkTask("中性", -1, -1, -1, VoiceType.Imd1);

                //声質(ロボット)
                BouyomiChan.AddTalkTask("ロボット", -1, -1, -1, VoiceType.Robot1);

                //声質(機械1)
                BouyomiChan.AddTalkTask("機械1", -1, -1, -1, VoiceType.Machine1);

                //声質(機械2)
                BouyomiChan.AddTalkTask("機械2", -1, -1, -1, VoiceType.Machine2);

                //速度(最低速)
                BouyomiChan.AddTalkTask("最低速度", 50, -1, -1, VoiceType.Default);

                //速度(通常)
                BouyomiChan.AddTalkTask("普通の速度", 100, -1, -1, VoiceType.Default);

                //速度(最高速)
                BouyomiChan.AddTalkTask("最高速度", 300, -1, -1, VoiceType.Default);

                //音程(最低)
                BouyomiChan.AddTalkTask("半分の周波数", -1, 50, -1, VoiceType.Default);

                //音程(通常)
                BouyomiChan.AddTalkTask("普通の周波数", -1, 100, -1, VoiceType.Default);

                //音程(最高)
                BouyomiChan.AddTalkTask("倍の周波数", -1, 200, -1, VoiceType.Default);

                //音量(小さめ)
                BouyomiChan.AddTalkTask("音量低め", -1, -1, 10, VoiceType.Default);

                //音量(中ぐらい)
                BouyomiChan.AddTalkTask("音量中ぐらい", -1, -1, 50, VoiceType.Default);

                //音量(最大)
                BouyomiChan.AddTalkTask("音量最大", -1, -1, 100, VoiceType.Default);
            } catch (RemotingException) {
                MessageBox.Show("棒読みちゃんに接続できませんでした");
            }
        }