Repository navigation
Python: DevUI audio input and response playback - #9462
Fernando de Oliveira (fedeoliv) wants to merge 24 commits into
Conversation
Send microphone recordings and uploaded WAV/MP3 files as input_audio content without transcription.
Render agent audio outputs with preview, download, and optional autoplay while preserving DevUI media output items in final responses. Refine microphone startup behavior and audio settings copy for a less noisy chat experience.
Add push-to-talk, live input level, optional silence auto-stop, clearer audio settings, and tighter recording/preview layouts.
There was a problem hiding this comment.
🟡 Changes recommended
Unresolved recording lifecycle and audio-handling defects can leave microphone capture active, disable the composer, or lose audio content.
6 open findings
Restrict audio data conversion to data URIs · New Handle top-level output_file audio responses · New Honor auto-play for OGG and FLAC fallback playback · New Reject multiple audio file selections · New Stop microphone stream if permission resolves after unmount · New Reset isStarting when stopping during microphone warmup · New
What changed in this PR
Adds audio input and response playback to Python DevUI, enabling developers to test audio-capable agents through the existing chat interface.
Changes:
- Adds microphone recording, WAV/MP3 uploads, previews, playback controls, and audio settings.
- Extends request mapping, response handling, and conversation persistence for audio.
- Adds backend tests and user-facing documentation.
| File | Description |
|---|---|
| python/packages/devui/tests/devui/test_multimodal_workflow.py | Tests audio input conversion and format rejection. |
| python/packages/devui/tests/devui/test_mapper.py | Tests streamed and aggregated audio output. |
| python/packages/devui/tests/devui/test_conversations.py | Tests audio persistence round trips. |
| python/packages/devui/README.md | Documents audio features and limitations. |
| python/packages/devui/frontend/src/types/openai.ts | Adds audio content and auto-play types. |
| python/packages/devui/frontend/src/types/agent-framework.ts | Adds structured audio input types. |
| python/packages/devui/frontend/src/stores/devuiStore.ts | Persists audio preferences. |
| python/packages/devui/frontend/src/hooks/use-audio-recorder.ts | Implements capture, WAV normalization, and analysis. |
| python/packages/devui/frontend/src/hooks/index.ts | Exports audio utilities. |
| python/packages/devui/frontend/src/components/ui/file-upload.tsx | Restricts audio selection to WAV/MP3. |
| python/packages/devui/frontend/src/components/ui/chat-message-input.tsx | Integrates recording and audio attachments. |
| python/packages/devui/frontend/src/components/ui/audio-message-preview.tsx | Adds recording and playback controls. |
| python/packages/devui/frontend/src/components/layout/settings-modal.tsx | Exposes audio settings. |
| python/packages/devui/frontend/src/components/features/agent/message-renderers/OpenAIMessageRenderer.tsx | Passes audio auto-play flags. |
| python/packages/devui/frontend/src/components/features/agent/message-renderers/OpenAIContentRenderer.tsx | Renders audio previews and players. |
| python/packages/devui/frontend/src/components/features/agent/agent-view.tsx | Integrates audio into chat messages. |
| python/packages/devui/agent_framework_devui/models/_openai_custom.py | Adds extension-compatible response models. |
| python/packages/devui/agent_framework_devui/models/__init__.py | Exports custom response models. |
| python/packages/devui/agent_framework_devui/_server.py | Serializes extended conversation items. |
| python/packages/devui/agent_framework_devui/_mapper.py | Preserves audio in mapped responses. |
| python/packages/devui/agent_framework_devui/_executor.py | Converts structured audio into agent content. |
| python/packages/devui/agent_framework_devui/_conversations.py | Adds audio conversation serialization. |
| python/packages/devui/agent_framework_devui/_audio.py | Centralizes audio format helpers. |
🧠 Review effort: Balanced
💡 Add a code-review agent skill for context-aware, tailored reviews. Learn more in the docs.
There was a problem hiding this comment.
🟡 Changes recommended
Recording limits, audio persistence, and playback behavior still have functional defects.
11 open findings
Preserve external URLs and explicitly tagged input files · New Restore playback for named audio input files · New Decode inline file data when available · New Honor autoplay for native audio fallback players · New Automatically finalize recordings at the maximum duration · New Reset isStarting when stopping during microphone warmup Stop microphone stream if permission resolves after unmount Reject multiple audio file selections Honor auto-play for OGG and FLAC fallback playback Handle top-level output_file audio responses Restrict audio data conversion to data URIs
🧠 Review effort: Balanced
Enhance audio content check to include additional conditions. Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
b1eed51 to
9b27221
Compare
Restore the OpenAI response alias to the SDK Response type and remove custom completed/failed event models so the audio backend changes stay localized to DevUI extension output items. Keep typed input_audio parsing for pyright and preserve audio conversion behavior without changing the OpenAI proxy executor contract. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: 259add50-0116-466a-9cbe-3ac3983977d4
Restore the conversation test to assert input_audio round-trip behavior instead of relying on the internal item representation, and keep mapper assertions compatible with the stricter typing checks used in CI. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: 259add50-0116-466a-9cbe-3ac3983977d4
Keep native SDK conversation contracts and validate only DevUI media extensions. Share response-media reconciliation and recorder resource ownership while retaining the original audio UI and controls. Add regressions for microphone cancellation, media recovery, generic uploads, and light/dark audio text contrast. Refs microsoft#9359 Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: 880103e4-e856-451b-b1b2-ddf4b47094b5
Keep chat audio aligned with response text while preserving centered composer previews and existing player styling. Refs microsoft#9359 Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: 880103e4-e856-451b-b1b2-ddf4b47094b5
| // For audio files | ||
| if (isAudio && fileUrl) { | ||
| if (isAudioFile && fileUrl) { | ||
| const sourceUrl = content.file_url || fileDataSourceUrl(content.file_data, mimeType) || fileUrl; |
There was a problem hiding this comment.
This reintroduces the earlier file_data/file_url issue. When both are present, selecting file_url first can lose otherwise valid embedded audio if that URL is expired or inaccessible. Please prefer fileDataSourceUrl(content.file_data, mimeType), fall back to file_url, and add coverage with both fields populated.
There was a problem hiding this comment.
thanks Jose Alvarez (@jpalvarezl), good catch! Just fixed it!
Integrate upstream changes while preserving existing DevUI audio behavior. Resolve generated bundle conflicts by rebuilding with the merged frontend dependencies. Refs microsoft#9359
Keep playback and downloads available when valid file_data accompanies an inaccessible file_url. Cover raw base64 and data URI payloads with both fields populated. Refs microsoft#9359

Motivation & Context
DevUI can render text conversations and file attachments, but it did not provide a complete path for testing agents that accept audio input or return audio output. This change adds that path so developers can test audio-capable agents directly in DevUI without building a custom UI.
The feature adds browser microphone recording with push-to-talk, preview before send, audio upload handling, audio response playback, optional auto-stop on silence, and clearer audio settings.
Description & Review Guide
What are the major changes?
Adds microphone recording in DevUI chat with WAV normalization before sending. Supports WAV and MP3 uploads as agent audio input.
Recording UX: push-to-talk, live mic level feedback, fixed-size recording layout, and optional auto-stop on silence.
Adds reusable audio preview and playback UI with waveform rendering, scrubber support, removal, download, and optional auto-play for agent audio responses.
Adds backend mapping for audio request and response content through DevUI conversations, executor handling, and OpenAI-compatible response mapping.
Adds audio settings under Settings, grouped into Input, Auto-stop on silence, and Output sections.
Adds tests for audio content mapping, conversation persistence, and multimodal workflow behavior.
Updates DevUI documentation with user-facing voice input guidance.
What is the impact of these changes?
What do you want reviewers to focus on?
Related Issue
Fixes #9359
AI Assistance
AI assistance details: GitHub Copilot assisted with implementation, testing, and UI refinements.
Contribution Checklist
breaking changelabel or add "[BREAKING]" to the title prefix, before or after any language prefix. A workflow keeps the label and title prefix in sync automatically.