ローカルで日本語を発話するようになった
This commit is contained in:
@@ -61,7 +61,7 @@ async function main() {
|
||||
});
|
||||
|
||||
// プレハブを探す
|
||||
const target = devices.find(d => d.serialNumber === 'G0922H08525302K5');
|
||||
const target = devices.find(d => d.serialNumber === 'G0922H08525302K5'); // オフィスの右エコー(以前成功したデバイス)
|
||||
console.log('\nTarget device:', target ? `${target.accountName}` : 'NOT FOUND');
|
||||
|
||||
if (!target) { process.exit(1); }
|
||||
@@ -72,7 +72,7 @@ async function main() {
|
||||
const customerId = bootstrap.authentication?.customerId;
|
||||
console.log(' Customer ID:', customerId);
|
||||
|
||||
// 3. TTSリクエスト
|
||||
// 3. TTSリクエスト(新Cookie + Alexa.Speak + locale:'ja-JP' + 日本語テキスト)
|
||||
const sequenceObj = {
|
||||
'@type': 'com.amazon.alexa.behaviors.model.Sequence',
|
||||
startNode: {
|
||||
@@ -83,19 +83,30 @@ async function main() {
|
||||
deviceSerialNumber: target.serialNumber,
|
||||
customerId: customerId,
|
||||
locale: 'ja-JP',
|
||||
textToSpeak: 'テストです。聞こえますか',
|
||||
textToSpeak: '\u3053\u308c\u306f\u65e5\u672c\u8a9e\u306e\u30c6\u30b9\u30c8\u3067\u3059', // 「これは日本語のテストです」
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
// non-ASCII を \uXXXX に強制エスケープ
|
||||
// Amazon のパーサーが sequenceJson 内の raw UTF-8 を処理できない場合の回避策
|
||||
const rawSequenceJson = JSON.stringify(sequenceObj).replace(
|
||||
/[\u0080-\uffff]/g,
|
||||
c => '\\u' + ('0000' + c.charCodeAt(0).toString(16)).slice(-4)
|
||||
);
|
||||
const bodyObj = {
|
||||
behaviorId: 'PREVIEW',
|
||||
sequenceJson: JSON.stringify(sequenceObj),
|
||||
sequenceJson: rawSequenceJson,
|
||||
status: 'ENABLED',
|
||||
};
|
||||
const body = JSON.stringify(bodyObj);
|
||||
|
||||
console.log('\n[3] TTS送信...');
|
||||
// 送信内容確認(textToSpeakの部分が\uXXXXエスケープになっているか)
|
||||
const ttsIdx = body.indexOf('textToSpeak');
|
||||
console.log(' textToSpeak部分:', body.substring(ttsIdx, ttsIdx + 80));
|
||||
|
||||
|
||||
|
||||
const ttsRes = await makeRequest('https://alexa.amazon.co.jp/api/behaviors/preview', {
|
||||
method: 'POST',
|
||||
|
||||
Reference in New Issue
Block a user