fuwei007 / OpenAIIOSRealtimeAPIDemo

12 stars 2 forks source link

Resume session when go to the other app and come back to the app again #4

Closed MayurShiroya103 closed 6 days ago

MayurShiroya103 commented 1 week ago

@fuwei007 How to resume current session when user come back to the app and it's within 30 minutes otherwise session closed.

the problem is, when going to the background and come back to the foreground, it automatically disconnected and not working

Sometimes, when stop recording and start again then audio resume successfully using AudioOutputUnitStart(audioUnit!) this but audio recording is not working and audio is also not playing.

Thanks in advance!

MayurShiroya103 commented 1 week ago

error: ["error": { code = "session_expired"; "event_id" = ""; message = "Your session hit the maximum duration of 15 minutes."; param = ""; type = "invalid_request_error"; }, "type": error, "event_id": event_AQwE26ajpcfiSOc5aq3a4] WebSocket disconnected: Your session hit the maximum duration of 15 minutes. with code: 1001

When this error comes and again connect to the socket then audio not recording

MayurShiroya103 commented 1 week ago

@fuwei007 is there anything wrong in the code? if i have started session and in between any call comes then after we start session again audio is not playing

fuwei007 commented 1 week ago

That is something from Open AI https://community.openai.com/t/realtime-api-session-expired/975036

By way the realtime API will cost a lot. around 8$ per 10 minutes. You may need disconnect if you don't need it. once you re-connect it you could pass the prompt of the previous session.

You could check this video to see how much it will cost you if you keep the connect more than 10 minutes.

https://www.youtube.com/watch?v=w2aFlWKIi9w

Thanks

Frank