AudioKey audioKey = new AudioKey("Hello fellow monkeys. This text is automatically converted to a mono audiostream.tts");
AudioData audioData = assetManager.loadAudio(audioKey);
new AudioNode(audioData, audioKey).play();
[/java]
One known bug to solve. (At the end of the audiostream it jumps back a little bit and replays a short chunk)
Some missing features to implement. (Probably trough a custom AudioKey)
Good news is, i fixed the error, now sound plays completely.
Going to refactor everything and upload the code today evening on github.
@ndebruyn: i dont think that this lib is suitable for android however, the generation takes already a few sec on my pc. Also the whole lib is too big to fit an apk. But i am going to add some lines to allow pregenration of .wav files.
@Fissll: beside the jars the above code is nearly everything you need to use it.
I would not use AssetKey here, and instead call a generator class directly. Use loader to load caches audio where available (you could do an md5 hash of the entire string as the file name).
@zzuegg said:
Indeed, i use the generator class directly in my project, but i tought this is more the jme way of dooing things ;)
Hmm, well the assetloader is really that - an asset loader.
By the way, how does MARY work without the server? I had a look before but it seemed a bit… meh when it comes to portable design.
@zzuegg said:
Indeed, i use the generator class directly in my project, but i tought this is more the jme way of dooing things ;)
I think its the proper way. Its an asset file you edit while you create the game and which you want to load as audio data into your game later. You wouldn’t unpack an .ogg file with some “generator” either, you simply load the .ogg and get audio data inside the game.
@normen said:
I think its the proper way. Its an asset file you edit while you create the game and which you want to load as audio data into your game later. You wouldn't unpack an .ogg file with some "generator" either, you simply load the .ogg and get audio data inside the game.
But it’s not unpacking it, it’s generating it… This point would be valid if the files were stored somewhere. In this, the asset key is being used as the single parameter to the generator.
By the way, if you’re going to take the path of using an asset loader, I would advise making your own AssetKey as with ModelKey: https://code.google.com/p/jmonkeyengine/source/browse/branches/jme3/src/core/com/jme3/asset/ModelKey.java?r=6060
This way, you could set the path as the path to the voice file (or something along those lines), and have the text, speed, volume or any other variables separately. Just an idea
Hm it is not assetloading, but behaves similar, eg you call it and it needs some time and returns you usable data.
Having a custom key where all the datas could be added makes sense.
In fact it might make sense to even allow the configuration of a cache directory, and add a boolean if a string should be cached.