34 lines
1.2 KiB
Lua
34 lines
1.2 KiB
Lua
|
|
local lang = jarvis.context.language
|
||
|
|
local raw = jarvis.system.clipboard.get() or ""
|
||
|
|
local text = raw:gsub("^%s+", ""):gsub("%s+$", "")
|
||
|
|
|
||
|
|
if text == "" then
|
||
|
|
jarvis.system.notify(
|
||
|
|
lang == "ru" and "Буфер" or "Clipboard",
|
||
|
|
lang == "ru" and "Пусто" or "Empty"
|
||
|
|
)
|
||
|
|
jarvis.audio.play_not_found()
|
||
|
|
return { chain = false }
|
||
|
|
end
|
||
|
|
|
||
|
|
local preview_chars = 400
|
||
|
|
local to_speak = text
|
||
|
|
if #to_speak > preview_chars then
|
||
|
|
to_speak = to_speak:sub(1, preview_chars) .. (lang == "ru" and " ... и так далее" or " ... and so on")
|
||
|
|
end
|
||
|
|
|
||
|
|
local sapi_text = to_speak:gsub("'", "''"):gsub("\r?\n", " ")
|
||
|
|
local ps = string.format(
|
||
|
|
[[Add-Type -AssemblyName System.Speech; $s = New-Object System.Speech.Synthesis.SpeechSynthesizer; foreach ($v in $s.GetInstalledVoices()) { if ($v.VoiceInfo.Culture.TwoLetterISOLanguageName -eq 'ru') { try { $s.SelectVoice($v.VoiceInfo.Name); break } catch {} } } $s.Speak('%s')]],
|
||
|
|
sapi_text
|
||
|
|
)
|
||
|
|
local cmd = string.format('powershell -NoProfile -ExecutionPolicy Bypass -Command "%s"', ps:gsub('"', '\\"'))
|
||
|
|
jarvis.system.exec(cmd)
|
||
|
|
|
||
|
|
jarvis.system.notify(
|
||
|
|
lang == "ru" and "Буфер" or "Clipboard",
|
||
|
|
text:sub(1, 120)
|
||
|
|
)
|
||
|
|
jarvis.audio.play_ok()
|
||
|
|
return { chain = false }
|