Repository navigation
docs: add full-duplex voice AI assistant guide - #1344
maciejkucmierz-swm wants to merge 2 commits into
Conversation
WPT non-regression comparisonPASS — no regressions · 0 improved section(s) · overall 3427 → 3427 (0) Unchanged sections (28)
Baseline: Workflow run · this comment is updated on every push. |
mdydek
left a comment
There was a problem hiding this comment.
can it be written more begginer-friendly when it comes to using our library. I think we can assume the user's knowledge about tokens and other stuff, but focus more on the features used from our library
mdydek
left a comment
There was a problem hiding this comment.
I like the structure much better, but I feel like we could give some more code snippets rather than wall of text, prefer keeping it brief and giving some mini code snippets that can help the user to understand how to structure that
| `} | ||
| /> | ||
|
|
||
| The examples below illustrate these interfaces, rather than a complete application. The communication settings described here require Android 12 (API 31)+ or iOS 14+. |
There was a problem hiding this comment.
| The examples below illustrate these interfaces, rather than a complete application. The communication settings described here require Android 12 (API 31)+ or iOS 14+. | |
| The examples below illustrate these interfaces, but bear in mind that the communication settings described here require Android 12 (API 31)+ or iOS 14+. |
| `} | ||
| /> | ||
|
|
||
| The examples below illustrate these interfaces, rather than a complete application. The communication settings described here require Android 12 (API 31)+ or iOS 14+. |
There was a problem hiding this comment.
and also we can wrap this in an info block
| await AudioManager.setAudioSessionActivity(true); | ||
| ``` | ||
|
|
||
| The configuration must be in place before creating the audio context or starting capture. Microphone permission is still required; Android communication routing also needs `MODIFY_AUDIO_SETTINGS`. See [permissions](../other/non-expo-permissions.mdx) for the native declarations. |
There was a problem hiding this comment.
| The configuration must be in place before creating the audio context or starting capture. Microphone permission is still required; Android communication routing also needs `MODIFY_AUDIO_SETTINGS`. See [permissions](../other/non-expo-permissions.mdx) for the native declarations. | |
| The configuration must be in place before starting the playback or capture. Microphone permission is still required; Android communication routing also needs `MODIFY_AUDIO_SETTINGS`. See [permissions](../other/non-expo-permissions.mdx) for the native declarations. |
| }); | ||
| ``` | ||
|
|
||
| The output profile is fixed when the context is created and is ignored on iOS. It does **not** acquire audio focus, activate communication mode, or select a speaker by itself. Changing that one option is not a substitute for configuring the session and recorder. |
There was a problem hiding this comment.
| The output profile is fixed when the context is created and is ignored on iOS. It does **not** acquire audio focus, activate communication mode, or select a speaker by itself. Changing that one option is not a substitute for configuring the session and recorder. |
|
|
||
| The output profile is fixed when the context is created and is ignored on iOS. It does **not** acquire audio focus, activate communication mode, or select a speaker by itself. Changing that one option is not a substitute for configuring the session and recorder. | ||
|
|
||
| On **Android**, the settings can also be combined differently: keep the `inCommunication` session, speaker request, and `voiceCommunication` microphone preset, but create the context with `androidOutputProfile: 'media'` (the default). This keeps media-classified playback while the communication session is active. |
There was a problem hiding this comment.
are you sure it will work with the media output profile?
| await recorder.start(); | ||
| ``` | ||
|
|
||
| Channel indices start at zero, so `getChannelData(0)` returns the mono channel as a `Float32Array`. Its samples are floating-point values, normally between `-1` and `1`; they are not already PCM16 bytes or base64 text. |
There was a problem hiding this comment.
| Channel indices start at zero, so `getChannelData(0)` returns the mono channel as a `Float32Array`. Its samples are floating-point values, normally between `-1` and `1`; they are not already PCM16 bytes or base64 text. | |
| `getChannelData()` returns the channel as a `Float32Array`. Its samples are floating-point values, normally between `-1` and `1`; they are not already PCM16 bytes or base64 text. |
|
|
||
| An AI reply often arrives as many small pieces rather than one complete recording. [`AudioBufferQueueSourceNode`](../sources/audio-buffer-queue-source-node.mdx) is a playback source that consumes a queue of decoded audio buffers in order. Unlike creating a separate source for every chunk, it gives the reply one continuous playback path. | ||
|
|
||
| `connect()` attaches the source to the graph. `audioContext.destination` is the graph's output to the device: |
There was a problem hiding this comment.
also links to the documentation parts
|
|
||
| Call `start()` only once for that queue source, not once per chunk or reply. More buffers can be enqueued while it is playing. An empty queue waits for more audio, so it can also be reused for later replies in the same conversation. | ||
|
|
||
| **If pieces of a reply play in the wrong order**, check the decoding flow. The queue preserves enqueue order, but independent asynchronous decode calls may finish in a different order from arrival. The app needs to serialize decoding and enqueueing; the queue cannot restore the original order afterwards. Gaps can also mean the queue is waiting for data, rather than that another `start()` call is needed. |
| - `AudioManager` configures the communication session and route. | ||
| - `AudioRecorder` supplies microphone samples through callbacks. | ||
| - `AudioContext` and `AudioBufferQueueSourceNode` decode and play streamed replies. |
There was a problem hiding this comment.
same case with links to docs pages
| - `AudioContext` and `AudioBufferQueueSourceNode` decode and play streamed replies. | ||
| - The app coordinates audio formats, decode ordering, and interruption decisions. | ||
|
|
||
| Understanding those boundaries helps distinguish an audio-data problem from a routing or conversation-state problem. See the [AudioManager](../system/audio-manager.mdx), [AudioRecorder](../inputs/audio-recorder.mdx), and [queue source](../sources/audio-buffer-queue-source-node.mdx) references for the individual APIs. |
There was a problem hiding this comment.
| Understanding those boundaries helps distinguish an audio-data problem from a routing or conversation-state problem. See the [AudioManager](../system/audio-manager.mdx), [AudioRecorder](../inputs/audio-recorder.mdx), and [queue source](../sources/audio-buffer-queue-source-node.mdx) references for the individual APIs. | |
| See the [AudioManager](../system/audio-manager.mdx), [AudioRecorder](../inputs/audio-recorder.mdx), and [queue source](../sources/audio-buffer-queue-source-node.mdx) references for the individual APIs. |
Based on the APIs introduced in:
Introduced changes
Only the new guide is included; existing documentation pages are unchanged.
Checklist