3.6 KiB
The speak-epub.ps1 PowerShell Script
This PowerShell script speaks the content of the given Epub file by text-to-speech (TTS).
Parameters
speak-epub.ps1 [[-Filename] <String>] [<CommonParameters>]
-Filename <String>
Specifies the path to the Epub file
Required? false
Position? 1
Default value
Accept pipeline input? false
Accept wildcard characters? false
[<CommonParameters>]
This script supports the common parameters: Verbose, Debug, ErrorAction, ErrorVariable, WarningAction,
WarningVariable, OutBuffer, PipelineVariable, and OutVariable.
Example
PS> ./speak-epub C:\MyBook.epub
Notes
Author: Markus Fleschutz | License: CC0
Related Links
https://github.com/fleschutz/PowerShell
Source Code
<# .SYNOPSIS Speaks the content of the given Epub file by text-to-speech (TTS). .DESCRIPTION This PowerShell script speaks the content of the given Epub file by text-to-speech (TTS). .PARAMETER Filename Specifies the path to the Epub file .EXAMPLE PS> ./speak-epub C:\MyBook.epub .LINK https://github.com/fleschutz/PowerShell .NOTES Author: Markus Fleschutz | License: CC0 #>
param([string]$Filename = "")
function Speak { param([string]$Text) write-output "$Text" $Voice = new-object -ComObject SAPI.SPVoice $Voices = $Voice.GetVoices() foreach ($OtherVoice in $Voices) { $Description = $OtherVoice.GetDescription() if ($Description -like "*- English (United States)") { $Voice.Voice = $OtherVoice break } } [void]$Voice.Speak($Text) }
function ReadBook() { param([string]$book, [string]$bookPath, [int]$lineNumber = 0) $data = Get-Content $book for([int]$i=$lineNumber;$i -lt $data.Count;$i++) { Set-Content -Path $bookPath"\progress.txt" -Value ($book+","+$i) $line = $data[$i] if ($line.Contains("