質問をすることでしか得られない、回答やアドバイスがある。

15分調べてもわからないことは、質問しよう!

新規登録して質問してみよう
ただいま回答率
85.46%
Node.js

Node.jsとはGoogleのV8 JavaScriptエンジンを使用しているサーバーサイドのイベント駆動型プログラムです。

Q&A

解決済

1回答

1029閲覧

読み上げをmp3にしようとした

yuina8686

総合スコア12

Node.js

Node.jsとはGoogleのV8 JavaScriptエンジンを使用しているサーバーサイドのイベント駆動型プログラムです。

0グッド

0クリップ

投稿2021/10/17 23:46

前提・実現したいこと

Google Cloud Text-to-SpeechでNode.jsを使用し、テキストの読み上げ音声をmp3として取得しようとしているのですが、次のようなエラーが出ました。

発生している問題・エラーメッセージ

Error: Could not load the default credentials. Browse to https://cloud.google.com/docs/authentication/getting-started for more information. at GoogleAuth.getApplicationDefaultAsync (/home/runner/YuinaBOT-test/node_modules/google-auth-library/build/src/auth/googleauth.js:180:19) at processTicksAndRejections (node:internal/process/task_queues:96:5) at async GoogleAuth.getClient (/home/runner/YuinaBOT-test/node_modules/google-auth-library/build/src/auth/googleauth.js:558:17) at async GrpcClient._getCredentials (/home/runner/YuinaBOT-test/node_modules/google-gax/build/src/grpc.js:145:24) at async GrpcClient.createStub (/home/runner/YuinaBOT-test/node_modules/google-gax/build/src/grpc.js:308:23)

該当のソースコード

javascript

1const { Intents, Client } = require('discord.js'); 2const { joinVoiceChannel, entersState, VoiceConnectionStatus, createAudioResource, StreamType, createAudioPlayer, AudioPlayerStatus, NoSubscriberBehavior, generateDependencyReport } = require("@discordjs/voice"); 3const Discord = require('discord.js'); 4const textToSpeech = require('@google-cloud/text-to-speech'); 5const util = require('util'); 6const options = { 7 intents: ['GUILDS', 'GUILD_MESSAGES', 'GUILD_MEMBERS', 'GUILD_VOICE_STATES'], 8}; 9const client = new Discord.Client(options); 10const fs = require('fs'); 11const { disconnect } = require('process'); 12const { setFlagsFromString } = require('v8'); 13/* 14その他の処理 15*/ 16 } else if (msg.content.startsWith('--join')) { 17 const sclient = new textToSpeech.TextToSpeechClient(); 18 const outputFile = 'test.mp3'; 19 command = msg.content.split(' '); 20 const request = { 21 input: {text: command[1]}, 22 voice: {languageCode: 'ja-JP', ssmlGender: 'FEMALE'}, 23 audioConfig: {audioEncoding: 'MP3'}, 24 }; 25 const [response] = await sclient.synthesizeSpeech(request); 26 const writeFile = util.promisify(fs.writeFile); 27 await writeFile(outputFile, response.audioContent, 'binary'); 28 return onCommandInteraction(msg);

補足情報(FW/ツールのバージョンなど)

"@discordjs/voice": "^0.6.0"
"@google-cloud/text-to-speech": "^3.3.1"
"discord.js": "^13.2.0"
"ffmpeg-static": "^4.4.0"
"har-validator": "^5.1.5"
"opus": "^0.0.0"
"request": "^2.88.2"
"util": "^0.12.4"
"uuid": "^8.3.2"

Node.js 16.10.0

気になる質問をクリップする

クリップした質問は、後からいつでもMYページで確認できます。

またクリップした質問に回答があった際、通知やメールを受け取ることができます。

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

guest

回答1

0

自己解決

エラーのリンクにアクセスしたら認証の方法が乗っていたのでそれをやろうとしたのですが、有料だった為諦めました。

投稿2021/10/18 02:07

yuina8686

総合スコア12

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

あなたの回答

tips

太字

斜体

打ち消し線

見出し

引用テキストの挿入

コードの挿入

リンクの挿入

リストの挿入

番号リストの挿入

表の挿入

水平線の挿入

プレビュー

15分調べてもわからないことは
teratailで質問しよう!

ただいまの回答率
85.46%

質問をまとめることで
思考を整理して素早く解決

テンプレート機能で
簡単に質問をまとめる

質問する

関連した質問