Audio File Transcription
Relevant source files
The following files were used as context for generating this wiki page:
- VoiceInk/Services/AudioFileTranscriptionManager.swift
- VoiceInk/Services/AudioFileTranscriptionService.swift
- VoiceInk/Views/AudioTranscribeView.swift
- VoiceInk/Models/Transcription.swift
- VoiceInk/Whisper/WhisperState.swift
- VoiceInk/Services/NativeAppleTranscriptionService.swift
- VoiceInk/Services/ParakeetTranscriptionService.swift
The Audio File Transcription feature provides users with the ability to transcribe pre-existing audio or video files. This is distinct from the live recording-to-text functionality. Users can select a file from their system or drag-and-drop it into the application. The system then processes the audio, transcribes it using a selected model, applies optional AI enhancements, and saves the result as a Transcription record in the application's database.
This system is designed to be modular, supporting various transcription providers including local models (Whisper, Parakeet), native Apple services, and multiple cloud-based APIs. The entire process is managed by the AudioTranscriptionManager and presented to the user through the AudioTranscribeView.
Architecture Overview
The feature is orchestrated by the AudioTranscriptionManager, which acts as a singleton. It coordinates the UI (AudioTranscribeView), audio processing, transcription service delegation, and data persistence.
The following diagram illustrates the high-level architecture of the file transcription system.
User Interface
The user interface for file transcription is provided by AudioTranscribeView. It serves two main purposes: file selection and progress/result display.
Key UI Components
- Drop Zone: A designated area where users can drag and drop audio or video files. It supports formats like WAV, MP3, M4A, AIFF, MP4, and MOV.
- File Picker: A "Choose File" button that opens a standard
NSOpenPanelfor file selection. - Selected File View: Once a file is selected, the view displays the filename and presents options to start the transcription or choose a different file.
- AI Enhancement Toggle: Allows the user to enable or disable AI enhancement for the transcription. If enabled, a
Pickerfor selecting a specific prompt appears. - Processing View: When transcription is in progress, this view shows a
ProgressViewand a status message indicating the current phase (e.g., "Transcribing audio..."). - Result View: After completion, the resulting
Transcriptionobject is displayed in aTranscriptionResultView. - Error Alert: If an error occurs during the process, an alert is shown with the error message.
The view interacts directly with the AudioTranscriptionManager.shared singleton to initiate and monitor the transcription process.
Sources: VoiceInk/Views/AudioTranscribeView.swift:15-177
Core Logic and Flow
The AudioTranscriptionManager is the central component that orchestrates the entire file transcription process. It manages the state and coordinates the various services involved.
Processing State
The manager tracks the current state of the operation through a ProcessingPhase enum.
| Phase | Message | Description |
|---|---|---|
idle | "" | The manager is not processing any file. |
loading | "Loading transcription model..." | Initial phase when processing starts. |
processingAudio | "Processing audio file for transcription..." | The raw audio is being converted to the required format (WAV samples). |
transcribing | "Transcribing audio..." | The audio is being sent to the selected transcription service. |
enhancing | "Enhancing transcription with AI..." | The transcribed text is being processed by the AI enhancement service. |
completed | "Transcription completed!" | The process has finished successfully. |
Sources: VoiceInk/Services/AudioFileTranscriptionManager.swift:23-44
Transcription Flow
The following sequence diagram details the steps involved when a user starts a transcription from the AudioTranscribeView.
Transcription Services
The AudioTranscriptionManager delegates the core transcription task to a specific service based on the provider property of the currently selected model. This allows for a plug-and-play architecture for different transcription backends.
Service Implementations
The system uses several service classes, each responsible for a specific type of transcription model.
LocalTranscriptionService: Handles on-device transcription usingwhisper.cppmodels.ParakeetTranscriptionService: Manages on-device transcription using Parakeet models.NativeAppleTranscriptionService: Uses Apple's nativeSpeechframework for transcription (available on macOS 26+).CloudTranscriptionService: A facade that routes requests to various cloud-based APIs like Soniox, Gemini, Groq, and ElevenLabs.
The following class diagram shows the relationship between the manager and the services.
Data Persistence
The result of each transcription is stored in the app's database using SwiftData. The Transcription model captures all relevant details of the operation.
Transcription Data Model
The erDiagram below shows the structure of the Transcription entity.
The table below describes the fields of the Transcription model.
| Field | Type | Description |
|---|---|---|
id | UUID | The unique identifier for the transcription record. |
text | String | The raw, post-processed transcribed text. |
enhancedText | String? | The AI-enhanced version of the text, if applicable. |
timestamp | Date | The date and time when the transcription was created. |
duration | TimeInterval | The duration of the original audio file in seconds. |
audioFileURL | String? | A string representation of the URL to the saved audio file. |
transcriptionModelName | String? | The display name of the model used for transcription. |
aiEnhancementModelName | String? | The name of the model used for AI enhancement. |
promptName | String? | The name of the prompt used for AI enhancement. |
transcriptionDuration | TimeInterval? | The time taken for the transcription process in seconds. |
enhancementDuration | TimeInterval? | The time taken for the AI enhancement process in seconds. |
powerModeName | String? | The name of the active Power Mode, if any. |
transcriptionStatus | String? | The final status of the transcription (pending, completed, failed). |
Sources: VoiceInk/Models/Transcription.swift:8-43
Retranscription
The application also supports re-transcribing an audio file, for instance, from the history view. This functionality is handled by AudioFileTranscriptionService. The retranscribeAudio(from:using:) method takes a URL to an existing audio file and a new transcription model. It follows a similar flow to the initial transcription but is designed to create a new Transcription object rather than updating an existing one.
Sources: VoiceInk/Services/AudioFileTranscriptionService.swift:34-198