ローカルで日本語を発話するようになった
This commit is contained in:
@@ -130,31 +130,35 @@ app.post('/speak', async function(req, res) {
|
||||
|
||||
console.log(' -> ' + target.accountName + ' (type=' + target.deviceType + ', serial=' + target.serialNumber + ')');
|
||||
|
||||
// locale: '' はローカルPCでは日本語発話成功(サーバーからは要検証)
|
||||
// Alexa.SpeakSsml 系は全滅のため Alexa.Speak に戻す
|
||||
var sequenceObj = {
|
||||
'@type': 'com.amazon.alexa.behaviors.model.Sequence',
|
||||
startNode: {
|
||||
'@type': 'com.amazon.alexa.behaviors.model.OpaquePayloadOperationNode',
|
||||
type: 'Alexa.Speak',
|
||||
operationPayload: {
|
||||
deviceType: target.deviceType,
|
||||
deviceSerialNumber: target.serialNumber,
|
||||
customerId: customerId,
|
||||
locale: '',
|
||||
textToSpeak: text
|
||||
},
|
||||
},
|
||||
};
|
||||
// ★ 重要: sequenceJson の non-ASCII(日本語等)を \uXXXX エスケープに変換してから送る
|
||||
// raw UTF-8 のまま送ると Amazon 側でフィルタリングされ日本語が発話されない(解決済み 2026-03-03)
|
||||
var sequenceObj = {
|
||||
'@type': 'com.amazon.alexa.behaviors.model.Sequence',
|
||||
startNode: {
|
||||
'@type': 'com.amazon.alexa.behaviors.model.OpaquePayloadOperationNode',
|
||||
type: 'Alexa.Speak',
|
||||
operationPayload: {
|
||||
deviceType: target.deviceType,
|
||||
deviceSerialNumber: target.serialNumber,
|
||||
customerId: customerId,
|
||||
locale: 'ja-JP',
|
||||
textToSpeak: text
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
var rawSequenceJson = JSON.stringify(sequenceObj).replace(
|
||||
/[\u0080-\uffff]/g,
|
||||
function(c) { return '\\u' + ('0000' + c.charCodeAt(0).toString(16)).slice(-4); }
|
||||
);
|
||||
|
||||
var bodyStr = JSON.stringify({
|
||||
behaviorId: 'PREVIEW',
|
||||
sequenceJson: JSON.stringify(sequenceObj),
|
||||
sequenceJson: rawSequenceJson,
|
||||
status: 'ENABLED',
|
||||
});
|
||||
|
||||
// リクエストボディをログ出力(認証・パラメータ確認用)
|
||||
console.log('[DEBUG] sequenceJson:', JSON.stringify(sequenceObj, null, 2));
|
||||
console.log('[DEBUG] textToSpeak:', text);
|
||||
|
||||
var ttsRes = await httpsRequest('/api/behaviors/preview', {
|
||||
method: 'POST',
|
||||
|
||||
Reference in New Issue
Block a user