Initial commit
This commit is contained in:
40
Powershell/Speech/list_voices-old.ps1
Normal file
40
Powershell/Speech/list_voices-old.ps1
Normal file
@@ -0,0 +1,40 @@
|
||||
# Check if the System.Speech assembly is available
|
||||
try {
|
||||
Add-Type -AssemblyName System.Speech
|
||||
} catch {
|
||||
Write-Error "Windows Text-to-Speech (SAPI5) is not installed or not available. Please ensure you have Windows 10/11 with the latest updates."
|
||||
exit 1
|
||||
}
|
||||
|
||||
# Create a SpeechSynthesizer instance
|
||||
$synth = New-Object System.Speech.Synthesis.SpeechSynthesizer
|
||||
|
||||
# Check if the synthesizer can retrieve voices
|
||||
try {
|
||||
# Get the list of available voices
|
||||
#$voices = $synth.GetVoices()
|
||||
$voices = $synth.GetInstalledVoices()|ForEach-Object { $_.VoiceInfo }
|
||||
if ($voices.Count -eq 0) {
|
||||
Write-Host "No TTS voices available." -ForegroundColor Yellow
|
||||
} else {
|
||||
Write-Host "Available TTS Voices:" -ForegroundColor Green
|
||||
Write-Host "------------------------" -ForegroundColor Green
|
||||
|
||||
foreach ($voice in $voices) {
|
||||
$voiceName = $voice.Name
|
||||
$voiceInfo = $voice.Info
|
||||
$language = $voiceInfo.Language
|
||||
$displayName = $voiceInfo.DisplayName
|
||||
$gender = $voiceInfo.Gender
|
||||
Write-Host $voice.name
|
||||
Write-Host "Name: $voiceName" -ForegroundColor White
|
||||
Write-Host " Language: $language" -ForegroundColor Gray
|
||||
Write-Host " Display Name: $displayName" -ForegroundColor Cyan
|
||||
Write-Host " Gender: $gender" -ForegroundColor Magenta
|
||||
Write-Host "------------------------" -ForegroundColor Green
|
||||
}
|
||||
}
|
||||
} catch {
|
||||
Write-Error "Error retrieving voices: $_"
|
||||
exit 1
|
||||
}
|
||||
3
Powershell/Speech/list_voices.ps1
Normal file
3
Powershell/Speech/list_voices.ps1
Normal file
@@ -0,0 +1,3 @@
|
||||
Add-Type -AssemblyName System.speech
|
||||
$speak = New-Object System.Speech.Synthesis.SpeechSynthesizer
|
||||
$speak.GetInstalledVoices()|ForEach-Object { $_.VoiceInfo }
|
||||
21
Powershell/Speech/say-old.ps1
Normal file
21
Powershell/Speech/say-old.ps1
Normal file
@@ -0,0 +1,21 @@
|
||||
# Check if the System.Speech assembly is available
|
||||
try {
|
||||
Add-Type -AssemblyName System.Speech
|
||||
} catch {
|
||||
Write-Error "Windows Text-to-Speech (SAPI5) is not installed or not available. Please ensure you have Windows 10/11 with the latest updates."
|
||||
exit 1
|
||||
}
|
||||
|
||||
# Get user input
|
||||
$text = Read-Host "Enter text to speak:"
|
||||
|
||||
# Create a SpeechSynthesizer instance
|
||||
$synth = New-Object System.Speech.Synthesis.SpeechSynthesizer
|
||||
|
||||
try {
|
||||
# Speak the text
|
||||
$synth.Speak($text)
|
||||
Write-Host "Text spoken successfully."
|
||||
} catch {
|
||||
Write-Error "Error speaking text: $_"
|
||||
}
|
||||
31
Powershell/Speech/say.ps1
Normal file
31
Powershell/Speech/say.ps1
Normal file
@@ -0,0 +1,31 @@
|
||||
# Check if the System.Speech assembly is available
|
||||
try {
|
||||
Add-Type -AssemblyName System.Speech
|
||||
} catch {
|
||||
Write-Error "Windows Text-to-Speech (SAPI5) is not installed or not available. Please ensure you have Windows 10/11 with the latest updates."
|
||||
exit 1
|
||||
}
|
||||
|
||||
# Check for command-line arguments
|
||||
if (-not $args) {
|
||||
Write-Error "Error: No text provided. Usage: .\speak.ps1 'Your Text Here'"
|
||||
exit 1
|
||||
}
|
||||
|
||||
# Use first command-line argument as text to speak
|
||||
$text = $args[0]
|
||||
|
||||
# Create SpeechSynthesizer
|
||||
$synth = New-Object System.Speech.Synthesis.SpeechSynthesizer
|
||||
|
||||
try {
|
||||
#$synth.SelectVoice("Microsoft David Desktop")
|
||||
$synth.SelectVoice("Microsoft Hazel Desktop")
|
||||
#$synth.SelectVoice("Microsoft Zira Desktop")
|
||||
# Speak the text
|
||||
$synth.Speak($text)
|
||||
#Write-Host "Text spoken successfully."
|
||||
} catch {
|
||||
Write-Error "Error speaking text: $_"
|
||||
exit 1
|
||||
}
|
||||
Reference in New Issue
Block a user