Improve speed of TTS output

This commit is contained in:
Markus Fleschutz 2021-11-27 14:16:50 +01:00
parent ae2ba5bf30
commit 5a2dcb0465
15 changed files with 36 additions and 29 deletions

View File

@ -13,6 +13,6 @@
$Answer = "Good bye.", "See you.", "Bye bye." | Get-Random $Answer = "Good bye.", "See you.", "Bye bye." | Get-Random
write-output "$Answer"
& "$PSScriptRoot/speak-english.ps1" "$Answer" & "$PSScriptRoot/speak-english.ps1" "$Answer"
write-output "$Answer"
exit 0 # success exit 0 # success

View File

@ -13,6 +13,6 @@
$Answer = "Good bye.", "See you.", "Bye bye." | Get-Random $Answer = "Good bye.", "See you.", "Bye bye." | Get-Random
write-output "$Answer"
& "$PSScriptRoot/speak-english.ps1" "$Answer" & "$PSScriptRoot/speak-english.ps1" "$Answer"
write-output "$Answer"
exit 0 # success exit 0 # success

View File

@ -13,6 +13,6 @@
$Answer = "And a special good evening to you too." $Answer = "And a special good evening to you too."
write-output "$Answer"
& "$PSScriptRoot/speak-english.ps1" "$Answer" & "$PSScriptRoot/speak-english.ps1" "$Answer"
write-output "$Answer"
exit 0 # success exit 0 # success

View File

@ -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 $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" & "$PSScriptRoot/speak-english.ps1" "$Answer"
write-output "$Answer"
exit 0 # success exit 0 # success

View File

@ -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 $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" & "$PSScriptRoot/speak-english.ps1" "$Answer"
write-output "$Answer"
exit 0 # success exit 0 # success

View File

@ -11,10 +11,8 @@
https://github.com/fleschutz/PowerShell https://github.com/fleschutz/PowerShell
#> #>
try { $Answer = "I'm fine, thanks."
& "$PSScriptRoot/speak-english.ps1" "I'm fine, thanks."
exit 0 # success & "$PSScriptRoot/speak-english.ps1" "$Answer"
} catch { write-output "$Answer"
"⚠️ Error: $($Error[0]) ($($MyInvocation.MyCommand.Name):$($_.InvocationInfo.ScriptLineNumber))" exit 0 # success
exit 1
}

View File

@ -11,5 +11,8 @@
https://github.com/fleschutz/PowerShell 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 exit 0 # success

View File

