community.windows.win_say module – Text to speech module for Windows to speak messages and optionally play sounds
Note
This module is part of the community.windows collection (version 1.11.1).
You might already have this collection installed if you are using the ansible
package.
It is not included in ansible-core
.
To check whether it is installed, run ansible-galaxy collection list
.
To install it, use: ansible-galaxy collection install community.windows
.
To use it in a playbook, specify: community.windows.win_say
.
Synopsis
Uses .NET libraries to convert text to speech and optionally play .wav sounds. Audio Service needs to be running and some kind of speakers or headphones need to be attached to the windows target(s) for the speech to be audible.
Parameters
Parameter |
Comments |
---|---|
Full path to a Useful on conference calls to alert other speakers that ansible has finished speaking. |
|
The text to be spoken. Use either Optional so that you can use this module just to play sounds. |
|
Full path to a windows format text file containing the text to be spoken. Use either Optional so that you can use this module just to play sounds. |
|
How fast or slow to speak the text. Must be an integer value in the range -10 to 10. -10 is slowest, 10 is fastest. Default: |
|
Full path to a Useful on conference calls to alert other speakers that ansible has something to say. |
|
Which voice to use. See notes for how to discover installed voices. If the requested voice is not available the default voice will be used. Example voice names from Windows 10 are |
Notes
Note
Needs speakers or headphones to do anything useful.
To find which voices are installed, run the following Powershell commands.
Add-Type -AssemblyName System.Speech $speech = New-Object -TypeName System.Speech.Synthesis.SpeechSynthesizer $speech.GetInstalledVoices() | ForEach-Object { $_.VoiceInfo } $speech.Dispose()
Speech can be surprisingly slow, so it’s best to keep message text short.
See Also
See also
- community.windows.win_msg
Sends a message to logged in users on Windows hosts.
- community.windows.win_toast
Sends Toast windows notification to logged in users on Windows 10 or later hosts.
Examples
- name: Warn of impending deployment
community.windows.win_say:
msg: Warning, deployment commencing in 5 minutes, please log out.
- name: Using a different voice and a start sound
community.windows.win_say:
start_sound_path: C:\Windows\Media\ding.wav
msg: Warning, deployment commencing in 5 minutes, please log out.
voice: Microsoft Hazel Desktop
- name: With start and end sound
community.windows.win_say:
start_sound_path: C:\Windows\Media\Windows Balloon.wav
msg: New software installed
end_sound_path: C:\Windows\Media\chimes.wav
- name: Text from file example
community.windows.win_say:
start_sound_path: C:\Windows\Media\Windows Balloon.wav
msg_file: AppData\Local\Temp\morning_report.txt
end_sound_path: C:\Windows\Media\chimes.wav
Return Values
Common return values are documented here, the following are the fields unique to this module:
Key |
Description |
---|---|
The text that the module attempted to speak. Returned: success Sample: |
|
The voice used to speak the text. Returned: success Sample: |
|
The voice used to speak the text. Returned: when requested voice could not be loaded Sample: |