Giter Club home page Giter Club logo

discord-pero's Introduction

英語音声で読み上げてくれるBot

招待リンク

目的

  • 話している時に気になった英語をさっと読み上げさせたい

動作環境

$ gcloud auth application-default print-access-token

動き概要

  1. Discordでボイスチャンネルに入っている人から!peroで始まるメッセージを受け取る
  2. Google Cloud Text to Speech APIを呼び出し、音声データ(base64形式)を取得
  3. 音声データをbase64デコードし、再生

使い方

読み上げる

!pero <読み上げさせたいメッセージ>

ボイスチャンネルから退出

注意:これをしないと退出しません

!pero disc

起動方法

# nodejsのインストール
$ git clone https://github.com/creationix/nvm ~/.nvm
$ source ~/.nvm/nvm.sh
$ echo "source ~/.nvm/nvm.sh" >> ~/.bashrc
$ nvm install 10.16.3
$ nvm use 10.16.3

# このアプリの起動
$ git clone https://github.com/sakkuntyo/discord-pero
$ cd discord-pero
$ sed "s/<discordtoken>/ここにdiscordのトークンを入れる/g" -i settings.json
$ npm install
$ npm start

# デーモンにしたい場合、pm2を使う
$ npm install -g pm2
$ pm2 start index pero
## OSの起動と同時に起動
$ pm2 startup
## 現在のpm2 listの状態を保存
$ pm2 save

1.アプリケーション作成

2.Bot設定ページのBUILD-A-BOTにある Add Bot ボタンを押下

今後このページからBot設定を行う

3.OAuth2設定ページから招待リンクを作成してBotをチャンネルに追加する

  • 必要なスコープ
    • bot
  • 必要な権限
    • View Audiot Log
    • Connect
    • Speak

image

4.tokenはBot設定ページの Click to Reveal Token をクリックして表示される物を使用する

image

discord-pero's People

Contributors

sakkuntyo avatar

Watchers

James Cloos avatar  avatar

discord-pero's Issues

curlをrequestライブラリで置き換えたい

requestでやってみているけどうまくいかない

現状

curl -X POST -H "Authorization: Bearer "$(gcloud auth application-default print-access-token) -H "Content-Type: application/json; charset=utf-8" -d @request.json https://texttospeech.googleapis.com/v1/text:synthesize

これを↓みたいなかんじで置き換えたい
translateConfigはこのままでよさそう

var translateConfig = {
  audioConfig: {
    audioEncoding: "LINEAR16",
    pitch: 0,
    speakingRate: 1
  },
  input: {
    text: secondory_msg
  },
  voice: {
    languageCode: "en-US",
    name: "en-US-Wavenet-D"
  }
}
var options = {
  url: 'https://texttospeech.googleapis.com/v1/text:synthesize',
  method: "POST",
  form: JSON.stringify(translateConfig),
  headers: {
    'Authorization': "Bearer " + execSync("gcloud auth application-default print-access-token"),
    'Content-Type': "application/json; charset=utf-8"
  },
  json: true
}
request(options, (err,res,body) => {
  console.log(err);
  console.log(res);
  console.log(body);
});

Authorizationがどうたらこうたらってエラーが出る

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.