Functions/GenXdev.Console/Resume-TextToSpeech.ps1
|
<############################################################################## Part of PowerShell module : GenXdev.Console Original cmdlet filename : Resume-TextToSpeech.ps1 Original author : René Vaessen / GenXdev Version : 3.29.2026 ################################################################################ Copyright (c) 2026 René Vaessen / GenXdev Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. ################################################################################> ############################################################################### <# .SYNOPSIS Resumes text-to-speech output that was previously paused via Suspend-TextToSpeech. .DESCRIPTION Resumes audio playback on whichever GenXdev speech synthesizer was paused by Suspend-TextToSpeech. Only the instance with an actual paused output will wake up; the other instances are harmless no-ops. Also clears the internal "user paused" flag so that subsequent Start-TextToSpeech -Force calls will auto-resume as normal. .EXAMPLE PS C:\> say "Long text" ; Suspend-TextToSpeech ; Resume-TextToSpeech Starts speaking, pauses it, then resumes. .EXAMPLE PS C:\> Suspend-TextToSpeech; say "Urgent!" -Force; Resume-TextToSpeech Pauses ongoing speech, interrupts with urgent message, then resumes the original speech. .NOTES This cmdlet is commonly used in conjunction with Start-TextToSpeech (alias: say), Suspend-TextToSpeech, and Stop-TextToSpeech (alias: sst) for speech control. #> function Resume-TextToSpeech { [CmdletBinding(SupportsShouldProcess = $true)] [Alias("resumespeech")] param() begin { Microsoft.PowerShell.Utility\Write-Verbose 'Initiating speech resume request' } process { try { if ($PSCmdlet.ShouldProcess('Text-to-speech output', 'Resume')) { # Resume whichever synthesizer was paused. Clears # Misc.IsUserPaused so that -Force auto-resume # behavior is restored. [GenXdev.Helpers.Misc]::ResumeAllSpeech() Microsoft.PowerShell.Utility\Write-Verbose 'Successfully resumed speech output' } } catch { Microsoft.PowerShell.Utility\Write-Verbose 'Error occurred while attempting to resume speech' } } end { } } |