キャラクターの発言に字幕を追加するアニメーション プロジェクトに取り組んでいます。問題なく AWS Polly から mp3 ファイルを取得できます。
ただし、単語の各部分を個別に取得したい場合は機能しません。インスペクタータブを確認したところ、いくつかのパラメーターがpolly.awsへのリクエストに渡されていることがわかります。各単語と文の開始と終了をjson/マークアップファイルに取得する方法はありますか?
const AWS = require('aws-sdk')
const Fs = require('fs')
const Polly = new AWS.Polly({
signatureVersion: 'v4',
region: 'us-east-1'
})
// # this part works fine
let params = {
'Text': 'Hi, my name is Soley. We are building something amazing!',
'OutputFormat': 'mp3',
'VoiceId': 'Matthew'
}
// # from chrome's network tab:
// # and is there a way to get mp3 and mark-up text at the same time?
// "text": "Hi, my name is Soley. We are building something amazing!",
// "textContentType": "text",
// "voiceId": "Matthew",
// "languageCode": "en-US",
// "engine": "standard",
// "outputFormat": "json-8000",
// "lexiconNames": [],
// "speechMarksTypes": [
// "word",
// "sentence"
// ]
Polly.synthesizeSpeech(params, (err, data) => {
if (err) {
console.log(err)
} else if (data) {
console.log(data)
if (data.AudioStream instanceof Buffer) {
Fs.writeFile("speech."+params.OutputFormat, data.AudioStream, function (err) {
if (err) {
return console.log(err)
}
console.log("The file was saved!")
})
}
}
})
チェックするのに役立つリンク: https://aws.amazon.com/blogs/aws/new-amazon-polly-speech-marks/
cli を使用してもファイルは機能します: https://docs.aws.amazon.com/polly/latest/dg/speechmarkexamples.htmlしかし、NodeJs でそれが必要です