local lang = jarvis.context.language local cmd_id = jarvis.context.command_id math.randomseed(os.time() + math.floor(jarvis.context.time.second * 7919)) local title, text, say if cmd_id == "coin_flip" then local r = math.random(2) text = (r == 1) and (lang == "ru" and "Орёл" or "Heads") or (lang == "ru" and "Решка" or "Tails") title = lang == "ru" and "Монетка" or "Coin" say = text elseif cmd_id == "roll_dice" then local r = math.random(1, 6) text = tostring(r) title = lang == "ru" and "Кубик" or "Dice" say = (lang == "ru" and "Выпало " or "Rolled ") .. r else local r = math.random(1, 100) text = tostring(r) title = lang == "ru" and "Случайное число" or "Random number" say = (lang == "ru" and "Число " or "Number ") .. r end jarvis.system.notify(title, text) local sapi = say:gsub("'", "''") local sps = 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 ) jarvis.system.exec(string.format('powershell -NoProfile -Command "%s"', sps:gsub('"', '\\"'))) jarvis.audio.play_ok() return { chain = false }