TTS file generation

742 views
Skip to first unread message

Moute moute

unread,
Jul 7, 2014, 12:12:17 PM7/7/14
to ope...@googlegroups.com
Hi,

I'm currently using openhab to control an experimental platform (an appartment) in my research lab, and it works really fine.

Among the other equipments, I use 3 Sonos controllers and I want to be able to send TTS messages on the different sonos.
One way to do it, will be to use the input line of the sonos, but I don't like this solution.

I've been able to do it by using the mary tts service to generate a mp3 file, instead of just playing it, with a little dirty trick that checks the third parameter of the the tts say fonction (output device) to choose between playing or generating the sound in a shared folder.
It was really simple to do (a few lines), but it's not a clean way to do it.

Then with a simple rule, I generate the file and send the playuri command to the sonos with the generated file path, and it works really well.

But I think the best way to do it, would be to modify the TTSService Interface to add a function like

generateFile(text, voice, audioFileFormat, filePath). 

It's not a really big deal to implement it in the TTS services, and I think it would be usefull.

Do you think it's something acceptable and doable in the project?

Thank you,

Nicolas

Christoph Wempe

unread,
Jul 7, 2014, 12:52:26 PM7/7/14
to ope...@googlegroups.com
Despite your solution, I would suggest something that's more compatible with existing audio streaming solutions.

How about streaming a TTS message via UPnP AV (DLNA) to any upnp-player.
I don't know if this is even possible.

Just my 2 cents.

Kai Kreuzer

unread,
Jul 7, 2014, 2:01:28 PM7/7/14
to ope...@googlegroups.com
Hi Nicolas,

Using Sonos for TTS definitely makes sense.
But instead of generating an mp3 file, storing it locally and serving it again through HTTP or similar, I would like to think this idea a bit further:

What you describe is actually a preprocessing step for playing a sound. For Sonos (or DLNA or Squeezebox or any other audio streaming device), it does not matter whether this is the sound of a doorbell or a generated voice. It is just an audio stream.

So the current „playSound“ could actually be enhanced to allow source and target parameters. TTS services that support audio stream generation could register themselves as a sound source. Note that e.g. the Mac OS TTS service can not easily provide an audio stream, that’s why I wouldn’t want to add a method generateFile to the TTSService interface. Furthermore, writing a file is not as nice as directly directing an audio stream.

We would have to think about the exact interfaces and services, but I think this could be a valuable new feature - and as such, I would want to integrate it in Eclipse SmartHome and thus openHAB 2.0 rather than changing openHAB 1.x.

Best regards,
Kai


--
You received this message because you are subscribed to the Google Groups "openhab" group.
To unsubscribe from this group and stop receiving emails from it, send an email to openhab+u...@googlegroups.com.
To post to this group, send email to ope...@googlegroups.com.
Visit this group at http://groups.google.com/group/openhab.
For more options, visit https://groups.google.com/d/optout.

Karel Goderis

unread,
Jul 8, 2014, 4:53:41 AM7/8/14
to ope...@googlegroups.com
Nicolas

Can you share the scripts you are talking about? 

I do currently use the line-in method, with a line-in of the one of the rooms connected to the host running OH. It does work without a problem however, but one need to manage as well the output volume on the host, switch over the source to line-in (somehwat slower then another URI),...

Tx
KArel

Karel Goderis

unread,
Jul 8, 2014, 5:06:33 AM7/8/14
to ope...@googlegroups.com
Interesting idea, but difficult to realise as the UPNP standard is quite open, and HW manufacturers can extend the standard profiles to include other functionalities. For example, Sonos does a lot of it's magic through its own set of UPNP "commands" that are not compatible with other players. Furthermore, HW manufacturers are not obliged to fully implement the standard "templates" of the UPNP standard, so very often devices will respond with "NOT IMPLEMENTED" kind of messages when you try to trigger something supposedly quite standard....

Moute moute

unread,
Jul 8, 2014, 7:21:28 AM7/8/14
to ope...@googlegroups.com
Hi,
and thanks for the answers.

@Kai, I don't really understand the way you want to use playSound with a Sonos. I used simple files in the first place, because it's very simple, and I know I can play it without problem.

For the streaming part, in the previous version of the middleware controlling the platform (osgi based middleware too), I coded a simple streaming servlet, using the built-in webServer, to stream TTS and audioFiles to the sonos.
It solves a lot of sharing problem, because you juste have to send to your UPNP player an uri like "http://serverIP:port/audio/streaming/river.mp3" and the servlet was able to retrieve the good file and to stream it.
You can imagine having a servlet like this, able to use the TTS services for exemple.

@Karel, I'll share the scripts (the code too if you want) when I'll  go back to the platform (in 2 days I think).

Nicolas

Karel Goderis

unread,
Jul 8, 2014, 1:27:29 PM7/8/14
to ope...@googlegroups.com
You could equally, but this is subjective cfr voices used, use Google's TTS service  (translate.google.com/translate_tts?tl=en&q=welcome+to+openHAB)

It is in essence an mp3 stream

K

Kai Kreuzer

unread,
Jul 9, 2014, 4:42:42 PM7/9/14
to ope...@googlegroups.com

> @Kai, I don't really understand the way you want to use playSound with a Sonos. I used simple files in the first place, because it's very simple, and I know I can play it without problem.

My idea was just what you describe below: Provide a servlet that Sonos can call through a URL. Afaik, „playSound“ is currently not supported by the Sonos binding - so my point was that having such a servlet for TTS is not enough, it should be used for playing all kinds of audio (streams) in general.

Regards,
Kai

Karel Goderis

unread,
Jul 9, 2014, 6:02:12 PM7/9/14
to ope...@googlegroups.com
Then we shall put this on my to-do list guess? ;-)

K

Sent from my iPhone

Moute moute

unread,
Jul 11, 2014, 8:09:29 AM7/11/14
to ope...@googlegroups.com
Hi Karel,

here are the tricks I use (I know it's dirty, I'm usually the only one using it so...)

Objects:

String Bureau_PlayUri(Sonos , Bureau) {sonos="[bureau:playuri]"}
String Bureau_TTS (Sonos , Bureau)

Rule:

rule Bureau_tts
when
Item Bureau_TTS received command
then
say(Bureau_TTS.state.toString , "enst-dennys-hsmm" , "generate")
sendCommand(Bureau_PlayUri , "x-file-cifs://myserver/Music/phrase.wav")
end

For the TTS modification part, here is how I changed the say fonction in marryTTS:

                               AudioInputStream audio = marytts.generateAudio(text);
if (outputDevice.equals("generate")){
AudioSystem.write(audio, AudioFileFormat.Type.WAVE, new File("My\\Shared\\Folder\\Music\\phrase.wav"));
}else {
AudioPlayer player = new AudioPlayer(audio);
player.start();
player.join();


I also tried to use the google TTS, mainly because marrytts is not able to handle numbers (big problem to say what time it is...) and it kind of works with :

sendCommand("Bureau_PlayUri" , "x-rincon-mp3radio://translate.google.com/translate_tts?tl=fr&q=1+2+3+4+5+6+7+8+9+10")


But it's really slower than marrytts and there is a small glitch. It says almost all the phrase, then nothing for like 5 seconds, then the last caracter of the phrase. Really weird...

I hope that helps. 


Nicolas
Reply all
Reply to author
Forward
0 new messages