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