30 lines
957 B
Lua
30 lines
957 B
Lua
|
|
local lang = jarvis.context.language
|
||
|
|
local triggers = {
|
||
|
|
"продиктуй по буквам", "произнеси по буквам", "произнеси буквы", "по буквам",
|
||
|
|
"spell out", "spell it",
|
||
|
|
"вимов по буквах",
|
||
|
|
}
|
||
|
|
local word = jarvis.text.strip_trigger(jarvis.context.phrase or "", triggers)
|
||
|
|
if word == "" then
|
||
|
|
jarvis.system.notify("Spelling", lang == "ru" and "Что произнести?" or "What to spell?")
|
||
|
|
jarvis.audio.play_error()
|
||
|
|
return { chain = false }
|
||
|
|
end
|
||
|
|
|
||
|
|
local letters = {}
|
||
|
|
for ch in word:gmatch(".") do
|
||
|
|
if ch ~= " " then table.insert(letters, ch) end
|
||
|
|
end
|
||
|
|
if #letters == 0 then
|
||
|
|
jarvis.audio.play_error()
|
||
|
|
return { chain = false }
|
||
|
|
end
|
||
|
|
|
||
|
|
local spoken = table.concat(letters, ". ") .. "."
|
||
|
|
|
||
|
|
jarvis.system.notify(lang == "ru" and "По буквам" or "Spelling",
|
||
|
|
word .. "\n" .. spoken)
|
||
|
|
jarvis.speak(spoken, { lang = lang })
|
||
|
|
jarvis.audio.play_ok()
|
||
|
|
return { chain = false }
|