I still had a minor issue and forgot to put an answer when I fixed it. Thanks and I hope someone can find it useful:
Speaks artist+album+track name, cleans up the text so it won't speak unnecessary stuff:
function replace_it(str)
{
str = str.replace(",","(")
str = str.replace("-","(")
str = str.replace(")","(")
str = str.replace("[","(")
str = str.replace("]","(")
str = str.replace("\\","(")
str = str.replace("/","(")
str = str.replace(":","(")
var str_index = str.indexOf("(")
if (str_index != -1)
{
str = str.substring(0,str_index)
}
return str
}
function on_playback_new_track(metadb) {
WSH = new ActiveXObject("WScript.Shell");
var artist = fb.TitleFormat("%artist%").Eval(true)
var album = fb.TitleFormat("%album%").Eval(true)
var track_name = fb.TitleFormat("%Title%").Eval(true);
artist = replace_it(artist)
album = replace_it(album)
track_name = replace_it(track_name)
track_path="Artist "+artist+" Album " +album+" track name "+ track_name
fb.Pause()
WSH.run("powershell.exe -nologo -NonInteractive -ExecutionPolicy ByPass -WindowStyle Hidden -f c:\\users\\jrg26\\documents\\windowspowershell\\text2speech.ps1 \"" + track_path + "\"",0,true);
fb.play()
}
And the powershell script, in case anybody wants this solution:
if ($args.count -gt 0)
{
echo $args[0]
Add-Type -AssemblyName System.speech
$speak = New-Object System.Speech.Synthesis.SpeechSynthesizer
$speak.Speak($args[0])
}
You can increase and lower the rate of the voice as well. Type $speak|get-member, to get a list of properties and methods after you add the type and create the object:
Rate Property int Rate {get;set;}
Voice Property System.Speech.Synthesis.VoiceInfo Voice {get;}
Volume Property int Volume {get;set;}
SelectVoice Method void SelectVoice(string name)
SelectVoiceByHints Method void SelectVoiceByHints(System.Speech.Synthesis.VoiceGender gender),
$speak.rate = -5
changes rate to -5, goes from -10 to 10.
$speak.selectvoicebyhints("female")
changes to the US female voice.