@ -16,7 +16,9 @@ try {
[system.threading.thread]::currentthread.currentculture=[system.globalization.cultureinfo]"en-US" [system.threading.thread]::currentthread.currentculture=[system.globalization.cultureinfo]"en-US"
$Weekday = (Get-Date -format "dddd") $Weekday = (Get-Date -format "dddd")
$CurrentDate = (Get-Date).ToShortDateString() $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 exit 0 # success
} catch { } catch {
"⚠️ Error: $($Error[0]) ($($MyInvocation.MyCommand.Name):$($_.InvocationInfo.ScriptLineNumber))" "⚠️ Error: $($Error[0]) ($($MyInvocation.MyCommand.Name):$($_.InvocationInfo.ScriptLineNumber))"

View File

@ -15,7 +15,9 @@
try { try {
[system.threading.thread]::currentThread.currentCulture=[system.globalization.cultureInfo]"en-US" [system.threading.thread]::currentThread.currentCulture=[system.globalization.cultureInfo]"en-US"
$CurrentTime = $((Get-Date).ToShortTimeString()) $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 exit 0 # success
} catch { } catch {
"⚠️ Error: $($Error[0]) ($($MyInvocation.MyCommand.Name):$($_.InvocationInfo.ScriptLineNumber))" "⚠️ Error: $($Error[0]) ($($MyInvocation.MyCommand.Name):$($_.InvocationInfo.ScriptLineNumber))"

View File

@ -3,7 +3,6 @@
Speaks text with an English text-to-speech voice Speaks text with an English text-to-speech voice
.DESCRIPTION .DESCRIPTION
This scripts speaks the given text with an English text-to-speech (TTS) voice. This scripts speaks the given text with an English text-to-speech (TTS) voice.
Requires that an English TTS voice is installed.
.PARAMETER text .PARAMETER text
Specifies the text to speak Specifies the text to speak
.EXAMPLE .EXAMPLE
@ -19,12 +18,11 @@ param([string]$text = "")
try { try {
if ("$text" -eq "") { $text = read-host "Enter the English text to speak" } if ("$text" -eq "") { $text = read-host "Enter the English text to speak" }
$CurrentVoice = New-Object -ComObject SAPI.SPVoice $TTSVoice = New-Object -ComObject SAPI.SPVoice
$Voices = $CurrentVoice.GetVoices() foreach ($Voice in $TTSVoice.GetVoices()) {
foreach ($Voice in $Voices) {
if ($Voice.GetDescription() -notlike "*- English*") { continue } if ($Voice.GetDescription() -notlike "*- English*") { continue }
$CurrentVoice.Voice = $Voice $TTSVoice.Voice = $Voice
[void]$CurrentVoice.Speak($text) [void]$TTSVoice.Speak($text)
exit 0 # success exit 0 # success
} }
throw "No English text-to-speech voice found - please install one" throw "No English text-to-speech voice found - please install one"

View File

@ -16,9 +16,10 @@ try {
$Generator = New-Object System.Random $Generator = New-Object System.Random
$Index = [int]$Generator.next(0, $Table.Count - 1) $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 exit 0 # success
} catch { } catch {
"⚠️ Error: $($Error[0]) ($($MyInvocation.MyCommand.Name):$($_.InvocationInfo.ScriptLineNumber))" "⚠️ Error: $($Error[0]) ($($MyInvocation.MyCommand.Name):$($_.InvocationInfo.ScriptLineNumber))"

View File

@ -13,15 +13,16 @@
try { try {
if ($IsLinux) { if ($IsLinux) {
$details = (uname -sr) $Answer = (uname -sr)
} else { } else {
$OS = Get-WmiObject -class Win32_OperatingSystem $OS = Get-WmiObject -class Win32_OperatingSystem
$OSname = $OS.Caption $OSname = $OS.Caption
$OSarchitecture = $OS.OSArchitecture $OSarchitecture = $OS.OSArchitecture
$OSversion = $OS.Version $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 exit 0 # success
} catch { } catch {
"⚠️ Error: $($Error[0]) ($($MyInvocation.MyCommand.Name):$($_.InvocationInfo.ScriptLineNumber))" "⚠️ Error: $($Error[0]) ($($MyInvocation.MyCommand.Name):$($_.InvocationInfo.ScriptLineNumber))"

View File

@ -18,8 +18,10 @@ try {
$Index = [int]$Generator.next(0, $Table.Count - 1) $Index = [int]$Generator.next(0, $Table.Count - 1)
$Quote = $Table[$Index].Quote $Quote = $Table[$Index].Quote
$Author = $Table[$Index].Author $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 exit 0 # success
} catch { } catch {
"⚠️ Error: $($Error[0]) ($($MyInvocation.MyCommand.Name):$($_.InvocationInfo.ScriptLineNumber))" "⚠️ Error: $($Error[0]) ($($MyInvocation.MyCommand.Name):$($_.InvocationInfo.ScriptLineNumber))"

View File

@ -22,8 +22,8 @@ try {
$Answer = "I'm up for $($Uptime.Days) days, $($Uptime.Hours) hours and $($Uptime.Minutes) minutes." $Answer = "I'm up for $($Uptime.Days) days, $($Uptime.Hours) hours and $($Uptime.Minutes) minutes."
write-output "$Answer"
& "$PSScriptRoot/speak-english.ps1" "$Answer" & "$PSScriptRoot/speak-english.ps1" "$Answer"
write-output "$Answer"
exit 0 # success exit 0 # success
} catch { } catch {
"⚠️ Error: $($Error[0]) ($($MyInvocation.MyCommand.Name):$($_.InvocationInfo.ScriptLineNumber))" "⚠️ Error: $($Error[0]) ($($MyInvocation.MyCommand.Name):$($_.InvocationInfo.ScriptLineNumber))"

View File

@ -13,6 +13,6 @@
$Answer = "It's a pleasure.", "Never mind." | Get-Random $Answer = "It's a pleasure.", "Never mind." | Get-Random
write-output "$Answer"
& "$PSScriptRoot/speak-english.ps1" "$Answer" & "$PSScriptRoot/speak-english.ps1" "$Answer"
write-output "$Answer"
exit 0 # success exit 0 # success