Local MaryTTS Server - no sound from OpenHAB

I have both openHAB and MaryTTS running on my Windows Server box. I want openHab to use my local instance of MaryTTS for text-to-speech functions (I know about the built in MaryTTS but it’s way to choppy and I want to use different voices), but no matter what I do I can’t seem to get it to work. I can enter the following url into my browser and get a response just fine: http://localhost:59125/process?INPUT_TYPE=TEXT&AUDIO=WAVE_FILE&OUTPUT_TYPE=AUDIO&LOCALE=en_us&INPUT_TEXT=“Hello%20World” so I know that my MaryTTS is working.

I use the GoogleTTS binding and my configuration looks like this

###################### GoogleTTS configuration ############################
#
# The language to be used by the GoogleTTS engine (optional, default: 'en').
# Language must be supported for audio output by https://translate.google.com.
googletts:language=en_us
# Sentence delimiters used to split text into sentences (optional, default: !.?:;)
# googletts:sentenceDelimiters=
# Google Translate URL to be used for converting text to speech (optional, 
# defaults to http://translate.google.com/translate_tts?tl=%s&q=%s).
googletts:translateUrl=http://localhost:59125/process?INPUT_TYPE=TEXT&AUDIO=WAVE_FILE&OUTPUT_TYPE=AUDIO&LOCALE=%s&INPUT_TEXT=%s

I use the following in my rules

rule "Smoke Detector"
when
	Item HW_Smoke received command
then
	logInfo("report", "Fire detected")
	say("Alert Fire detected on second floor")
end

I see the following in my openHAB eventbus

2015-11-01 01:35:00.631 [INFO ] [.i.m.i.tts.TTSServiceGoogleTTS] - Executing GoogleTTS for text 'Alert Fire detected on second floor' in language en_us

The OpenHAB log files show no errors with the TTS and my MaryTTS Server logs show a successful response as shown below:

