Skip to content

Commit

Permalink
made safe_say safe
Browse files Browse the repository at this point in the history
  • Loading branch information
luv2code committed Sep 20, 2012
1 parent c11b110 commit be07712
Showing 1 changed file with 11 additions and 7 deletions.
18 changes: 11 additions & 7 deletions pom.ps1
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ param(
# Runtime of a single session. # Runtime of a single session.
$time_in_minutes = 25 $time_in_minutes = 25
$script_name = $MyInvocation.MyCommand.Name $script_name = $MyInvocation.MyCommand.Name

$has_speech = true


# Print current status. # Print current status.
# First argument is number of minutes elapsed. # First argument is number of minutes elapsed.
Expand Down Expand Up @@ -60,12 +60,16 @@ function finish {


# Audibly say something, if possible. # Audibly say something, if possible.
function safe_say($text) { function safe_say($text) {
Add-Type -AssemblyName System.Speech if(has_speech) {
$synthesizer = New-Object -TypeName System.Speech.Synthesis.SpeechSynthesizer try{

Add-Type -AssemblyName System.Speech
# This line converts the text to speech $synthesizer = New-Object -TypeName System.Speech.Synthesis.SpeechSynthesizer
$synthesizer.SpeakAsync($text) $synthesizer.SpeakAsync($text)

}
catch {
$has_speech = false
}
}
} }


# Try to ring the terminal bell. # Try to ring the terminal bell.
Expand Down

0 comments on commit be07712

Please sign in to comment.