我想删除将音频文件保存到本地,然后在保存后读取音频文件的步骤。
这是我目前正在完美运行的操作
fs.writeFileSync("audio/audioFile.webm", audioBuffer);
var audioStream = fs.createReadStream("audio/audioFile.webm");
// then posting the audio stream in the Whisper Api at https://api.openai.com/v1/audio/transcriptions which is working perfectly
我不禁想到,我肯定可以省略保存文件的步骤,并将缓冲区作为可读音频流发送到Whisper Api。
这真的可能吗?
我尝试过了,但它不起作用,该流是“可读取”的而不是“ReadStream”,这似乎是Whisper Api所需的。
const { Readable } = require('stream');
var audioStream = Readable.from(audioBuffer);