前提・実現したいこと
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
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。