Aquest script utilitza Add-WindowsCapability
per instal·lar els paquets de veu oficials de Microsoft via DISM (eina integrada).
varificar la versió de powershell
$PSVersionTable.PSVersion
powershellCopiaModifica
# Idiomes i veus que vols instal·lar
$languageTags = @(
"en-US", # English (US)
"en-GB", # English (UK)
"es-ES", # Spanish (Spain)
"ca-ES", # Catalan (Spain)
"fr-FR", # French (France)
"de-DE" # German
)
foreach ($lang in $languageTags) {
Write-Host "Instal·lant veu per a $lang..." -ForegroundColor Cyan
try {
# Instal·la la llengua si no existeix
$langList = Get-WinUserLanguageList
if (-not ($langList.LanguageTag -contains $lang)) {
$langList.Add($lang)
Set-WinUserLanguageList $langList -Force
}
# Instal·la la veu OneCore associada
$capability = "Language.$lang~Basic~~~"
Add-WindowsCapability -Online -Name $capability -ErrorAction Stop
# Opcional: activa reconeixement de parla
$speechCap = "Language.$lang~Speech~~~"
Add-WindowsCapability -Online -Name $speechCap -ErrorAction SilentlyContinue
}
catch {
Write-Warning "Error instal·lant per a $lang: $_"
}
}
🧩 Què fa aquest script?
✔️ Funciona amb PowerShell 5.x (Windows PowerShell): parcialment en 7
- Afegeix l’idioma si cal.
- Instal·la la veu (OneCore).
- Intenta afegir també el reconeixement de veu (opcional).
- Funciona en Windows 10 i 11, però cal accés d’administrador.
2. 🔊 Comprova que les veus apareixen a OneCore:
Get-ChildItem "HKLM:\SOFTWARE\Microsoft\Speech_OneCore\Voices\Tokens" | ForEach-Object {
$keyPath = $_.PSPath
$subkeys = Get-ChildItem -Path $keyPath -ErrorAction SilentlyContinue
$displayName = $null
foreach ($subkey in $subkeys) {
$subProps = Get-ItemProperty -Path $subkey.PSPath -ErrorAction SilentlyContinue
if ($subProps.DisplayName) {
$displayName = $subProps.DisplayName
break
}
}
[PSCustomObject]@{
VoiceId = $_.PSChildName
Name = $displayName
Path = $keyPath
}
}
i a powerhshell

