…just another random person's thoughts & digressions.
If you’re playing around with TTS–in RadioDJ or any other Windows program–you might find that the pre-installed system voice on your computer leaves much to be desired. The instructions I’m about to give are a bit of a hack and only complete to the point in which I got it to work for the purpose I had in mind. I’ve gotten this little hack to work in Vista 32 and 7 64-bit versions…
First, seek out and install Microsoft Speech Server 11.0 x86 [aka Microsoft Speech Platform – Runtime (Version 11)].
Second, get and install the voices for Speech Server 11.0 [Microsoft Speech Platform – Runtime Languages (Version 11)].
Third–the fun part–open regedit and export the “Tokens” for the newly installed voices. Depending upon your version of windows, you’ll find the voices referenced under one or both of the following:
HKLM\SOFTWARE\Microsoft\Speech Server\v11.0\Voices
HKLM\SOFTWARE\Wow6432Node\Microsoft\Speech Server\v11.0\Voices
…if you’ve found them, right-click and export the “Tokens” folder to a file — say, something like voices1.reg and voices2.reg, respectively.
Edit those exported entries with your favorite text-editor, replacing the instances of \Speech Server\v11.0\ with \Speech\ . When you’re done, save, and then import the entries back into the registry (double-clicking will suffice).
You may want to reboot the machine–I didn’t have to on one, but did on the other.
After all that’s done, all you have to do is change your computer’s default voice–c’est voila!–no more Microsoft Anna!
Personally, the voice I like the sound of Zira Pro.
…and for the RadioDJ user, don’t forget–if you’re using the AutoDJ TTS feature–the voice number referenced in the XML files begins numbering at 0, and will go in order that it appears in the TTS plugin’s drop-down voice list.
References/Additional Info:
For the fun of it, I thought I’d give a 7-Day forecast to my RadioDJ installation for playback in the morning–and maybe at other points throughout the day. After a bit of tinkering, I’ve come up with a solution that’ll pull my local forecast and speak it into a waveform file, which I have imported into RDJ as a “variable duration”–see my previous post for a quick explanation of that RDJ file-type.
In a folder under RDJ, I put the executable and dlls from GNUWin32’s wget port, and a little .vbs script (for TTS conversion) from the Jampal mp3 Library.
Next, I put together a batch file and a powershell script that would process the NWS Forecast information and create the waveform:
nws.bat:
@echo off
CD C:\RadioDJ\Media\NWS
:: get the forecast
wget ftp://tgftp.nws.noaa.gov/data/forecasts/zone/ky/kyz037.txt
:: remove header, end characters
for /f "skip=14 delims=$$" %%a in (kyz037.txt) do (
echo %%a >>forecast.tmp1
)
:: put text into one line (for TTS readability)
setlocal DisableDelayedExpansion
(for /F "usebackq delims=" %%a in (forecast.tmp1) do (
set /P "=%%a" < NUL )) > forecast.tmp
:: filter NWS abbreviations (and certain words) and replace with TTS friendly pronunciation values
powershell -command .\nws-filter.ps1
:: read the forecast into a WAV (NOTE: uses the 'default' computer voice)
cscript ptts.vbs -w forecast.wav -s 48000 -c 1 -r 2 < forecast.txt
:: cleanup the temp files
del *.tmp*
del *.txt
nws-filter.ps1:
$lookupTable = @{
'50s' = 'FIFTIES'
'60s' = 'SIXTIES'
'70s' = 'SEVENTIES'
'80s' = 'EIGHTIES'
'90s' = 'NINETIES'
'100s' = 'ONE-HUNDREDS'
'mph' = 'MILES-PER-HOUR'
'winds' = 'WINNEDS'
}
$original_file = 'forecast.tmp'
$destination_file = 'forecast.txt'
Get-Content -Path $original_file | ForEach-Object {
$line = $_
$lookupTable.GetEnumerator() | ForEach-Object {
if ($line -match $_.Key)
{
$line = $line -replace $_.Key, $_.Value
}
}
$line
} | Set-Content -Path $destination_file
…personally, I love the change I have to make to “winds” 😉
The powershell script can be edited later, for when I inevitably run across other words that aren’t pronounced right. Other filtering may be mandatory with other voices/engines… For example, the default voice I’m using–Microsoft Speech Server ZiraPro–will skip over ellipsis, whereas Microsoft Anna reads them as dot-dot-dot. Your mileage may vary.
…I guess the next thing I have to figure out is how to handle “immediate” bulletins… 😉
…okay, so I just went to look for the previous writing, and it apparently never made it to my wordpress.com blog… hmm…
A month or so ago I wrote of how I was experimenting with playing locally saved podcast episodes in RadioDJ; while the process worked, it left a bit to be desired–especially when I moved things to an older/slower machine.
I’m still using Juice to download the podcasts–if it ain’t broke, etc., etc.–but I’ve done a bit of tweaking to everything else. First off, I changed the path to where I’m saving the episodes–simply because where I had things going was nuts! Second, I gave up on the creation of .m3u playlists, and went with using RadioDJ’s “Variable Duration File” abilities.
Huh? Say what?
Okay, RDJ has the ability to import a track once–as a “Variable Duration”–and will go back and scan it later to double check it’s length when it’s time to play again. …a feature just for this purpose!
With that new-found knowledge, I wrote a single quick-n-dirty batch file (using some Google-fu ninja tricks to help) that goes through the podcast sub-directories, keeps only the most recent episode, and renames it to the file that RDJ will be looking for. (I’ve also got RadioDJ running this batch as an event… so far, the performance hit isn’t as noticeable as my previous backwards methods.)
…so, anyway… to the batch-cave!
CD C:\RadioDJ\Media\Podcasts
for /f "delims=" %%i in ('dir C:\RadioDJ\Media\Podcasts /ad/s/b') do (
for /f "skip=1 delims=" %%j in ('dir "%%i\*.mp3" /b /o-d /a-d') do del "%%i\%%j"
)
for /f "delims=" %%k in ('dir C:\RadioDJ\Media\Podcasts /ad/s/b') do (
for /f "skip=1 delims=" %%l in ('dir "%%k\*.m4a" /b /o-d /a-d') do del "%%k\%%l"
)
FOR /D /R %%# in (*) DO (
PUSHD "%%#"
FOR %%@ in ("*") DO (
Echo Ren: ".\%%~n#\%%@" "%%~n#%%~x@"
Ren "%%@" "%%~n#%%~x@"
)
POPD
)
A couple days ago, I wrote a post about a quick and dirty–and half-working–solution to scrobbling tracks from RadioDJ… After further experimentation, I’ve found a cleaner automated way to do so. The method I’m employing scrobbles every hour, and reports the previous hour’s worth of tracks.
Additional software needed:
QTscrobbler–Command Line version available at Sourceforge
First, we need to build a compatible log-file–we’ll start to do this using the mySQL command line (assuming you’re using mySQL for your RadioDJ database–mine came packaged with all the other goodies in XAMPP). Immediately following is just the query, full-blown command line operation will be in the example batch file [scroll down for that hot goodness].
SELECT `artist`, `album`, `title`, `track_no`, cast(duration as decimal(10,0)), 'L' AS `listened_dummy_field`, UNIX_TIMESTAMP(date_played) FROM `history` WHERE `song_type`='0' AND `date_played` > DATE_ADD( NOW(), INTERVAL -1 HOUR ) ORDER BY `date_played` DESC INTO OUTFILE 'C:/RadioDJ/Media/last.fm/part.scrobbler.log' FIELDS TERMINATED BY '\t';
…as you can see, the query is dumping the info into a [tab-delimited] file; you’ll also see that for my own sanity, I’ve got it dumping into a directory created just for this, under the RadioDJ folder. Adjust for your own setup, of course. 😉
…also, you’ll see that the query is creating a dummy column–this is to satisfy QTscrobbler’s needs–it’s picky, whereas other scrobbling clients aren’t… and, yes, I’m going ahead and making mySQL do the UNIX time conversion–I had some issues when I tried to let other clients do the conversion for me.
Next, we need to put the audioscrobbler log file headers into the final part of the log file. (I did mention that QTscrobbler is a little picky, didn’t I?) For that, I created a static file in the aforementioned directory. Contents of that file–which I named “head.scrobbler.log”–is as follows:
#AUDIOSCROBBLER/1.0
#TZ/UTC
#CLIENT/RadioDJ
Now, we have to put the two *.scrobbler.log files together–I do this by dumping the head- file and then the part- file into the final .scrobbler.log file. [See the batch, further down this post.] With all that done, we can now–finally–scrobble the log file:
scrobbler-0.11.exe -c qtscrob.ini -f -l c:\radiodj\media\last.fm
NOTE: you’ll need a config file for QTscrobbler to use. I’m not entirely sure of what you can use or include in the config file–I ended up toying with the GUI version in order to create one that works. As an example, here’s my config file–minus the username and pass-hash:
[application]
version=0.11
utc_offset=0
tz_override=false
auto_open=true
del_apple_playlist=false
display_utc=false
mru=@Invalid()
[Last.fm]
enabled=true
username=YOUR_USERNAME_HERE
password_hash=MD5_HASH_OF_YOUR_PASSWORD
…ready to see the batch pulling all this off? I hope so, ’cause here it is:
@ECHO OFF
CD c:\radiodj\media\last.fm
::get_log
c:\xampp\mysql\bin\mysql.exe -e "SELECT `artist`, `album`, `title`, `track_no`, cast(duration as decimal(10,0)), 'L' AS `listened_dummy_field`, UNIX_TIMESTAMP(date_played) FROM `history` WHERE `song_type`='0' AND `date_played` > DATE_ADD( NOW(), INTERVAL -1 HOUR ) ORDER BY `date_played` DESC INTO OUTFILE 'C:/RadioDJ/Media/last.fm/part.scrobbler.log' FIELDS TERMINATED BY '\t';" --user=MYSQL_USERNAME_HERE --password=MYSQL_PASSWORD_HERE radiodj161
::build_log
type head.scrobbler.log>>.scrobbler.log
type part.scrobbler.log>>.scrobbler.log
del part.scrobbler.log
::scrobble
scrobbler-0.11.exe -c qtscrob.ini -f -l c:\radiodj\media\last.fm
::end
exit
To automate all this, I’m attempting to take advantage of RadioDJ’s ability to run commands as events. Currently, I’ve got an event set to run the batch hourly at xx:05:00. A tip to doing this–after you select RadioDJ to run cmd.exe, format the execution of the batch file [in the arguments field] like this:
cmd.exe /c start "scrobble" /min C:\RadioDJ\Media\last.fm\scrobble.bat ^& exit
…and you’ll be rewarded with a window that pops minimized, runs the batch, and exits when it’s finished!
One thing that I’ve been trying to figure out how to do is report the tracks I’ve listened to/played via RadioDJ to last.fm. With the little bit of time I’ve had the best solution I’ve been able to come up with thus far is creating a log file from the info stored in RadioDJ’s database, then uploading that log file via someone else’s “scrobbler”.
First, the SQL query to build a .scrobbler.log file:
SELECT `artist`, `album`, `title`, `track_no`, cast(duration as decimal(10,0)), 'L' AS `listened_dummy_field`, UNIX_TIMESTAMP(date_played) FROM `history` WHERE `song_type`='0' AND `date_played` LIKE '2015-06-25%' ORDER BY `date_played` DESC INTO OUTFILE 'C:/.scrobbler.log' FIELDS TERMINATED BY '\t';
The code above currently pulls the info from the history table–assuming that the RadioDJ database has already been selected for use, of course–and outputs all the plays for the set date (set by the `date_played` LIKE '2015-06-25%') into a tab delimited text file. As of now, I’ve found two services that will use the file created: the online scroblr.net, and a standalone client called LogScrobbler. I’m hoping that I can later tweak the query and find a way to inject the proper headers into the .scrobbler.log file, so that the log-file is more compatible with other scrobbling clients. My end-goal is to create either a batch process that does all that, and uses a command-line scrobbling client, OR some sort of php script that handles querying the database and posting to last.fm…
…needless to say, I also want a better way to handle the date option. And, finding a way to scrobble in “real-time” would be preferable, rather than this “bulk” scrobbling option.
Inspiration for this little project:
http://www.rockbox.org/wiki/LastFMLog
http://www.audioscrobbler.net/wiki/Portable_Player_Logging