2015-11-01 01:35:00,639 [I/O dispatcher 1] INFO  marytts.R 99 New request (input type "TEXT", output type "AUDIO", voice "cmu-slt-hsmm", effect "", audio "WAVE")
2015-11-01 01:35:00,639 [I/O dispatcher 1] INFO  marytts.server Read: Alert Fire detected on second floor
2015-11-01 01:35:00,639 [I/O dispatcher 1] INFO  marytts.R 99 Handling request using the following modules:
2015-11-01 01:35:00,639 [I/O dispatcher 1] INFO  marytts.R 99 - TextToMaryXML (marytts.modules.TextToMaryXML)
2015-11-01 01:35:00,640 [I/O dispatcher 1] INFO  marytts.R 99 Next module: TextToMaryXML
2015-11-01 01:35:00,640 [I/O dispatcher 1] INFO  marytts.R 99 Handling request using the following modules:
2015-11-01 01:35:00,640 [I/O dispatcher 1] INFO  marytts.R 99 - JTokeniser (marytts.language.en.JTokeniser)
2015-11-01 01:35:00,640 [I/O dispatcher 1] INFO  marytts.R 99 - XML2Utt TokensEn (marytts.language.en.XML2UttTokensEn)
2015-11-01 01:35:00,640 [I/O dispatcher 1] INFO  marytts.R 99 - TokenToWords (marytts.language.en.FreeTTSTokenToWords)
2015-11-01 01:35:00,640 [I/O dispatcher 1] INFO  marytts.R 99 - Utt2XML WordsEn (marytts.language.en.Utt2XMLWordsEn)
2015-11-01 01:35:00,640 [I/O dispatcher 1] INFO  marytts.R 99 - OpenNLPPosTagger (marytts.modules.OpenNLPPosTagger)
2015-11-01 01:35:00,640 [I/O dispatcher 1] INFO  marytts.R 99 - JPhonemiser (marytts.modules.JPhonemiser)
2015-11-01 01:35:00,640 [I/O dispatcher 1] INFO  marytts.R 99 - Prosody (marytts.language.en.Prosody)
2015-11-01 01:35:00,640 [I/O dispatcher 1] INFO  marytts.R 99 - PronunciationModel (marytts.language.en.PronunciationModel)
2015-11-01 01:35:00,640 [I/O dispatcher 1] INFO  marytts.R 99 - AcousticModeller (marytts.modules.AcousticModeller)
2015-11-01 01:35:00,640 [I/O dispatcher 1] INFO  marytts.R 99 - Synthesis (marytts.modules.Synthesis)
2015-11-01 01:35:00,640 [I/O dispatcher 1] INFO  marytts.R 99 Next module: JTokeniser
2015-11-01 01:35:00,641 [I/O dispatcher 1] INFO  marytts.R 99 Next module: XML2Utt TokensEn
2015-11-01 01:35:00,641 [I/O dispatcher 1] INFO  marytts.R 99 Next module: TokenToWords
2015-11-01 01:35:00,641 [I/O dispatcher 1] INFO  marytts.R 99 Next module: Utt2XML WordsEn
2015-11-01 01:35:00,641 [I/O dispatcher 1] INFO  marytts.R 99 Next module: OpenNLPPosTagger
2015-11-01 01:35:00,643 [I/O dispatcher 1] INFO  marytts.R 99 Next module: JPhonemiser
2015-11-01 01:35:00,645 [I/O dispatcher 1] INFO  marytts.R 99 Next module: Prosody
2015-11-01 01:35:00,646 [I/O dispatcher 1] INFO  marytts.R 99 Next module: PronunciationModel
2015-11-01 01:35:00,647 [I/O dispatcher 1] INFO  marytts.R 99 Next module: AcousticModeller
2015-11-01 01:35:00,663 [I/O dispatcher 1] INFO  marytts.ParameterGeneration Parameter generation for LF0: 
2015-11-01 01:35:00,663 [I/O dispatcher 1] INFO  marytts.PStream Context-dependent global variance optimization: gvLength = 475
2015-11-01 01:35:00,664 [I/O dispatcher 1] INFO  marytts.PStream Gradient GV optimization for feature: (0)  number of iterations=2
2015-11-01 01:35:00,666 [I/O dispatcher 1] INFO  marytts.R 99 Next module: Synthesis
2015-11-01 01:35:00,666 [I/O dispatcher 1] INFO  marytts.HMMSynthesizer Synthesizing one sentence.
2015-11-01 01:35:00,667 [I/O dispatcher 1] INFO  marytts.HTSEngine Using prosody from acoustparams.
2015-11-01 01:35:00,668 [I/O dispatcher 1] INFO  marytts.HTSEngine Number of models in sentence numModel=28  Total number of states numState=140
2015-11-01 01:35:00,668 [I/O dispatcher 1] INFO  marytts.HTSEngine Total number of frames=741  Number of voiced frames=475
2015-11-01 01:35:00,675 [I/O dispatcher 1] INFO  marytts.ParameterGeneration Parameter generation for MGC: 
2015-11-01 01:35:00,675 [I/O dispatcher 1] INFO  marytts.PStream Context-dependent global variance optimization: gvLength = 706
2015-11-01 01:35:00,684 [I/O dispatcher 1] INFO  marytts.PStream Gradient GV optimization for feature: (0)  number of iterations=43
2015-11-01 01:35:00,690 [I/O dispatcher 1] INFO  marytts.PStream Gradient GV optimization for feature: (1)  number of iterations=31
2015-11-01 01:35:00,695 [I/O dispatcher 1] INFO  marytts.PStream Gradient GV optimization for feature: (2)  number of iterations=24
2015-11-01 01:35:00,696 [I/O dispatcher 1] INFO  marytts.PStream Gradient GV optimization for feature: (3)  number of iterations=2
2015-11-01 01:35:00,698 [I/O dispatcher 1] INFO  marytts.PStream Gradient GV optimization for feature: (4)  number of iterations=4
2015-11-01 01:35:00,703 [I/O dispatcher 1] INFO  marytts.PStream Gradient GV optimization for feature: (5)  number of iterations=27
2015-11-01 01:35:00,703 [I/O dispatcher 1] INFO  marytts.PStream Gradient GV optimization for feature: (6)  number of iterations=2
2015-11-01 01:35:00,705 [I/O dispatcher 1] INFO  marytts.PStream Gradient GV optimization for feature: (7)  number of iterations=2
2015-11-01 01:35:00,708 [I/O dispatcher 1] INFO  marytts.PStream Gradient GV optimization for feature: (8)  number of iterations=17
2015-11-01 01:35:00,713 [I/O dispatcher 1] INFO  marytts.PStream Gradient GV optimization for feature: (9)  number of iterations=20
2015-11-01 01:35:00,716 [I/O dispatcher 1] INFO  marytts.PStream Gradient GV optimization for feature: (10)  number of iterations=16
2015-11-01 01:35:00,718 [I/O dispatcher 1] INFO  marytts.PStream Gradient GV optimization for feature: (11)  number of iterations=3
2015-11-01 01:35:00,721 [I/O dispatcher 1] INFO  marytts.PStream Gradient GV optimization for feature: (12)  number of iterations=16
2015-11-01 01:35:00,725 [I/O dispatcher 1] INFO  marytts.PStream Gradient GV optimization for feature: (13)  number of iterations=16
2015-11-01 01:35:00,728 [I/O dispatcher 1] INFO  marytts.PStream Gradient GV optimization for feature: (14)  number of iterations=17
2015-11-01 01:35:00,732 [I/O dispatcher 1] INFO  marytts.PStream Gradient GV optimization for feature: (15)  number of iterations=15
2015-11-01 01:35:00,736 [I/O dispatcher 1] INFO  marytts.PStream Gradient GV optimization for feature: (16)  number of iterations=17
2015-11-01 01:35:00,739 [I/O dispatcher 1] INFO  marytts.PStream Gradient GV optimization for feature: (17)  number of iterations=17
2015-11-01 01:35:00,745 [I/O dispatcher 1] INFO  marytts.PStream Gradient GV optimization for feature: (18)  number of iterations=29
2015-11-01 01:35:00,747 [I/O dispatcher 1] INFO  marytts.PStream Gradient GV optimization for feature: (19)  number of iterations=10
2015-11-01 01:35:00,750 [I/O dispatcher 1] INFO  marytts.PStream Gradient GV optimization for feature: (20)  number of iterations=14
2015-11-01 01:35:00,754 [I/O dispatcher 1] INFO  marytts.PStream Gradient GV optimization for feature: (21)  number of iterations=18
2015-11-01 01:35:00,759 [I/O dispatcher 1] INFO  marytts.PStream Gradient GV optimization for feature: (22)  number of iterations=23
2015-11-01 01:35:00,764 [I/O dispatcher 1] INFO  marytts.PStream Gradient GV optimization for feature: (23)  number of iterations=22
2015-11-01 01:35:00,767 [I/O dispatcher 1] INFO  marytts.PStream Gradient GV optimization for feature: (24)  number of iterations=12
2015-11-01 01:35:00,770 [I/O dispatcher 1] INFO  marytts.PStream Gradient GV optimization for feature: (25)  number of iterations=11
2015-11-01 01:35:00,772 [I/O dispatcher 1] INFO  marytts.PStream Gradient GV optimization for feature: (26)  number of iterations=12
2015-11-01 01:35:00,775 [I/O dispatcher 1] INFO  marytts.PStream Gradient GV optimization for feature: (27)  number of iterations=12
2015-11-01 01:35:00,778 [I/O dispatcher 1] INFO  marytts.PStream Gradient GV optimization for feature: (28)  number of iterations=29
2015-11-01 01:35:00,781 [I/O dispatcher 1] INFO  marytts.PStream Gradient GV optimization for feature: (29)  number of iterations=14
2015-11-01 01:35:00,785 [I/O dispatcher 1] INFO  marytts.PStream Gradient GV optimization for feature: (30)  number of iterations=20
2015-11-01 01:35:00,788 [I/O dispatcher 1] INFO  marytts.PStream Gradient GV optimization for feature: (31)  number of iterations=16
2015-11-01 01:35:00,790 [I/O dispatcher 1] INFO  marytts.PStream Gradient GV optimization for feature: (32)  number of iterations=9
2015-11-01 01:35:00,791 [I/O dispatcher 1] INFO  marytts.PStream Gradient GV optimization for feature: (33)  number of iterations=8
2015-11-01 01:35:00,795 [I/O dispatcher 1] INFO  marytts.PStream Gradient GV optimization for feature: (34)  number of iterations=26
2015-11-01 01:35:00,795 [I/O dispatcher 1] INFO  marytts.ParameterGeneration Using f0 from maryXML acoustparams
2015-11-01 01:35:00,796 [I/O dispatcher 1] INFO  marytts.PStream Context-dependent global variance optimization: gvLength = 706
2015-11-01 01:35:00,798 [I/O dispatcher 1] INFO  marytts.PStream Gradient GV optimization for feature: (0)  number of iterations=15
2015-11-01 01:35:00,802 [I/O dispatcher 1] INFO  marytts.PStream Gradient GV optimization for feature: (1)  number of iterations=17
2015-11-01 01:35:00,803 [I/O dispatcher 1] INFO  marytts.PStream Gradient GV optimization for feature: (2)  number of iterations=4
2015-11-01 01:35:00,808 [I/O dispatcher 1] INFO  marytts.PStream Gradient GV optimization for feature: (3)  number of iterations=27
2015-11-01 01:35:00,810 [I/O dispatcher 1] INFO  marytts.PStream Gradient GV optimization for feature: (4)  number of iterations=5
2015-11-01 01:35:00,817 [I/O dispatcher 1] INFO  marytts.R 99 Request processed in 171 ms.
2015-11-01 01:35:00,817 [I/O dispatcher 1] INFO  marytts.R 99    TextToMaryXML took 1 ms
2015-11-01 01:35:00,817 [I/O dispatcher 1] INFO  marytts.R 99    JTokeniser took 1 ms
2015-11-01 01:35:00,817 [I/O dispatcher 1] INFO  marytts.R 99    XML2Utt TokensEn took 0 ms
2015-11-01 01:35:00,817 [I/O dispatcher 1] INFO  marytts.R 99    TokenToWords took 0 ms
2015-11-01 01:35:00,817 [I/O dispatcher 1] INFO  marytts.R 99    Utt2XML WordsEn took 0 ms
2015-11-01 01:35:00,817 [I/O dispatcher 1] INFO  marytts.R 99    OpenNLPPosTagger took 2 ms
2015-11-01 01:35:00,817 [I/O dispatcher 1] INFO  marytts.R 99    JPhonemiser took 2 ms
2015-11-01 01:35:00,817 [I/O dispatcher 1] INFO  marytts.R 99    Prosody took 1 ms
2015-11-01 01:35:00,817 [I/O dispatcher 1] INFO  marytts.R 99    PronunciationModel took 1 ms
2015-11-01 01:35:00,817 [I/O dispatcher 1] INFO  marytts.R 99    AcousticModeller took 19 ms
2015-11-01 01:35:00,817 [I/O dispatcher 1] INFO  marytts.R 99    Synthesis took 144 ms
2015-11-01 01:35:02,472 [I/O dispatcher 1] INFO  marytts.server Request handled successfully.
2015-11-01 01:35:08,127 [I/O dispatcher 1] INFO  marytts.server Connection closed: [closed]

