* port win-say to use CSharpUtil AnsibleBasic and add warning when requested voice not found
* win_say: fixes following code review: use C# style properties consistently; prefix changelog fragments
* fix invalid yaml in change log fragment
* win_say: fixes following code review: use generic module parameter validation where possible
* remove redundant setting of Result.changed to false, simplified some logic for readability.
* fix serialisation issue when message text is drawn from a file; allows tests to be run not in check mode and fix up some test descriptions
Fail-Json$result"No msg_file, msg, start_sound_path, or end_sound_path parameters have been specified. Please specify at least one so the module has something to do"
if(-not(Test-Path-Path$msg_file)){
$module.FailJson("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.")
}
$words=Get-Content$msg_file|Out-String
}
}
if($msg_file){
if($msg){
if(Test-Path-Path$msg_file){
$words=$msg
$words=Get-Content$msg_file|Out-String
}else{
Fail-Json$result"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."
}
}
}
if($start_sound_path){
if($start_sound_path){
if(Test-Path-Path$start_sound_path){
if(-not(Test-Path-Path$start_sound_path)){
if(-not$check_mode){
$module.FailJson("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.")
Fail-Json$result"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."
$result.voice_info="Could not load voice $voice, using system default voice."
$module.Result.voice_info="Could not load voice '$voice', using system default voice."
$module.Warn("Could not load voice '$voice', using system default voice.")
}
}
}
}
$result.voice=$tts.Voice.Name
$module.Result.voice=$tts.Voice.Name
if($speech_speed-ne0){
if($speech_speed-ne0){
$tts.Rate=$speech_speed
$tts.Rate=$speech_speed
}
}
if(-not$check_mode){
if(-not$module.CheckMode){
$tts.Speak($words)
$tts.Speak($words)
}
}
$tts.Dispose()
$tts.Dispose()
}
}
if($end_sound_path){
if($end_sound_path){
if(Test-Path-Path$end_sound_path){
if(-not(Test-Path-Path$end_sound_path)){
if(-not$check_mode){
$module.FailJson("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.")
Fail-Json$result"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."