Есть ли возможность получить голос из google-text-to-speech и сохранить его в базе данных с помощью mongoose? - PullRequest
0 голосов
/ 25 мая 2019

Я создаю приложение для изучения словарного запаса.Я хочу сохранить свой словарный запас + голос / речь (аудиофайл) для каждого слова в базе данных (mongodb, я использую mongoose).

Моя идея состоит в том, чтобы подготовить словарный список, мой словарный список будет содержать слова, каждое словобудет объектом, который содержит 3 свойства: внешнее значение, собственное значение и голос / речь (аудиофайл).Можно ли хранить голос / речь в базе данных и использовать ее, когда мне это нужно?

Я уже использовал google-text-to-speech, но в документации я могу прочитать только о том, как сохранить файл на моем компьютере.

// Imports the Google Cloud client library
const textToSpeech = require('@google-cloud/text-to-speech');

// Import other required libraries
const fs = require('fs');
const util = require('util');
async function main() {
  // Creates a client
  const client = new textToSpeech.TextToSpeechClient();

  // The text to synthesize
  const text = 'Hello, world!';

  // Construct the request
  const request = {
    input: {text: text},
    // Select the language and SSML Voice Gender (optional)
    voice: {languageCode: 'en-US', ssmlGender: 'NEUTRAL'},
    // Select the type of audio encoding
    audioConfig: {audioEncoding: 'MP3'},
  };

  // Performs the Text-to-Speech request
  const [response] = await client.synthesizeSpeech(request);
  // Write the binary audio content to a local file
  const writeFile = util.promisify(fs.writeFile);
  await writeFile('output.mp3', response.audioContent, 'binary');
  console.log('Audio content written to file: output.mp3');
}

Я хочу получить голос из текста в речь и сохранить его в одном объекте с иностранным значением и собственным значением в моей базе данных.

...