HEX
Server: LiteSpeed
System: Linux kapuas.iixcp.rumahweb.net 5.14.0-427.42.1.el9_4.x86_64 #1 SMP PREEMPT_DYNAMIC Fri Nov 1 14:58:02 EDT 2024 x86_64
User: mirz4654 (1666)
PHP: 8.1.33
Disabled: system,exec,escapeshellarg,escapeshellcmd,passthru,proc_close,proc_get_status,proc_nice,proc_open,proc_terminate,shell_exec,popen,pclose,dl,pfsockopen,leak,apache_child_terminate,posix_kill,posix_mkfifo,posix_setsid,posix_setuid,posix_setpgid,ini_alter,show_source,define_syslog_variables,symlink,syslog,openlog,openlog,closelog,ocinumcols,listen,chgrp,apache_note,apache_setenv,debugger_on,debugger_off,ftp_exec,dll,ftp,myshellexec,socket_bind,mail,posix_getwpuid
Upload Files
File: //usr/lib/python3.9/site-packages/ansible_collections/community/windows/plugins/modules/win_say.ps1
#!powershell

# Copyright: (c) 2016, Jon Hawkesworth (@jhawkesworth) <[email protected]>
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)

#AnsibleRequires -CSharpUtil Ansible.Basic

$spec = @{
    options = @{
        msg = @{ type = "str" }
        msg_file = @{ type = "path" }
        start_sound_path = @{ type = "path" }
        end_sound_path = @{ type = "path" }
        voice = @{ type = "str" }
        speech_speed = @{ type = "int"; default = 0 }
    }
    mutually_exclusive = @(
        , @('msg', 'msg_file')
    )
    required_one_of = @(
        , @('msg', 'msg_file', 'start_sound_path', 'end_sound_path')
    )
    supports_check_mode = $true
}

$module = [Ansible.Basic.AnsibleModule]::Create($args, $spec)


$msg = $module.Params.msg
$msg_file = $module.Params.msg_file
$start_sound_path = $module.Params.start_sound_path
$end_sound_path = $module.Params.end_sound_path
$voice = $module.Params.voice
$speech_speed = $module.Params.speech_speed

if ($speech_speed -lt -10 -or $speech_speed -gt 10) {
    $module.FailJson("speech_speed needs to be an integer in the range -10 to 10.  The value $speech_speed is outside this range.")
}

$words = $null

if ($msg_file) {
    if (-not (Test-Path -LiteralPath $msg_file)) {
        $msg = -join @(
            "Message file $msg_file could not be found or opened. "
            "Ensure you have specified the full path to the file, and the ansible windows user has permission to read the file."
        )
        $module.FailJson($msg)
    }
    $words = Get-Content -LiteralPath $msg_file | Out-String
}

if ($msg) {
    $words = $msg
}

if ($start_sound_path) {
    if (-not (Test-Path -LiteralPath $start_sound_path)) {
        $msg = -join @(
            "Start sound file $start_sound_path could not be found or opened. "
            "Ensure you have specified the full path to the file, and the ansible windows user has permission to read the file."
        )
        $module.FailJson($msg)
    }
    if (-not $module.CheckMode) {
      (new-object Media.SoundPlayer $start_sound_path).playSync()
    }
}

if ($words) {
    Add-Type -AssemblyName System.speech
    $tts = New-Object System.Speech.Synthesis.SpeechSynthesizer
    if ($voice) {
        try {
            $tts.SelectVoice($voice)
        }
        catch [System.Management.Automation.MethodInvocationException] {
            $module.Result.voice_info = "Could not load voice '$voice', using system default voice."
            $module.Warn("Could not load voice '$voice', using system default voice.")
        }
    }

    $module.Result.voice = $tts.Voice.Name
    if ($speech_speed -ne 0) {
        $tts.Rate = $speech_speed
    }
    if (-not $module.CheckMode) {
        $tts.Speak($words)
    }
    $tts.Dispose()
}

if ($end_sound_path) {
    if (-not (Test-Path -LiteralPath $end_sound_path)) {
        $msg = -join @(
            "End sound file $start_sound_path could not be found or opened. "
            "Ensure you have specified the full path to the file, and the ansible windows user has permission to read the file."
        )
        $module.FailJson($msg)
    }
    if (-not $module.CheckMode) {
        (new-object Media.SoundPlayer $end_sound_path).playSync()
    }
}

$module.Result.message_text = $words.ToString()

$module.ExitJson()