audiojs / audio-play

Play audio buffer in browser/node
MIT License
60 stars 14 forks source link

Can't play audio buffer returned from @google-cloud/text-to-speech #28

Open thegoatherder opened 3 years ago

thegoatherder commented 3 years ago

Google Cloud Text to Speech returns a response.audioContent which logs to console as:

<Buffer ff f3 44 c4 00 12 6a d5 44 01 41 10 01 c6 37 00 20 8c 6c 80 04 05 fe 84 6a 9c ef f3 9f 39 f2 10 9f e4 24 8d bf fc e7 79 cf 21 09 c9 53 9e 42 49 53 ba ... 4846 more bytes>

Running this:

let playback = play(response.audioContent);
playback.play();

Errors out with:

Error: Argument should be an audio buffer

Am I doing something wrong?

dy commented 3 years ago

Try converting Buffer to AudioBuffer via https://github.com/audiojs/audio-buffer-from