-
Notifications
You must be signed in to change notification settings - Fork 77
Add Android views to guides #754
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
mattieruth
wants to merge
2
commits into
main
Choose a base branch
from
client-guides-android
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -3,34 +3,95 @@ title: "Small WebRTC Transport" | |
| description: "WebRTC implementation for Android" | ||
| --- | ||
|
|
||
| The Small WebRTC transport implementation enables real-time audio communication with the Small WebRTC Pipecat transport, using a direct WebRTC connection. | ||
| The Small WebRTC transport enables real-time audio communication with a Pipecat bot over a direct WebRTC connection, with no third-party account required. | ||
|
|
||
| ## Installation | ||
|
|
||
| Add the transport dependency to your `build.gradle`: | ||
| Add the transport dependency to your `app/build.gradle.kts`: | ||
|
|
||
| ```gradle | ||
| implementation "ai.pipecat:small-webrtc-transport:0.3.7" | ||
| ```kotlin | ||
| dependencies { | ||
| implementation("ai.pipecat:small-webrtc-transport:1.2.0") | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This version has also never existed
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Current latest is 1.1.0: https://central.sonatype.com/search?q=pipecat |
||
| } | ||
| ``` | ||
|
|
||
| ## Usage | ||
| Add the microphone permission to `AndroidManifest.xml`: | ||
|
|
||
| Create a client: | ||
| ```xml | ||
| <uses-permission android:name="android.permission.RECORD_AUDIO" /> | ||
| ``` | ||
|
|
||
| ## Usage | ||
|
|
||
| ```kotlin | ||
| val transport = SmallWebRTCTransport.Factory(context, baseUrl) | ||
| import ai.pipecat.client.PipecatClientOptions | ||
| import ai.pipecat.client.PipecatEventCallbacks | ||
| import ai.pipecat.client.small_webrtc_transport.PipecatClientSmallWebRTC | ||
| import ai.pipecat.client.small_webrtc_transport.SmallWebRTCTransport | ||
| import ai.pipecat.client.types.APIRequest | ||
| import ai.pipecat.client.types.BotReadyData | ||
| import ai.pipecat.client.types.Value | ||
|
|
||
| val options = RTVIClientOptions( | ||
| params = RTVIClientParams(baseUrl = null), | ||
| enableMic = true, | ||
| enableCam = true | ||
| ) | ||
| val callbacks = object : PipecatEventCallbacks() { | ||
| override fun onBackendError(message: String) { | ||
| Log.e(TAG, "Backend error: $message") | ||
| } | ||
|
|
||
| val client = RTVIClient(transport, callbacks, options) | ||
| override fun onBotReady(data: BotReadyData) { | ||
| Log.d(TAG, "Bot is ready") | ||
| } | ||
| } | ||
|
|
||
| val options = PipecatClientOptions(callbacks = callbacks, enableMic = true) | ||
| val client = PipecatClientSmallWebRTC(SmallWebRTCTransport(context), options) | ||
|
|
||
| client.start().withCallback { | ||
| // ... | ||
| // Connect via your server endpoint (recommended) | ||
| client.startBotAndConnect( | ||
| APIRequest(endpoint = "https://your-server.com/api/offer", requestData = Value.Object()) | ||
| ).withCallback { result -> | ||
| result.errorOrNull?.let { Log.e(TAG, "Connection failed: $it") } | ||
| } | ||
|
|
||
| // Or connect with coroutines | ||
| // client.startBotAndConnect(...).await() | ||
| ``` | ||
|
|
||
| ## Configuration | ||
|
|
||
| ### IceConfig | ||
|
|
||
| Pass custom ICE servers for TURN/STUN support: | ||
|
|
||
| ```kotlin | ||
| val iceConfig = IceConfig( | ||
| iceServers = listOf( | ||
| IceServer( | ||
| urls = listOf("turn:your-turn-server.com:3478"), | ||
| username = "user", | ||
| credential = "pass" | ||
| ) | ||
| ) | ||
| ) | ||
|
|
||
| val transport = SmallWebRTCTransport(context, iceConfig = iceConfig) | ||
| ``` | ||
|
|
||
| ### Audio devices | ||
|
|
||
| The transport exposes static constants for audio routing: | ||
|
|
||
| ```kotlin | ||
| // Route audio to speakerphone (default) or earpiece | ||
| client.updateMic(SmallWebRTCTransport.AudioDevices.Speakerphone.id) | ||
| client.updateMic(SmallWebRTCTransport.AudioDevices.Earpiece.id) | ||
| ``` | ||
|
|
||
| ### Camera selection | ||
|
|
||
| ```kotlin | ||
| // Switch between front and rear cameras | ||
| client.updateCam(SmallWebRTCTransport.Cameras.Front.id) | ||
| client.updateCam(SmallWebRTCTransport.Cameras.Rear.id) | ||
| ``` | ||
|
|
||
| ## Resources | ||
|
|
||
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This version doesn't exist, the OpenAI realtime transport is still on 0.3.7.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Or more specifically, it hasn't been published -- I think it was a work in progress when I was pulled onto other tasks.