The MaryTTS and the GoogleTTS are returning the same audio format?

Nope :frowning:
I attempted the same approach in using the the GoogleTTS binding to hit a local MaryTTS Web Service, and upon introspection it seems GoogleTTS returns ‘audio/mpeg’ format whereas MaryTTS returns ‘audio/wav’. The other options are au and aiff which doesn’t really help here…

What does work for me (Linux only, but same approach could be adapted) is to call Mary from a bash script and play with another CLI player. Results are very good here when compared to the addon MaryTTS binding.

#!/bin/bash
str=$@
TEXT=${str// /+}
#REMOTE PLAYBACK
#curl "http://127.0.0.1:59125/process?INPUT_TYPE=TEXT&OUTPUT_TYPE=AUDIO&LOCALE=en_GB&AUDIO=WAVE_FILE&VOICE=dfki-spike-hsmm&INPUT_TEXT="$TEXT | PULSE_SERVER=192.168.1.100 aplay -q
#LOCAL PLAYBACK
curl "http://127.0.0.1:59125/process?INPUT_TYPE=TEXT&OUTPUT_TYPE=AUDIO&LOCALE=en_GB&AUDIO=WAVE_FILE&VOICE=dfki-spike-hsmm&INPUT_TEXT="$TEXT | aplay -q

This is then called in rules like so (instead of say()):

executeCommandLine(‘/home/openhab/scripts/marycli.sh Your air purifier is now on’)

Not clean nor ideal, but it works!