Skip to content

Add WebRTC option #12

@paulpv

Description

@paulpv

I just stumbled across your excellent refactor of https://github.com/openai/openai-realtime-api-beta .

Before finding you...

While writing my https://github.com/swooby/AlfredAI native Android Phone/Wear app that uses my own https://github.com/swooby/openai-openapi-kotlin Kotlin OpenAI Realtime API lib, I think I started to run into some inconsistencies with how my WebRTC implementation behaves versus how I see the plethora of JavaScript WebSocket implementations behave.

I decided I "needed" a good stable JavaScript test app that I could easily A/B toggle between WebRTC and WebSocket to compare/contrast behavior with.

I came up with this:
https://github.com/swooby/AlfredAI/blob/main/openai-realtime-js/index.html

Image Image

It is fugly, but it [mostly] works for my A/B testing purposes.

But, while writing that I also wanted to implement a WebRTC version of:
https://github.com/openai/openai-realtime-api-beta/blob/main/lib/api.js

I came up with this:
https://github.com/swooby/AlfredAI/blob/main/openai-realtime-js/api_webrtc.js

It implements RealtimeApiWebRTC, which is a near drop in replacement for OpenAI's original RealtimeAPI.

I show how to flip between the two in:
https://github.com/swooby/AlfredAI/blob/3a3ffb31c44a8462313dacfa5111d789f0a887ae/openai-realtime-js/index.js#L196-L259

THEN I FOUND THIS/YOUR EXCELLENT REPO!

You are more than welcome to TypeScript and clean up my https://github.com/swooby/AlfredAI/blob/main/openai-realtime-js/api_webrtc.js and do the needful to implement a WebRTC version of your excellent looking lib!

I did not go the extra distance and make sure that it fully works with RealtimeClient, but that would need to be tweaked a little to be passed a parameter of what connection type to use.

Basing the logic off of whether the given url started with wss:// seemed like a reasonable way to attempt to auto-detect what connection type to use.

Let me know how/if I can help.

🍻

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions