Start Migration to Swift 6 - #171
BrandonWeng wants to merge 8 commits into
Conversation
|
Claude finished @BrandonWeng's task —— View job PR Review: Swift 6 Migration AnalysisComprehensive review completed! I've analyzed all changes in this Swift 6 migration PR and provided detailed feedback through GitHub's review system. Review Tasks:
✅ Review SummaryThis is a high-quality Swift 6 migration that demonstrates excellent adherence to concurrency best practices:
The incremental approach to handling 712 warnings is pragmatic and will lead to better long-term code quality. All changes maintain performance characteristics while improving thread safety. Verdict: ✅ Recommended for merge - Moves the project in the right direction for Swift 6 compatibility. |
There was a problem hiding this comment.
Swift 6 Migration Review
This PR makes excellent progress on migrating to Swift 6 with proper concurrency handling. The changes demonstrate a solid understanding of Swift 6's strict concurrency requirements. Here's my detailed analysis:
✅ Excellent Changes
Package.swift (Lines 33-36, 54-57)
- Enabling
StrictConcurrencyis the correct approach for Swift 6 migration - This will catch concurrency issues at compile time and enforce proper Sendable conformance
- Perfectly aligns with the project's guideline to never use
@unchecked Sendable
Sendable Conformance Additions
TdtDecoderState: Sendable- ✅ Correct: This struct contains only value types (MLMultiArray, Int?, which are Sendable)AssignmentConfig: Sendable- ✅ Correct: Contains only Float valuesDownloadConfig: Sendable- ✅ Correct: Contains only TimeInterval (Double)AppLogger: Sendable- ✅ Correct: All stored properties are SendableAppLogger.Level: Sendable- ✅ Correct: Simple enum with Int raw values
🔧 Good Improvements
AppLogger.swift Changes
- Converting
defaultSubsystemfromvartolet(line 9) - ✅ Good: Immutable static properties are safer for concurrency - Adding explicit variable captures in
logToConsole(lines 85-87) - ✅ Good: This ensures captured values are safely passed to the detached task
EspeakG2P Actor Conversion
- Converting from
final classwith DispatchQueue toactor- ✅ Excellent: This is the proper Swift 6 approach for thread safety - Removing
queue.syncwrapper andcurrentVoicetracking - ✅ Good: Actors provide automatic synchronization - Simplifying voice switching logic - ✅ Good: The actor isolation handles thread safety
AssetDownloader Typealias Updates
- Adding
@Sendableto closure types - ✅ Correct: Required for Swift 6 strict concurrency
🎯 Architecture Assessment
This migration demonstrates excellent adherence to the project's core principles:
- ✅ No
@unchecked Sendableusage - Following the strict "NEVER USE" rule from CLAUDE.md - ✅ Proper actor usage - EspeakG2P conversion is textbook Swift 6 migration
- ✅ Gradual migration approach - Smart to tackle 712 warnings incrementally
- ✅ Maintains performance - Changes don't introduce unnecessary overhead
📊 Performance Considerations
- Actor overhead: EspeakG2P actor conversion may add slight overhead for phonemization calls, but this is acceptable for thread safety
- Memory safety: All changes maintain the existing memory optimization patterns
- ANE compatibility: TdtDecoderState changes don't affect Apple Neural Engine optimization
🔍 Potential Issues (Minor)
- EspeakG2P voice switching: The new implementation calls
espeak_SetVoiceByNameon everyphonemizecall when already initialized. Consider caching the current voice to avoid redundant calls:
private var currentVoice: String = ""
// In initializeIfNeeded:
if initialized && espeakVoice != currentVoice {
// Set voice and update currentVoice
}🚀 Next Steps Recommendations
- Continue incremental approach - The 712 → ??? warning reduction strategy is solid
- Monitor test performance - Ensure actor changes don't affect benchmarks significantly
- Consider streaming implications - Verify EspeakG2P actor doesn't introduce latency in TTS pipeline
📝 Summary
This is a high-quality Swift 6 migration that properly addresses concurrency without shortcuts. The changes are architecturally sound, follow best practices, and maintain the project's performance characteristics. The gradual approach to handling the remaining warnings is pragmatic and will lead to a more maintainable codebase.
Verdict: ✅ Approve for merge - This PR moves the project in the right direction for Swift 6 compatibility.
Speaker Diarization Benchmark ResultsSpeaker Diarization PerformanceEvaluating "who spoke when" detection accuracy
Diarization Pipeline Timing BreakdownTime spent in each stage of speaker diarization
Speaker Diarization Research ComparisonResearch baselines typically achieve 18-30% DER on standard datasets
Note: RTFx shown above is from GitHub Actions runner. On Apple Silicon with ANE:
🎯 Speaker Diarization Test • AMI Corpus ES2004a • 1049.0s meeting audio • 39.6s diarization time • Test runtime: 1m 12s • 10/29/2025, 03:55 PM EST |
VAD Benchmark ResultsPerformance Comparison
Dataset Details
✅: Average F1-Score above 70% |
Offline VBx Pipeline ResultsSpeaker Diarization Performance (VBx Batch Mode)Optimal clustering with Hungarian algorithm for maximum accuracy
Offline VBx Pipeline Timing BreakdownTime spent in each stage of batch diarization
Speaker Diarization Research ComparisonOffline VBx achieves competitive accuracy with batch processing
Pipeline Details:
🎯 Offline VBx Test • AMI Corpus ES2004a • 1049.0s meeting audio • 332.2s processing • Test runtime: 5m 31s • 10/29/2025, 03:58 PM EST |
There was a problem hiding this comment.
💡 Codex Review
https://github.com/FluidInference/FluidAudio/blob/0586c80c6924d7b0e18ad2f5264e38d6e2a52017/Sources/FluidAudio/TextToSpeech/Kokoro/Pipeline/Preprocess/KokoroChunker.swift#L496-L498
Actor conversion broke synchronous phonemizer calls
After turning EspeakG2P into an actor, phonemize is now an actor-isolated method and external callers must await it. resolvePhonemes still invokes EspeakG2P.shared.phonemize synchronously (also around line 513), so the file no longer compiles under Strict Concurrency (actor-isolated instance method ... can only be referenced asynchronously). The function needs to become async or the calls must hop to the actor; otherwise every build of the target fails.
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
0586c80 to
9c712db
Compare
ASR Benchmark Results ✅Status: All benchmarks passed Parakeet v3 (multilingual)
Parakeet v2 (English-optimized)
Streaming (v3)
Streaming (v2)
Streaming tests use 5 files with 0.5s chunks to simulate real-time audio streaming 25 files per dataset • Test runtime: 7m38s • 10/29/2025, 04:02 PM EST RTFx = Real-Time Factor (higher is better) • Calculated as: Total audio duration ÷ Total processing time Expected RTFx Performance on Physical M1 Hardware:• M1 Mac: ~28x (clean), ~25x (other) Testing methodology follows HuggingFace Open ASR Leaderboard |
Why is this change needed?
712 warnings still but working on it one bunch at a time. Going to keep the PR open to run tests in the background as I work on the warnings.
This should help with the concurrency crashing issue some of the devs are seeing