{"id":25830372,"url":"https://github.com/compiler-inc/transcriber","last_synced_at":"2025-07-11T11:35:49.670Z","repository":{"id":278472085,"uuid":"935734927","full_name":"Compiler-Inc/Transcriber","owner":"Compiler-Inc","description":"A modern, Swift-native wrapper around Apple's Speech framework and SFSpeechRecognizer that provides an actor-based interface for speech recognition with automatic silence detection and custom language model support.","archived":false,"fork":false,"pushed_at":"2025-03-30T00:53:48.000Z","size":115,"stargazers_count":14,"open_issues_count":3,"forks_count":0,"subscribers_count":4,"default_branch":"main","last_synced_at":"2025-06-03T09:17:07.296Z","etag":null,"topics":["actor","asr","ios","macos","sfspeechrecognizer","swift"],"latest_commit_sha":null,"homepage":"","language":"Swift","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Compiler-Inc.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2025-02-19T23:45:49.000Z","updated_at":"2025-05-31T20:05:02.000Z","dependencies_parsed_at":"2025-02-20T23:20:48.323Z","dependency_job_id":"3a21db09-7af0-418d-a0fa-48b24bb2c38f","html_url":"https://github.com/Compiler-Inc/Transcriber","commit_stats":null,"previous_names":["compiler-inc/speechrecognitionservice","compiler-inc/transcriber"],"tags_count":10,"template":false,"template_full_name":null,"purl":"pkg:github/Compiler-Inc/Transcriber","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Compiler-Inc%2FTranscriber","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Compiler-Inc%2FTranscriber/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Compiler-Inc%2FTranscriber/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Compiler-Inc%2FTranscriber/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Compiler-Inc","download_url":"https://codeload.github.com/Compiler-Inc/Transcriber/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Compiler-Inc%2FTranscriber/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":264795839,"owners_count":23665241,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["actor","asr","ios","macos","sfspeechrecognizer","swift"],"created_at":"2025-02-28T19:16:06.245Z","updated_at":"2025-07-11T11:35:49.655Z","avatar_url":"https://github.com/Compiler-Inc.png","language":"Swift","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Transcriber\n\nA modern, Swift-native wrapper around Apple's `Speech` framework and `SFSpeechRecognizer` that provides an actor-based interface for speech recognition with automatic silence detection and custom language model support.\n\n## Features\n\n- ✨ Modern Swift concurrency with async/await\n- 🔒 Thread-safe actor-based design\n- 🎯 Automatic silence detection using RMS power analysis\n- 🔊 Support for custom language models\n- 📱 Works across iOS, macOS, and other Apple platforms\n- 💻 SwiftUI-ready with MVVM support\n- 🔍 Comprehensive error handling\n- 📊 Debug logging support\n\n## Requirements\n\n- iOS 17.0+ / macOS 14.0+\n- Swift 5.9+\n- Xcode 15.0+\n\n## Installation\n\n### Swift Package Manager\n\nAdd the following to your `Package.swift` file:\n\n```swift\ndependencies: [\n    .package(url: \"https://github.com/Compiler-Inc/Transcriber.git\", from: \"0.1.1\")\n]\n```\n\nOr in Xcode:\n1. File \u003e Add Packages...\n2. Enter `https://github.com/Compiler-Inc/Transcriber.git`\n3. Select \"Up to Next Major Version\" with \"0.1.1\"\n\n### Privacy Keys\n\nThe service requires microphone and speech recognition access. Add these keys to your `Info.plist`:\n\n```xml\n\u003ckey\u003eNSMicrophoneUsageDescription\u003c/key\u003e\n\u003cstring\u003eWe need microphone access to transcribe your speech.\u003c/string\u003e\n\u003ckey\u003eNSSpeechRecognitionUsageDescription\u003c/key\u003e\n\u003cstring\u003eWe need speech recognition to convert your voice to text.\u003c/string\u003e\n```\n\nOr in Xcode:\n1. Select your project in the sidebar\n2. Select your target\n3. Select the \"Info\" tab\n4. Add `Privacy - Microphone Usage Description` and `Privacy - Speech Recognition Usage Description`\n\n## Usage\n\n### Basic Implementation\n\nThe simplest way to use the service is with the default configuration:\n\n```swift\nfunc startRecording() async throws {\n    // Initialize with default configuration\n    let transcriber = Transcriber()\n    \n    // Request authorization\n    let status = await transcriber.requestAuthorization()\n    guard status == .authorized else {\n        throw TranscriberError.notAuthorized\n    }\n    \n    // Start recording and receive transcriptions\n    let stream = try await transcriber.startStream()\n    for try await transcription in stream {\n        print(\"Transcribed text: \\(transcription)\")\n    }\n}\n```\n\n### Configuration Options\n\nThe service is highly configurable through defining your own `TranscriberConfiguration`.\n\n```swift\n    let myConfig = TranscriberConfiguration(\n        appIdentifier: \"com.myapp.speech\",\n        locale: .current,                       // Recognition language\n        silenceThreshold: 0.01,                 // RMS power threshold (0.0 to 1.0)\n        silenceDuration: 2,                     // Duration of silence before stopping\n        languageModelInfo: nil,                 // For domain-specific recognition\n        requiresOnDeviceRecognition: false,     // Force on-device processing\n        shouldReportPartialResults: true,       // Get results as they're processed\n        contextualStrings: [\"Custom\", \"Words\"], // Improve recognition of specific terms\n        taskHint: .unspecified,                 // Optimize for specific speech types\n        addsPunctuation: true                   // Automatic punctuation\n    )    \n```\n\n### Using in SwiftUI\n\nFor SwiftUI applications, we provide a protocol-based MVVM pattern:\n\n```swift\n// 1. Create your view model\n@Observable\n@MainActor\nclass MyViewModel: Transcribable {\n    public var isRecording = false\n    public var transcribedText = \"\"\n    public var rmsLevel: Float = 0\n    public var authStatus: SFSpeechRecognizerAuthorizationStatus = .notDetermined\n    public var error: Error?\n    \n    public let transcriber: Transcriber?\n    private var recordingTask: Task\u003cVoid, Never\u003e?\n    \n    init() {\n        self.transcriber = Transcriber()\n    }\n    \n    // Required protocol methods\n    public func requestAuthorization() async throws {\n        guard let transcriber else {\n            throw TrannscriberError.noRecognizer\n        }\n        authStatus = await transcriber.requestAuthorization()\n        guard authStatus == .authorized else {\n            throw TranscriberError.notAuthorized\n        }\n    }\n    \n    public func toggleRecording() {\n        guard let transcriber else {\n            error = TranscriberError.noRecognizer\n            return\n        }\n        \n        if isRecording {\n            recordingTask?.cancel()\n            recordingTask = nil\n            isRecording = false\n        } else {\n            recordingTask = Task {\n                do {\n                    isRecording = true\n                    let stream = try await transcriber.startRecordingStream()\n                    \n                    for try await signal in stream {\n                        switch signal {\n                            case .rms(let float):\n                                rmsLevel = float\n                            case .transcription(let string):\n                                transcribedText = string\n                        }\n                    }\n                    \n                    isRecording = false\n                } catch {\n                    self.error = error\n                    isRecording = false\n                }\n            }\n        }\n    }\n}\n// 2. Use in your SwiftUI view\nstruct MySpeechView: View {\n    @State private var viewModel = MyViewModel()\n    \n    var body: some View {\n        VStack {\n            Text(viewModel.transcribedText)\n            Button(viewModel.isRecording ? \"Stop\" : \"Start\") {\n                viewModel.toggleRecording()\n            }\n            .disabled(viewModel.authStatus != .authorized)\n            \n            if let error = viewModel.error {\n                Text(error.localizedDescription)\n                    .foregroundColor(.red)\n            }\n        }\n        .task {\n            try? await viewModel.requestAuthorization()\n        }\n    }\n}\n```\n\n## Advanced Features\n\n### Debug Logging\n\nEnable detailed logging for debugging:\n\n```swift\nlet transcriber = Transcriber(debugLogging: true)\n```\n\n### Custom Language Models\n\nSupport for custom language models with version tracking:\n\n```swift\nlet model = LanguageModelInfo(url: modelURL,version: \"2.0-beta\")\nlet config = TranscriberConfiguration(languageModelInfo: model)\n```\n\nYou can easily build `SFCustomLanguageModelData` models with our [SpeechModelBuilder CLI Tool](https://github.com/Compiler-Inc/SpeechModelBuilder)\n\n### Silence Detection\n\nAutomatic silence detection using RMS power analysis with configurable threshold and duration:\n\n```swift\nstruct SensitiveConfig: TranscriberConfiguration {\n    var silenceThreshold: Float = 0.001  // Very sensitive\n    var silenceDuration: TimeInterval = 2.0  // Longer confirmation\n    // ... other properties\n}\n```\n\n## License\n\nThis project is licensed under the MIT License\n\n## Contributing\n\nContributions are welcome! Please feel free to submit a Pull Request. \n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcompiler-inc%2Ftranscriber","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcompiler-inc%2Ftranscriber","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcompiler-inc%2Ftranscriber/lists"}