воскресенье, 11 августа 2019 г.

willie script, psh

$count_in_serial = 4 #
$overall_count = 20 #
$sleep_sec = 6 #

Add-Type -AssemblyName System.speech
$speak = New-Object System.Speech.Synthesis.SpeechSynthesizer
$speak.SelectVoice('Microsoft Zira Desktop')

$rnd = [random]::new()

for($i=0; $i -lt $overall_count; $i++){
    $str = ""
    for($j=0; $j -lt $count_in_serial; $j++){
      $str += " " + $rnd.Next(1,10) 
    }
    write-host $str
    $speak.Speak($str)
    Start-Sleep -Seconds $sleep_sec
}

willie, python script

count_in_serial = 3 # count in serie
overall_count = 20 # series count
sleep_sec = 5 # series delay

incomp_punch = { 9 : [8], 8: [9], 3 : [4], 4: [3], 3: [3], 4: [4] }

import random
import win32com.client as wincl
import time
speak = wincl.Dispatch("SAPI.SpVoice")
speak.Rate = -2

random.seed()

for i in range(overall_count):
    str = ""
    ser = [random.randint(1, 9) for x in range(count_in_serial)]
    for j in range(count_in_serial-1):
        while ser[j+1] in incomp_punch.get(ser[j],[]):
            ser[j+1] = random.randint(1, 10)
    print(ser.__str__())
    speak.Speak(ser.__str__().replace(',',' '))
    time.sleep(sleep_sec)