What the...
I think you misunderstood what the OP is after
They'd like to to be able to access a sound sample of the text to speech block not just hear the sound
A reporter (round block) reports a value that another block can use as an input
Could you show me the code so I can test it?
I just use someone's contrib node in NodeRED
This is the node I use with the TTS Service using Google (without credentials) setting
I've no idea how it works but maybe if you explore the source code for it you could work it out
[edit] I've glanced thru its code and I "think" that its using a Google translation API to do the conversion - but I can't work out the details so far
There's a lot of noise when you try and search for free text to speech API
[edit2] Made some progress
provide a free service but it does require signing up and getting a key
Which is fine for personal projects but not good for public ones
I've got as far as this with it
I think I just need to work out how to make Snap! play the returned data as a sound
[edit3] 26Jan2022
Well, one issue is that the url block returns at UTF-16 (I think) encoded string and that is no good for binary data such as an audio wav file
So I came up with this (always remember I know very little about JavaScript) that seems to return the contents of the wav file as a list of binary values and AFAICT, the list is the same data that I get if I use the same URL in my browser and download the result
But I cannot get it to playback properly in Snap!
I'm obviously missing something somewhere
maybe code in something like SAM (software automatic mouth)
You may try "b64" options...
Ouptut seems to be a RIFF, but
probably require only the data (samples) part of the RIFF.
Victory is mine
So as before, this JavaScript will return the contents of the generated wav file
(Just need to add your Voice RSS key as mentioned in previous post)
Then it turns out the audio data is from item 47 to the end of the file (should work for any reasonable TTS request)
so
(I've got a more complicated version that will handle 16bits if needed)
or with custom reporters
And then we can convert the samples into a Snap! sound
This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.