Discordのテキストチャットを読み上げてみた 1
Discordのテキストチャットをボイスチャットに読み上げるBotづくり
ワタクシのようなコミュ障はなかなかボイスチャットに入りにくいんですね
けどわざわざテキストチャットを呼んでもらうのは会話のテンポてきにどうなの?
っておもったので作ってみることにします。
使うもの
NodeJS
voice-text(VoiceText Web APIをいい感じにしてくれる)
github.com
eris(DiscordBotをいい感じにしてくれる)
www.npmjs.com
1.各APIの登録
DiscordにBotの登録
[Node.js] [Discord] Discord の Bot を作る。 その1 | Cafe Dragon Forest ここを参考に、DiscordのBotを作成する。
VoiceText Web API
VoiceText Web API
ここから登録できる。トークンはメールですぐ届く
2.各APIを試してみる
Discord
NPMのPing Pong Exampleを試してみる
const Eris = require("eris"); var bot = new Eris("BOT_TOKEN"); // Replace BOT_TOKEN with your bot account's token bot.on("ready", () => { // When the bot is ready console.log("Ready!"); // Log "Ready!" }); bot.on("messageCreate", (msg) => { // When a message is created if(msg.content === "!ping") { // If the message content is "!ping" bot.createMessage(msg.channel.id, "Pong!"); // Send a message in the same channel with "Pong!" } else if(msg.content === "!pong") { // Otherwise, if the message is "!pong" bot.createMessage(msg.channel.id, "Ping!"); // Respond with "Ping!" } }); bot.connect(); // Get the bot to connect to Discord
VoiceText
GitHub - 59naga/voice-text: VoiceText Web API client for NodeJS
ここのUsageをやってみる
importがよくわからないからrequireにかえる
const {VoiceText} = require('voice-text'); const {writeFileSync} = require('fs'); const voiceText = new VoiceText('YOUR_API_KEY'); voiceText.fetchBuffer('激アツモンゴル', { format: 'ogg' }) .then((buffer) => { writeFileSync('voice.ogg', buffer); });
次回はこの2つの溶接作業を行います