laguagu/claude-code-nextjs-skills / skills/ai-elements
ai-elements
VerifiedMaintains AI chat UI built from elements.ai-sdk.dev AI Elements components already copied into the project. Use when changing or debugging those components (conversations, messages, prompt inputs, attachments, reasoning, tool output, sources). New chat UI uses the shadcn/ui AI Elements patterns (`shadcn` skill).
scripts/speech-input.tsx
View on GitHub"use client";
import { SpeechInput } from "@/components/ai-elements/speech-input";
import { useCallback, useState } from "react";
/**
* Fallback handler for browsers that don't support Web Speech API (Firefox, Safari).
* This function receives recorded audio and should send it to a transcription service.
* Example uses OpenAI transcription API (model checked 2026-10-11) - replace with your preferred service.
*/
const handleAudioRecorded = async (audioBlob: Blob): Promise<string> => {
const formData = new FormData();
formData.append("file", audioBlob, "audio.webm");
formData.append("model", "gpt-transcribe");
const response = await fetch(
"https://api.openai.com/v1/audio/transcriptions",
{
body: formData,
headers: {
Authorization: `Bearer ${process.env.NEXT_PUBLIC_OPENAI_API_KEY}`,
},
method: "POST",
}
);
if (!response.ok) {
throw new Error("Transcription failed");
}
const data = await response.json();
return data.text;
};
const Example = () => {
const [transcript, setTranscript] = useState("");
const handleTranscriptionChange = useCallback((text: string) => {
setTranscript((prev) => {
const newText = prev ? `${prev} ${text}` : text;
return newText;
});
}, []);
const handleClear = useCallback(() => {
setTranscript("");
}, []);
return (
<div className="flex size-full flex-col items-center justify-center gap-4">
<div className="flex gap-2">
<SpeechInput
onAudioRecorded={handleAudioRecorded}
onTranscriptionChange={handleTranscriptionChange}
size="icon"
variant="outline"
/>
{transcript && (
<button
className="text-muted-foreground text-sm underline hover:text-foreground"
onClick={handleClear}
type="button"
>
Clear
</button>
)}
</div>
{transcript ? (
<div className="max-w-md rounded-lg border bg-card p-4 text-sm">
<p className="text-muted-foreground">
<strong>Transcript:</strong>
</p>
<p className="mt-2">{transcript}</p>
</div>
) : (
<p className="text-muted-foreground text-sm">
Click the microphone to start speaking
</p>
)}
</div>
);
};
export default Example;
Related skills
| Skill | Stars | Updated | Works with | Status | Install |
|---|---|---|---|---|---|
| brainstormingobra/superpowersYou MUST use this before any creative work - creating features, building components, adding functionality, modifying behavior, or planning anything new, in software or out of it (a talk, a business, a renovation). | Stars: 322k | Updated | Claude CodeCodex | Verified | Install |
| brand-guidelinesanthropics/skillsApplies Anthropic's official brand colors and typography to any sort of artifact that may benefit from having Anthropic's look-and-feel. Use it when brand colors or style guidelines, visual formatting, or company design standards apply. | Stars: 197k | Updated | Claude CodeCodex | Verified | Install |
| frontend-designanthropics/skillsGuidance for distinctive, intentional visual design when building new UI or reshaping an existing one. Helps with aesthetic direction, typography, and making choices that don't read as templated defaults. | Stars: 197k | Updated | Claude CodeCodex | Verified | Install |
| mcp-builderanthropics/skillsGuide for creating high-quality MCP (Model Context Protocol) servers that enable LLMs to interact with external services through well-designed tools. Use when building MCP servers to integrate external APIs or services, whether in Python (FastMCP) or Node/TypeScript (MCP SDK). | Stars: 197k | Updated | Claude CodeCodex | Verified | Install |