Text to Speech: tidying up

Back in this post, I showed how PowerShell (via .Net) allows you to convert a .txt file to a .wav file. A couple of days back, I needed to do this for another short book/long paper. I was listening to it while driving to work, and noticed a number of references to “euro”, “copyright”.. which were certainly not there in the original, or at least not in the volume I heard them. So I have found the “euro” or more precisely a “a euro” reference as far as I can tell, and it is the [space dash space] after “Europe”:

Manifesto01

So for now I’ll just do a global replace on that to go just to a full stop, so we get some of the intended pause. And now I have found the other references – they are the too-fancily rendered double quotes:

Manifesto02

So that is 3 characters to replace, and then I can re-record the wav file. For free, this is pretty good, I must say. The default Windows 10 voice may not be brilliant, but there are some that are extremely good – I might invest in one of those.

In fact one other very useful point – use of the clipboard, depending on how much text you are dealing with:

[System.Windows.Forms.Clipboard]::GetText() | Convert-TextToWav -WavFile "c:\temp\theend.wav"

Or, course, you could speak it straight out, rather than saving to a file (Gutenberg):

You are over-scrupulous, surely. I dare say Mr. Bingley will be very glad to see you; and I will send a few lines by you to assure him of my hearty consent to his marrying whichever he chooses of the girls; though I must throw in a good word for my little Lizzy.

Copy that to the clipboard, and then run these few PowerShell commands (obviously don’t save the following to the clipboard, or else do the above last):

$speech = [System.Windows.Forms.Clipboard]::GetText()
Add-Type -AssemblyName System.Speech
$mrsBenet = New-Object System.Speech.Synthesis.SpeechSynthesizer
$mrsBenet.Speak($speech)

Tada.

This person has some useful stuff on TTS.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s