Google Text-to-speech
in
Core Library Questions
•
1 years ago
Hi f
olks,
I'm trying to use the unofficial google-tts-function to give my sketch a voice. I would prefer it, because it also supports German, but I got some problems. The tts could be easily accessed by the following link:
translate.google.com/translate_tts?q=Hallo+zusammen (This will give the output "hallo zusammen")
Now I want the mp3 to get dynamically generated and beeing played if sth is happening (like a mouseClick), but I always get a NullPointerException like if there were no file, but in browser it works fine.
This is my code:
So do you have any ideas what causes the problem?
Thanks in advance!
I'm trying to use the unofficial google-tts-function to give my sketch a voice. I would prefer it, because it also supports German, but I got some problems. The tts could be easily accessed by the following link:
translate.google.com/translate_tts?q=Hallo+zusammen (This will give the output "hallo zusammen")
Now I want the mp3 to get dynamically generated and beeing played if sth is happening (like a mouseClick), but I always get a NullPointerException like if there were no file, but in browser it works fine.
This is my code:
- import ddf.minim.*;
- AudioPlayer player;
- Minim minim;
- void setup()
- {
- size(512, 200, P2D);
- minim = new Minim(this);
- }
- void draw()
- {
- if(mousePressed) {
- playing("Dies ist ein Test");
- }
- }
- void playing(String txt) {
- player = minim.loadFile("http://translate.google.com/translate_tts?q="+txt+".mp3", 2048);
- player.play();
- }
- void stop()
- {
- // always close Minim audio classes when you are done with them
- player.close();
- minim.stop();
- super.stop();
- }
So do you have any ideas what causes the problem?
Thanks in advance!
1