Auto-sync: 2026-03-02 12:00:01
This commit is contained in:
@@ -2,8 +2,21 @@ summary: Echo デバイスに TTS で読み上げ
|
||||
description: 指定した Echo デバイスにテキストを読み上げさせる
|
||||
lock: '!inline u/admin/alexa_speak.script.lock'
|
||||
kind: script
|
||||
no_main_func: true
|
||||
schema:
|
||||
type: object
|
||||
properties: {}
|
||||
required: []
|
||||
properties:
|
||||
args:
|
||||
type: object
|
||||
description: ''
|
||||
default: null
|
||||
properties:
|
||||
device:
|
||||
type: string
|
||||
description: ''
|
||||
originalType: string
|
||||
text:
|
||||
type: string
|
||||
description: ''
|
||||
originalType: string
|
||||
required:
|
||||
- args
|
||||
|
||||
@@ -1,16 +1,27 @@
|
||||
const ssml = `
|
||||
<speak>
|
||||
<lang xml:lang="ja-JP">
|
||||
${text}
|
||||
</lang>
|
||||
</speak>
|
||||
`;
|
||||
export async function main(args: {
|
||||
device: string;
|
||||
text: string;
|
||||
}) {
|
||||
|
||||
const res = await fetch("http://alexa_api:3500/speak", {
|
||||
method: "POST",
|
||||
headers: { "Content-Type": "application/json" },
|
||||
body: JSON.stringify({
|
||||
device,
|
||||
ssml
|
||||
}),
|
||||
});
|
||||
console.log("ARGS:", args);
|
||||
|
||||
const ssml = `<speak><lang xml:lang="ja-JP">${args.text}</lang></speak>`;
|
||||
|
||||
const res = await fetch("http://alexa_api:3500/speak", {
|
||||
method: "POST",
|
||||
headers: { "Content-Type": "application/json" },
|
||||
body: JSON.stringify({
|
||||
device: args.device,
|
||||
text: ssml
|
||||
}),
|
||||
});
|
||||
|
||||
const body = await res.text();
|
||||
console.log("API RESPONSE:", body);
|
||||
|
||||
if (!res.ok) {
|
||||
throw new Error("alexa-api error " + res.status + ": " + body);
|
||||
}
|
||||
|
||||
return body;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user