Hey! I’m working on an text to speech plugin for TD. I’m using the python request library to download an audio file / stream. I’m wondering if there’s a way that I can immediately start streaming the audio into a CHOP in TouchDesigner, so the seconds there’s data it will start playing back audio?
Currently I’m writing the audio to a temporary file and then loading the audio through an AudioFileIn CHOP. The problem is that the audio can take a long time to generate and download which causes a significant delay. Any thoughts on passing along the audio data to a CHOP as it’s being downloaded?
Thanks!
T
I’d also like to know if there is decent solution for this problem. I saw some back and forth about this topic in the TD Discord - were you able to get something working?
Cheers.
C.
Hey I know we chatted on discord, but I’m leaving this on the forum for others. Yes, I was able to download audio in chunks and playback the audio as it was being streamed. I have a working component on my patreon that connects to the elevenlabs API, download the audio and plays it back as the audio is being streamed.
The trick was to lock a ScriptCHOP and as the audio chunks were being download I could programmatically write the audio into the ScriptCHOP as a buffer.
The other problem was how to play back the audio from the ScriptCHOP. If someone knows of an easier way I’d love to know. For now I noticed that if I directly connect an AudioDeviceOut to the ScriptCHOP when my timeline is at 1 it will start playing the audio. My solution was to place a local Time component with the AudioDeviceOut so that I could manually trigger the playback whenever, so if someone wanted to queue the audio.
Hope this helps!