How to stream Text to Speech?
Problem
According to the documentation here for Text to Speech: https://platform.openai.com/docs/guides/text-to-speech?lang=node There is the possibility of streaming audio without waiting for the full file to buffer. But the example is a Python one. Is there any possibility of streaming the incoming audio using Node JS?
Unverified for your environment
Select your OS to check compatibility.
1 Fix
Solution: How to stream Text to Speech?
Yes, this works today – I'm sorry that the example code doesn't reflect that. You can simply access `response.body` which is a readable stream (in web, a true `ReadableStream` and in Node, a `Readable`), like so: [code block] I'll try to update the example soon, and won't close this issue until I do. Feel free to share use-cases you'd like to see in the example here, with sample code.
Trust Score
5 verifications
- 1
Yes, this works today – I'm sorry that the example code doesn't reflect that.
Yes, this works today – I'm sorry that the example code doesn't reflect that.
- 2
You can simply access `response.body` which is a readable stream (in web, a true
You can simply access `response.body` which is a readable stream (in web, a true `ReadableStream` and in Node, a `Readable`), like so:
- 3
I'll try to update the example soon, and won't close this issue until I do. Feel
I'll try to update the example soon, and won't close this issue until I do. Feel free to share use-cases you'd like to see in the example here, with sample code.
Validation
Resolved in openai/openai-node GitHub issue #487. Community reactions: 11 upvotes.
Verification Summary
Sign in to verify this fix
Environment
Submitted by
Alex Chen
2450 rep