mirror of
https://github.com/fleschutz/PowerShell.git
synced 2024-12-23 23:29:02 +01:00
Improve speed of TTS output
This commit is contained in:
parent
ae2ba5bf30
commit
5a2dcb0465
@ -13,6 +13,6 @@
|
||||
|
||||
$Answer = "Good bye.", "See you.", "Bye bye." | Get-Random
|
||||
|
||||
write-output "$Answer"
|
||||
& "$PSScriptRoot/speak-english.ps1" "$Answer"
|
||||
write-output "$Answer"
|
||||
exit 0 # success
|
||||
|
@ -13,6 +13,6 @@
|
||||
|
||||
$Answer = "Good bye.", "See you.", "Bye bye." | Get-Random
|
||||
|
||||
write-output "$Answer"
|
||||
& "$PSScriptRoot/speak-english.ps1" "$Answer"
|
||||
write-output "$Answer"
|
||||
exit 0 # success
|
||||
|
@ -13,6 +13,6 @@
|
||||
|
||||
$Answer = "And a special good evening to you too."
|
||||
|
||||
write-output "$Answer"
|
||||
& "$PSScriptRoot/speak-english.ps1" "$Answer"
|
||||
write-output "$Answer"
|
||||
exit 0 # success
|
||||
|
@ -13,6 +13,6 @@
|
||||
|
||||
$Answer = "Good morning.", "Good morning to you too.", "Well, good morning to you too.", "Good morning! How are you?", "Morning." | Get-Random
|
||||
|
||||
write-output "$Answer"
|
||||
& "$PSScriptRoot/speak-english.ps1" "$Answer"
|
||||
write-output "$Answer"
|
||||
exit 0 # success
|
||||
|
@ -13,6 +13,6 @@
|
||||
|
||||
$Answer = "Good night to you, too.", "Good night to you, my friend.", "Have a good night. Sleep well.", "Good night and sweet dreams." | Get-Random
|
||||
|
||||
write-output "$Answer"
|
||||
& "$PSScriptRoot/speak-english.ps1" "$Answer"
|
||||
write-output "$Answer"
|
||||
exit 0 # success
|
||||
|
@ -11,10 +11,8 @@
|
||||
https://github.com/fleschutz/PowerShell
|
||||
#>
|
||||
|
||||
try {
|
||||
& "$PSScriptRoot/speak-english.ps1" "I'm fine, thanks."
|
||||
exit 0 # success
|
||||
} catch {
|
||||
"⚠️ Error: $($Error[0]) ($($MyInvocation.MyCommand.Name):$($_.InvocationInfo.ScriptLineNumber))"
|
||||
exit 1
|
||||
}
|
||||
$Answer = "I'm fine, thanks."
|
||||
|
||||
& "$PSScriptRoot/speak-english.ps1" "$Answer"
|
||||
write-output "$Answer"
|
||||
exit 0 # success
|
||||
|
@ -11,5 +11,8 @@
|
||||
https://github.com/fleschutz/PowerShell
|
||||
#>
|
||||
|
||||
& "$PSScriptRoot/speak-english.ps1" "Hasta la vista, baby."
|
||||
$Answer = "Hasta la vista, baby."
|
||||
|
||||
& "$PSScriptRoot/speak-english.ps1" "$Answer"
|
||||
write-output "$Answer"
|
||||
exit 0 # success
|
||||
|
@ -16,7 +16,9 @@ try {
|
||||
[system.threading.thread]::currentthread.currentculture=[system.globalization.cultureinfo]"en-US"
|
||||
$Weekday = (Get-Date -format "dddd")
|
||||
$CurrentDate = (Get-Date).ToShortDateString()
|
||||
& "$PSScriptRoot/speak-english.ps1" "It's $Weekday, $CurrentDate"
|
||||
$Answer = "It's $Weekday, $CurrentDate"
|
||||
& "$PSScriptRoot/speak-english.ps1" "$Answer"
|
||||
write-output "$Answer"
|
||||
exit 0 # success
|
||||
} catch {
|
||||
"⚠️ Error: $($Error[0]) ($($MyInvocation.MyCommand.Name):$($_.InvocationInfo.ScriptLineNumber))"
|
||||
|
@ -15,7 +15,9 @@
|
||||
try {
|
||||
[system.threading.thread]::currentThread.currentCulture=[system.globalization.cultureInfo]"en-US"
|
||||
$CurrentTime = $((Get-Date).ToShortTimeString())
|
||||
& "$PSScriptRoot/speak-english.ps1" "It's $CurrentTime"
|
||||
$Answer = "It's $CurrentTime"
|
||||
& "$PSScriptRoot/speak-english.ps1" "$Answer"
|
||||
write-output "$Answer"
|
||||
exit 0 # success
|
||||
} catch {
|
||||
"⚠️ Error: $($Error[0]) ($($MyInvocation.MyCommand.Name):$($_.InvocationInfo.ScriptLineNumber))"
|
||||
|
@ -3,7 +3,6 @@
|
||||
Speaks text with an English text-to-speech voice
|
||||
.DESCRIPTION
|
||||
This scripts speaks the given text with an English text-to-speech (TTS) voice.
|
||||
Requires that an English TTS voice is installed.
|
||||
.PARAMETER text
|
||||
Specifies the text to speak
|
||||
.EXAMPLE
|
||||
@ -19,12 +18,11 @@ param([string]$text = "")
|
||||
try {
|
||||
if ("$text" -eq "") { $text = read-host "Enter the English text to speak" }
|
||||
|
||||
$CurrentVoice = New-Object -ComObject SAPI.SPVoice
|
||||
$Voices = $CurrentVoice.GetVoices()
|
||||
foreach ($Voice in $Voices) {
|
||||
$TTSVoice = New-Object -ComObject SAPI.SPVoice
|
||||
foreach ($Voice in $TTSVoice.GetVoices()) {
|
||||
if ($Voice.GetDescription() -notlike "*- English*") { continue }
|
||||
$CurrentVoice.Voice = $Voice
|
||||
[void]$CurrentVoice.Speak($text)
|
||||
$TTSVoice.Voice = $Voice
|
||||
[void]$TTSVoice.Speak($text)
|
||||
exit 0 # success
|
||||
}
|
||||
throw "No English text-to-speech voice found - please install one"
|
||||
|
@ -16,9 +16,10 @@ try {
|
||||
|
||||
$Generator = New-Object System.Random
|
||||
$Index = [int]$Generator.next(0, $Table.Count - 1)
|
||||
$Joke = $Table[$Index].Joke
|
||||
$Answer = $Table[$Index].Joke
|
||||
|
||||
& "$PSScriptRoot/speak-english.ps1" "$Joke"
|
||||
& "$PSScriptRoot/speak-english.ps1" "$Answer"
|
||||
write-output "$Answer"
|
||||
exit 0 # success
|
||||
} catch {
|
||||
"⚠️ Error: $($Error[0]) ($($MyInvocation.MyCommand.Name):$($_.InvocationInfo.ScriptLineNumber))"
|
||||
|
@ -13,15 +13,16 @@
|
||||
|
||||
try {
|
||||
if ($IsLinux) {
|
||||
$details = (uname -sr)
|
||||
$Answer = (uname -sr)
|
||||
} else {
|
||||
$OS = Get-WmiObject -class Win32_OperatingSystem
|
||||
$OSname = $OS.Caption
|
||||
$OSarchitecture = $OS.OSArchitecture
|
||||
$OSversion = $OS.Version
|
||||
$details = "$OSname for $OSarchitecture version $OSversion"
|
||||
$Answer = "$OSname for $OSarchitecture version $OSversion"
|
||||
}
|
||||
& "$PSScriptRoot/speak-english.ps1" "$details"
|
||||
& "$PSScriptRoot/speak-english.ps1" "$Answer"
|
||||
write-output "$Answer"
|
||||
exit 0 # success
|
||||
} catch {
|
||||
"⚠️ Error: $($Error[0]) ($($MyInvocation.MyCommand.Name):$($_.InvocationInfo.ScriptLineNumber))"
|
||||
|
@ -18,8 +18,10 @@ try {
|
||||
$Index = [int]$Generator.next(0, $Table.Count - 1)
|
||||
$Quote = $Table[$Index].Quote
|
||||
$Author = $Table[$Index].Author
|
||||
$Answer = "$Quote (by $Author)"
|
||||
|
||||
& "$PSScriptRoot/speak-english.ps1" "$Quote (by $Author)"
|
||||
& "$PSScriptRoot/speak-english.ps1" "$Answer"
|
||||
write-output "$Answer"
|
||||
exit 0 # success
|
||||
} catch {
|
||||
"⚠️ Error: $($Error[0]) ($($MyInvocation.MyCommand.Name):$($_.InvocationInfo.ScriptLineNumber))"
|
||||
|
@ -22,8 +22,8 @@ try {
|
||||
|
||||
$Answer = "I'm up for $($Uptime.Days) days, $($Uptime.Hours) hours and $($Uptime.Minutes) minutes."
|
||||
|
||||
write-output "$Answer"
|
||||
& "$PSScriptRoot/speak-english.ps1" "$Answer"
|
||||
write-output "$Answer"
|
||||
exit 0 # success
|
||||
} catch {
|
||||
"⚠️ Error: $($Error[0]) ($($MyInvocation.MyCommand.Name):$($_.InvocationInfo.ScriptLineNumber))"
|
||||
|
@ -13,6 +13,6 @@
|
||||
|
||||
$Answer = "It's a pleasure.", "Never mind." | Get-Random
|
||||
|
||||
write-output "$Answer"
|
||||
& "$PSScriptRoot/speak-english.ps1" "$Answer"
|
||||
write-output "$Answer"
|
||||
exit 0 # success
|
||||
|
Loading…
Reference in New Issue
Block a user