28 lines
580 B
TypeScript
28 lines
580 B
TypeScript
export async function main(args: {
|
|
device: string;
|
|
text: string;
|
|
}) {
|
|
|
|
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;
|
|
}
|