Skip to content

Commit ef0a8a7

Browse files
Voice (#317)
* New voice folder * Draft Audio Player component * Add support for AI SDK speech result * Draft Mic Selector component * Extract PromptInputSpeechButton to SpeechInput * Update speech-input.mdx * Add new unit tests * Merge groups * Fix tests * Improve test coverage * Run Ultracite * Update mic-selector.tsx * Draft Voice Selector * Scaffold Persona * Update persona.tsx * Redesign speech input as record button * Scaffold Transcription component * Fix unit tests * Propagate changes from #233 * Resolves #242 * Update mic-selector.tsx * Update preview.tsx * Attempt to overwrite color * Fix persona bugs * Remove Pal * Update persona.test.tsx * Resolves #210 * Fix non-model instances * Rename orb to opal, change default * Performance improvements * Update pnpm-lock.yaml * Fix navbar tracking * Minor fixes * Update registry mcp server * Add changesets * Update persona.test.tsx
1 parent f0625b5 commit ef0a8a7

55 files changed

Lines changed: 8205 additions & 556 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.changeset/bright-wolves-bathe.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"ai-elements": patch
3+
---
4+
5+
Update mcp server

.changeset/mighty-papers-stare.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"ai-elements": patch
3+
---
4+
5+
Add support for MediaRecorder and custom config to SpeechInput

.changeset/soft-peaches-visit.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"ai-elements": minor
3+
---
4+
5+
AI Voice Elements

apps/docs/components/custom/navbar/client-navbar.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ export const ClientNavbar = ({ pages }: { pages: NavPageItem[] }) => (
6161
{pages.map((page) => (
6262
<Button
6363
asChild
64-
className="p-0 font-normal text-muted-foreground tracking-[0.13px] hover:text-foreground hover:no-underline"
64+
className="p-0 font-normal text-muted-foreground hover:text-foreground hover:no-underline"
6565
key={page.href}
6666
variant="link"
6767
>

apps/docs/components/custom/preview.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ export const Preview = async ({ path, className }: ComponentPreviewProps) => {
8585
<CodeBlockTabsTrigger value="code">Code</CodeBlockTabsTrigger>
8686
</CodeBlockTabsList>
8787
<CodeBlockTab className="not-prose p-0" value="preview">
88-
<ResizablePanelGroup direction="horizontal">
88+
<ResizablePanelGroup direction="horizontal" id={`preview-${path}`}>
8989
<ResizablePanel defaultSize={100}>
9090
<div className={cn("h-[600px] overflow-auto p-4", className)}>
9191
<Component />

apps/docs/content/docs/components/(chatbot)/prompt-input.mdx

Lines changed: 43 additions & 70 deletions
Original file line numberDiff line numberDiff line change
@@ -37,14 +37,13 @@ import {
3737
PromptInputSelectItem,
3838
PromptInputSelectTrigger,
3939
PromptInputSelectValue,
40-
PromptInputSpeechButton,
4140
PromptInputSubmit,
4241
PromptInputTextarea,
4342
PromptInputFooter,
4443
PromptInputTools,
4544
} from '@/components/ai-elements/prompt-input';
4645
import { GlobeIcon } from 'lucide-react';
47-
import { useRef, useState } from 'react';
46+
import { useState } from 'react';
4847
import { useChat } from '@ai-sdk/react';
4948
import {
5049
Conversation,
@@ -62,7 +61,6 @@ const InputDemo = () => {
6261
const [text, setText] = useState<string>('');
6362
const [model, setModel] = useState<string>(models[0].id);
6463
const [useWebSearch, setUseWebSearch] = useState<boolean>(false);
65-
const textareaRef = useRef<HTMLTextAreaElement>(null);
6664

6765
const { messages, status, sendMessage } = useChat();
6866

@@ -126,7 +124,6 @@ const InputDemo = () => {
126124

127125
<PromptInputTextarea
128126
onChange={(e) => setText(e.target.value)}
129-
ref={textareaRef}
130127
value={text}
131128
/>
132129
</PromptInputBody>
@@ -138,10 +135,6 @@ const InputDemo = () => {
138135
<PromptInputActionAddAttachments />
139136
</PromptInputActionMenuContent>
140137
</PromptInputActionMenu>
141-
<PromptInputSpeechButton
142-
onTranscriptionChange={setText}
143-
textareaRef={textareaRef}
144-
/>
145138
<PromptInputButton
146139
onClick={() => setUseWebSearch(!useWebSearch)}
147140
variant={useWebSearch ? 'default' : 'ghost'}
@@ -509,68 +502,6 @@ export async function POST(req: Request) {
509502

510503
Optional global provider that lifts PromptInput state outside of PromptInput. When used, it allows you to access and control the input state from anywhere within the provider tree. If not used, PromptInput stays fully self-managed.
511504

512-
### `<PromptInputSpeechButton />`
513-
514-
<TypeTable
515-
type={{
516-
textareaRef: {
517-
description: 'Reference to the textarea element to insert transcribed text.',
518-
type: 'RefObject<HTMLTextAreaElement | null>',
519-
},
520-
onTranscriptionChange: {
521-
description: 'Callback fired when transcription text changes.',
522-
type: '(text: string) => void',
523-
},
524-
'...props': {
525-
description: 'Any other props are spread to the underlying PromptInputButton component.',
526-
type: 'React.ComponentProps<typeof PromptInputButton>',
527-
},
528-
}}
529-
/>
530-
531-
Built-in button component that provides native speech recognition using the Web Speech API. The button will be disabled if speech recognition is not supported in the browser. Displays a microphone icon and pulses while actively listening.
532-
533-
## Hooks
534-
535-
### `usePromptInputAttachments`
536-
537-
Access and manage file attachments within a PromptInput context.
538-
539-
```tsx
540-
const attachments = usePromptInputAttachments();
541-
542-
// Available methods:
543-
attachments.files // Array of current attachments
544-
attachments.add(files) // Add new files
545-
attachments.remove(id) // Remove an attachment by ID
546-
attachments.clear() // Clear all attachments
547-
attachments.openFileDialog() // Open file selection dialog
548-
```
549-
550-
### `usePromptInputController`
551-
552-
Access the full PromptInput controller from a PromptInputProvider. Only available when using the provider.
553-
554-
```tsx
555-
const controller = usePromptInputController();
556-
557-
// Available methods:
558-
controller.textInput.value // Current text input value
559-
controller.textInput.setInput(value) // Set text input value
560-
controller.textInput.clear() // Clear text input
561-
controller.attachments // Same as usePromptInputAttachments
562-
```
563-
564-
### `useProviderAttachments`
565-
566-
Access attachments context from a PromptInputProvider. Only available when using the provider.
567-
568-
```tsx
569-
const attachments = useProviderAttachments();
570-
571-
// Same interface as usePromptInputAttachments
572-
```
573-
574505
### `<PromptInputHeader />`
575506

576507
<TypeTable
@@ -761,3 +692,45 @@ const attachments = useProviderAttachments();
761692
},
762693
}}
763694
/>
695+
696+
697+
## Hooks
698+
699+
### `usePromptInputAttachments`
700+
701+
Access and manage file attachments within a PromptInput context.
702+
703+
```tsx
704+
const attachments = usePromptInputAttachments();
705+
706+
// Available methods:
707+
attachments.files // Array of current attachments
708+
attachments.add(files) // Add new files
709+
attachments.remove(id) // Remove an attachment by ID
710+
attachments.clear() // Clear all attachments
711+
attachments.openFileDialog() // Open file selection dialog
712+
```
713+
714+
### `usePromptInputController`
715+
716+
Access the full PromptInput controller from a PromptInputProvider. Only available when using the provider.
717+
718+
```tsx
719+
const controller = usePromptInputController();
720+
721+
// Available methods:
722+
controller.textInput.value // Current text input value
723+
controller.textInput.setInput(value) // Set text input value
724+
controller.textInput.clear() // Clear text input
725+
controller.attachments // Same as usePromptInputAttachments
726+
```
727+
728+
### `useProviderAttachments`
729+
730+
Access attachments context from a PromptInputProvider. Only available when using the provider.
731+
732+
```tsx
733+
const attachments = useProviderAttachments();
734+
735+
// Same interface as usePromptInputAttachments
736+
```

apps/docs/content/docs/components/(documentation)/open-in-chat.mdx renamed to apps/docs/content/docs/components/(utilities)/open-in-chat.mdx

File renamed without changes.

0 commit comments

Comments
 (0)