It is currently October 3rd, 2024, 10:29 pm

Speech Plugin 2.4

Plugins and Addons popular with the Community
User avatar
jsmorley
Developer
Posts: 22802
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Speech Plugin 2.4

Post by jsmorley »

This is a plugin that will output any string to the built-in Windows Text-to-Speech functionality.

Plugin=Speech

The number value of the measure will be the total number of voices installed on your system.
The string value of the measure will be the currently selected voice name.

Most simple working example:

Code: Select all

[Rainmeter]
Update=1000

[SpeechHost]
Measure=Plugin
Plugin=Speech

[MeterSpeak]
Meter=Image
W=50
H=50
SolidColor=255,255,255,255
LeftMouseUpAction=[!CommandMeasure SpeechHost "Hello World!"]

Options

Name
Name of the desired Text-to-Speech voice to use.

This can be any installed voice on your system.

You can find out what Name(s) are supported on your system by opening a Powershell.exe window and pasting in the following:

Code: Select all

Add-Type -AssemblyName System.Speech
$speak = New-Object System.Speech.Synthesis.SpeechSynthesizer
$speak.GetInstalledVoices() | 
  Select-Object -ExpandProperty VoiceInfo | 
  Select-Object -Property Culture, Name, Gender, Age
1.jpg

You can also set Debug=1 on the measure to output information about the voices on your system to the Rainmeter Log.

Copy and paste the "Name" entry as the Name option in the plugin measure.

Example:
Name=Microsoft David Desktop

Notes:

If an invalid Name is used, the plugin will default to the first supported voice installed on your system that best matches other options.

By default, Windows will come with the following voices installed:
Windows 10
Microsoft David Desktop - Male - en-US
Microsoft Zira Desktop - Female - en-US
Windows 7
Microsoft Anna - Female - en-US

Additional voices can be obtained by installing Language Packs in Windows 10:
https://www.thewindowsclub.com/install-uninstall-languages-windows-10

While not for the faint of heart, other voices that may already be lurking on your system can be unlocked for use with this plugin:
https://winaero.com/blog/unlock-extra-voices-windows-10/


Gender

Gender of the desired Text-to-Speech voice to use.

This can be one of Male or Female.

Example:
Gender=Male

Notes:

This is ignored if a valid Name option is used.
If a valid Gender is defined, but no voice of that gender exists on the system, the first installed voice will be used.

Index

Alone, this is the number of the voice in the list of voices supported on your system.
Combined with Gender, this is the number of the voice of that gender in the list of voices supported on your system.

Examples:
Index=3
The third voice on your system.

Gender=Male
Index=2
The second male voice on your system.

Note: This is ignored if a valid Name option is used.

Volume

Volume level for the speech.

This is an integer value from 0 to 100 as a percentage.
The default is 100

Example:
Volume=60

Rate

The rate of speed at which the text will be spoken.

This is an integer value from -10 (slow) to 10 (fast).
The default is 0

Example:
Rate=-1

Debug

If set to 1, when the measure is refreshed, it will output information about the supported voices on your system to the Rainmeter Log.

The default is 0

Example:
Debug=1


Plugin Commands

!CommandMeasure

The plugin does nothing as a part of the normal update of the skin or measure. It is activated to speak by using !CommandMeasure with a string of text as the only parameter.

Examples:
LeftMouseUpAction=[!CommandMeasure MeasureName "Hello World"]
OnChangeAction=[!CommandMeasure MeasureName "You've got mail!"]
IfTrueAction=[!CommandMeasure MeasureName "The value is [SomeOtherMeasure]"]

Note: Any currently speaking text can be stopped by passing an empty string to the measure:
LeftMouseUpAction=[!CommandMeasure MeasureName ""]
Refreshing the skin will also stop any currently speaking text.

Final Note

Given that there is no way to know what voices any given user might or might not have installed on their system, the safest way to distribute a skin that uses this plugin is to only set Index=1, or if you prefer, Gender=Female and Index=1 on the measure. Those are certain to work on all systems. Then just provide instructions to your users to try different Index and/or gender values until they find a supported voice they prefer. All Windows systems are certain to have at least one female voice installed.


Download

Download the .rmskin to get the plugin installed on your system. The 64bit and 32bit .dll files will also be placed in your @Vault folder for use in your skins:

SpeechWSelect_Feb 8, 2019.rmskin


zelda.jpg


The 32bit and 64bit Speech.dll files can be downloaded without any .rmskin:
PluginSpeech.zip

The source code for the plugin is available at:
https://github.com/jsmorley/PluginSpeech
This requires the use of the Rainmeter Plugin SDK to build.
You do not have the required permissions to view the files attached to this post.
User avatar
balala
Rainmeter Sage
Posts: 16623
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: Speech Plugin

Post by balala »

Although speech can be done even with nircmd, this being a plugin, probably it's more versatile.
Just one question: I suppose there is no possible to make it to speech in any other language then English. Am i right?
Otherwise congratulations, it will be a useful plugin for me and I intend to use it into one of my projects. I hope there is no obstacle.
User avatar
jsmorley
Developer
Posts: 22802
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: Speech Plugin

