Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

made safe_say safe

  • Loading branch information...
commit be0771267335aabf7685b06cd63193db729c7ec5 1 parent c11b110
@luv2code authored
Showing with 11 additions and 7 deletions.
  1. +11 −7 pom.ps1
View
18 pom.ps1
@@ -28,7 +28,7 @@ param(
# Runtime of a single session.
$time_in_minutes = 25
$script_name = $MyInvocation.MyCommand.Name
-
+$has_speech = true
# Print current status.
# First argument is number of minutes elapsed.
@@ -60,12 +60,16 @@ function finish {
# Audibly say something, if possible.
function safe_say($text) {
- Add-Type -AssemblyName System.Speech
- $synthesizer = New-Object -TypeName System.Speech.Synthesis.SpeechSynthesizer
-
- # This line converts the text to speech
- $synthesizer.SpeakAsync($text)
-
+ if(has_speech) {
+ try{
+ Add-Type -AssemblyName System.Speech
+ $synthesizer = New-Object -TypeName System.Speech.Synthesis.SpeechSynthesizer
+ $synthesizer.SpeakAsync($text)
+ }
+ catch {
+ $has_speech = false
+ }
+ }
}
# Try to ring the terminal bell.
Please sign in to comment.
Something went wrong with that request. Please try again.