SpeechToTextPlayground component is the main orchestrator for the speech-to-text functionality. It manages the state for API authentication, file handling, transcription options, and results display.
Component Overview
This component integrates theTranscriptionForm and TranscriptionResult components to provide a complete transcription workflow. It handles:
- API key management
- File selection and validation
- Transcription options configuration
- ElevenLabs API integration
- Result processing and display
- Error handling
- Speaker identification and naming
State Management
The component uses React hooks to manage the following state:string
User’s ElevenLabs API key for authentication
File | null
Selected audio/video file for transcription
boolean
Loading state during transcription API call
TranscriptResult | null
Transcription result containing transcript, audio URL, and alignment data
string | null
Error message from failed transcription attempts
SpeakerNames
Record mapping speaker IDs to custom display names
TranscriptOptions
Configuration options for the transcription request
Usage Example
TypeScript Interfaces
TranscriptOptions
Configuration options for the transcription API request:TranscriptResult
Result object containing transcription data:SpeakerNames
Mapping of speaker IDs to custom names:Default Configuration
The component initializes with these default transcription options:Component Lifecycle
1. File Selection
When a user selects a file:- The file state is updated
- Any existing results are cleared
- Audio type is determined from file extension/MIME type
2. Transcription Process
When the form is submitted:3. Speaker Name Management
Users can customize speaker labels:Component Structure
The component renders two main sections:Dependencies
Source Location
/home/daytona/workspace/source/src/features/speech-to-text-playground/speech-to-text-playground.tsx