Post by jsmorley »

balala wrote: January 26th, 2019, 7:16 pm Although speech can be done even with nircmd, this being a plugin, probably it's more versatile.
Just one question: I suppose there is no possible to make it to speech in any other language then English. Am i right?
Otherwise congratulations, it will be a useful plugin for me and I intend to use it into one of my projects. I hope there is no obstacle.
I'm working on expanding it to include asking for particular "cultures" and such. It's doable, but I had an important threading issue I needed to get resolved first. I hope to have something more clever later tonight or sometime tomorrow.
User avatar
balala
Rainmeter Sage
Posts: 16623
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: Speech Plugin

Post by balala »

jsmorley wrote: January 26th, 2019, 7:48 pm I'm working on expanding it to include asking for particular "cultures" and such. It's doable, but I had an important threading issue I needed to get resolved first. I hope to have something more clever later tonight or sometime tomorrow.
Alright! Many thanks. This would be wonderful. :great:
User avatar
jsmorley
Developer
Posts: 22802
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: Speech Plugin

Post by jsmorley »

In its most simple form, it should be very easy to use:

Code: Select all

[Rainmeter]
Update=1000

[SpeechHost]
Measure=Plugin
Plugin=Speech

[MeterSquare]
Meter=Image
W=50
H=50
SolidColor=255,255,255,255
LeftMouseUpAction=[!CommandMeasure SpeechHost "Hello World"]
That will use the default Female voice defined in your "Ease of Access Center" settings in Windows, the default Volume of 100% and the default Rate of 0.
User avatar
jsmorley
Developer
Posts: 22802
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: Speech Plugin

Post by jsmorley »

I have updated the plugin and the .rmskin in the first post of this thread.

Added a new option Name which will allow you to set a specific voice name to use. See guidance in the documentation in the first post about this...

Reworked the plugin to use a single process thread per measure, so sending some text to speak using a single measure, while it is still speaking an earlier action, will stop the first action and play the second. If you have multiple measures, or use the plugin in multiple skins, more than one speech output can be spoken at a time.

This means you can also "stop" an action by sending [!CommandMeasure MeasureName ""], or an empty string.
User avatar
jsmorley
Developer
Posts: 22802
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: Speech Plugin

Post by jsmorley »

One other thing I would note.

There is a voice that comes with Windows 10, called Microsoft Eva Mobile that is not available to you by default. It is apparently a prototype of the voice they intended to use with Cortana, but they ended up not using it. It is there, and can very simply and safely be unlocked for use with a small change to the registry.

https://windowsreport.com/unlock-new-text-to-speech-voice-windows-10/

Just download the Download Registry tweak for Eva voice and run the .reg file to unlock the voice in your registry.

I do recommend it, as it is in my view a much more natural sounding voice than Microsoft Zira Desktop.
User avatar
jsmorley
Developer
Posts: 22802
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: Speech Plugin

Post by jsmorley »

Balala, I installed the German language pack for Windows 10, and after rebooting, Microsoft Hedda Desktop was available as a voice, and when used with the plugin, it spoke the date and time with a German accent, and even translated "numbers" to German. I assume if I also used a "locale" with the Time measure, I would get fully German output.
User avatar
eclectic-tech
Rainmeter Sage
Posts: 5536
Joined: April 12th, 2012, 9:40 pm
Location: Cedar Point, Ohio, USA

Re: Speech Plugin

Post by eclectic-tech »

Great work on this plugin Jeff!!

I have updated my talking forecast skin to use this plugin; that reduced the package size by 95% from 450 MB to just over 20 MB! :o
I especially like the ability to silence the speech with a simple command! :thumbup:

The possibility to work with other languages is also very interesting... 8-)
:Watching:
Keep 'em coming!

And Thanks again!
User avatar
jsmorley
Developer
Posts: 22802
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: Speech Plugin

Post by jsmorley »

eclectic-tech wrote: January 27th, 2019, 2:36 am Great work on this plugin Jeff!!

I have updated my talking forecast skin to use this plugin; that reduced the package size by 95% from 450 MB to just over 20 MB! :o
I especially like the ability to silence the speech with a simple command! :thumbup:

The possibility to work with other languages is also very interesting... 8-)
:Watching:
Keep 'em coming!

And Thanks again!
Glad you like it. Languages are tricky. I don't see an easy way for the plugin to "detect" the language you are using in Windows, and thus automatically select the correct "culture" when you choose Male or Female. Many languages only install one Female voice that works with Text-to-Speech anyway. German for instance installs several new voices, but only Microsoft Hedda Desktop is supported by Text-to-Speech. In any case I'm hesitant to "force" anything. While its a bit of a pain to use Powershell to figure out the "Name(s)" you have available to use, and that would make it pretty difficult to distribute a skin that purports to be language-aware, I think what I have is a reasonable first step.

The "safe" thing to do is to just use Gender=Female and leave it at that. That is certain to work on all systems. Gender=Male won't work on Win7 for instance.