TheoKanning / openai-java

OpenAI Api Client in Java
MIT License
4.72k stars 1.18k forks source link

createTranscription needs a stream api #450

Open xmkevin opened 7 months ago

xmkevin commented 7 months ago

Now, createTranscription has filePath and Audio parameter to upload audio file. but if I am the server, I just want to forward the client audio stream to chatgpt, I need to save the Multipart input stream to a disk file and then pass it to the sdk, then the sdk read it from the disk, which needs more IO operations. In order to avoid the IO operations, I need another api for createTranscription, thanks.

namankhurpia commented 7 months ago

before I can suggest a solution to this - you are getting the stream in which format? like how are you getting the audio in a stream? @xmkevin

Ideally how you can do it, do the entire process in batches, since there's no stream API by OpenAI, i m sure you can divide your stream into 30 second clip - save it (in memory not disk) - transcribe it (then save to db)- and destroy the file, Yes, it is tacky but certainly doable.