——- —- —-
MSTTS_V110_caES_Herena Microsoft.PowerShell.Core\Registry::HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Speech_OneCor…
MSTTS_V110_deDE_HeddaM Microsoft.PowerShell.Core\Registry::HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Speech_OneCor…
MSTTS_V110_deDE_KatjaM Microsoft.PowerShell.Core\Registry::HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Speech_OneCor…
MSTTS_V110_deDE_StefanM Microsoft.PowerShell.Core\Registry::HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Speech_OneCor…
MSTTS_V110_enGB_GeorgeM Microsoft.PowerShell.Core\Registry::HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Speech_OneCor…
MSTTS_V110_enGB_HazelM Microsoft.PowerShell.Core\Registry::HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Speech_OneCor…
MSTTS_V110_enGB_SusanM Microsoft.PowerShell.Core\Registry::HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Speech_OneCor…
MSTTS_V110_enUS_DavidM Microsoft.PowerShell.Core\Registry::HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Speech_OneCor…
MSTTS_V110_enUS_MarkM Microsoft.PowerShell.Core\Registry::HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Speech_OneCor…
MSTTS_V110_enUS_ZiraM Microsoft.PowerShell.Core\Registry::HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Speech_OneCor…
MSTTS_V110_esES_HelenaM Microsoft.PowerShell.Core\Registry::HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Speech_OneCor…
MSTTS_V110_esES_LauraM Microsoft.PowerShell.Core\Registry::HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Speech_OneCor…
MSTTS_V110_esES_PabloM Microsoft.PowerShell.Core\Registry::HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Speech_OneCor…
veus clàssiques (SAPI5)
# Carrega la biblioteca TTS clàssica
Add-Type -AssemblyName System.Speech
# Crea un objecte per accedir al sintetitzador de veu
$voiceSynth = New-Object System.Speech.Synthesis.SpeechSynthesizer
# Obtenir totes les veus instal·lades
$voices = $voiceSynth.GetInstalledVoices()
# Mostra informació detallada de cada veu
foreach ($v in $voices) {
[PSCustomObject]@{
Name = $v.VoiceInfo.Name
Culture = $v.VoiceInfo.Culture
Gender = $v.VoiceInfo.Gender
Age = $v.VoiceInfo.Age
Description = $v.VoiceInfo.Description
Attributes = $v.VoiceInfo.OtherProperties
}
}
PS C:\Users\urqte> # Carrega la biblioteca TTS clàssica
PS C:\Users\urqte> Add-Type -AssemblyName System.Speech
PS C:\Users\urqte>
PS C:\Users\urqte> # Crea un objecte per accedir al sintetitzador de veu
PS C:\Users\urqte> $voiceSynth = New-Object System.Speech.Synthesis.SpeechSynthesizer
PS C:\Users\urqte>
PS C:\Users\urqte> # Obtenir totes les veus instal·lades
PS C:\Users\urqte> $voices = $voiceSynth.GetInstalledVoices()
PS C:\Users\urqte>
PS C:\Users\urqte> # Mostra informació detallada de cada veu
PS C:\Users\urqte> foreach ($v in $voices) {
[PSCustomObject]@{ Name = $v.VoiceInfo.Name Culture = $v.VoiceInfo.Culture Gender = $v.VoiceInfo.Gender Age = $v.VoiceInfo.Age Description = $v.VoiceInfo.Description Attributes = $v.VoiceInfo.OtherProperties }
}
1 Name : Microsoft Helena Desktop
Culture : es-ES
Gender : Female
Age : Adult
Description : Microsoft Helena Desktop – Spanish (Spain)
Attributes :
2 Name : Microsoft Hazel Desktop
Culture : en-GB
Gender : Female
Age : Adult
Description : Microsoft Hazel Desktop – English (Great Britain)
Attributes :
3 Name : Microsoft David Desktop
Culture : en-US
Gender : Male
Age : Adult
Description : Microsoft David Desktop – English (United States)
Attributes :
4 Name : Microsoft Zira Desktop
Culture : en-US
Gender : Female
Age : Adult
Description : Microsoft Zira Desktop – English (United States)
Attributes :
5 Name : Microsoft Hedda Desktop
Culture : de-DE
Gender : Female
Age : Adult
Description : Microsoft Hedda Desktop – German
Attributes :
6 Name : Vocalizer Expressive Jordi Harpo 22kHz
Culture : ca-ES
Gender : Male
Age : Adult
Description : Vocalizer Expressive Jordi Harpo 22kHz
Attributes :
Script PowerShell — Prova de veus SAPI (Desktop)
Add-Type -AssemblyName System.Speech
$tts = New-Object System.Speech.Synthesis.SpeechSynthesizer
$proves = @(
@{ Nom = “Microsoft Helena Desktop”; Missatge = “Hola! Esta es la voz española de Microsoft Helena.” },
@{ Nom = “Microsoft Hazel Desktop”; Missatge = “Hello! This is the British English voice of Microsoft Hazel.” },
@{ Nom = “Microsoft David Desktop”; Missatge = “Hi there! I’m Microsoft David, the American English voice.” },
@{ Nom = “Microsoft Zira Desktop”; Missatge = “Welcome! I am Zira, the female voice for American English.” },
@{ Nom = “Microsoft Hedda Desktop”; Missatge = “Hallo! Ich bin Hedda, die deutsche Stimme von Microsoft.” },
@{ Nom = “Vocalizer Expressive Jordi Harpo 22kHz”; Missatge = “Bon dia! Sóc en Jordi, la veu en català del sistema.” }
)
foreach ($prova in $proves) {
Write-Host “`n🔊 Prova amb veu: $($prova.Nom)” -ForegroundColor Cyan
try {
$tts.SelectVoice($prova.Nom)
$tts.Speak($prova.Missatge)
} catch {
Write-Warning “⚠️ No s’ha pogut trobar o usar la veu: $($prova.Nom)”
}
}