From 2bae0c38b2471bc18ba405d10f4a5b0f90918024 Mon Sep 17 00:00:00 2001 From: John Matthew Tennant Date: Thu, 12 Nov 2026 18:14:43 -0500 Subject: [PATCH] fix(berd-call): list and download Siri voices on macOS 26 macOS 26 lists Siri's voices as com.apple.ttsbundle.gryphon-neural_* with .neural.premium assets. Berd accepted only macOS 27's com.apple.siri.natural.* voices, so on macOS 26 it listed no Siri voice and could not download one. Use the natural family where the catalog has it and the neural family otherwise. Co-authored-by: Gordon <6581f171b4f294207c04c83d43b057ea88caa717457980f756160f0212d4f429@buzz.block.builderlab.xyz> Co-Authored-By: Claude Opus 5.5 Signed-off-by: John Matthew Tennant --- .../crates/berd-call/native/siri_tts_bridge.m | 32 +++++++++++++++---- .../native/tests/siri_tts_stream_regression.m | 28 +++++++++++++--- 2 files changed, 49 insertions(+), 11 deletions(-) diff --git a/src-tauri/crates/berd-call/native/siri_tts_bridge.m b/src-tauri/crates/berd-call/native/siri_tts_bridge.m index 6aca6d48a..b7d0dfb58 100644 --- a/src-tauri/crates/berd-call/native/siri_tts_bridge.m +++ b/src-tauri/crates/berd-call/native/siri_tts_bridge.m @@ -1026,10 +1026,28 @@ static void BerdDownloadedVoices( return @[]; } -// The name a voice's natural premium UAF asset carries as its CFBundleName. -static NSString *BerdUAFVoiceAssetName(NSString *language, NSString *voiceName) { - return [[NSString stringWithFormat:@"com.apple.siri.tts.voice.%@.%@.natural.premium", - [language stringByReplacingOccurrencesOfString:@"-" withString:@"_"], voiceName] +// The catalog identifier prefix of a Siri voice family. +static NSString *BerdSiriVoicePrefix(NSString *family) { + return [family isEqualToString:@"natural"] + ? @"com.apple.siri.natural." + : @"com.apple.ttsbundle.gryphon-neural_"; +} + +// macOS 27 lists natural Siri voices, and Berd uses only those where they exist. +// macOS 26 has only neural ones. +static NSString *BerdSiriVoiceFamily(NSArray *resources) { + for (id resource in resources ?: @[]) { + if ([[resource valueForKey:@"identifier"] hasPrefix:BerdSiriVoicePrefix(@"natural")]) { + return @"natural"; + } + } + return @"neural"; +} + +// The name a voice's premium UAF asset in a family carries as its CFBundleName. +static NSString *BerdUAFVoiceAssetName(NSString *language, NSString *voiceName, NSString *family) { + return [[NSString stringWithFormat:@"com.apple.siri.tts.voice.%@.%@.%@.premium", + [language stringByReplacingOccurrencesOfString:@"-" withString:@"_"], voiceName, family] lowercaseString]; } @@ -1079,6 +1097,8 @@ static void BerdDownloadedVoices( return nil; } NSArray *resources = ((SendObject)objc_msgSend)(manager, voicesSelector, nil); + NSString *family = BerdSiriVoiceFamily(resources); + NSString *prefix = BerdSiriVoicePrefix(family); NSString *normalizedFilter = [[languageFilter stringByReplacingOccurrencesOfString:@"_" withString:@"-"] lowercaseString]; NSDictionary *diskAssets = BerdUAFVoiceAssets( @@ -1087,7 +1107,7 @@ static void BerdDownloadedVoices( [NSMutableDictionary dictionary]; for (id resource in resources ?: @[]) { NSString *identifier = [resource valueForKey:@"identifier"]; - if (![identifier hasPrefix:@"com.apple.siri.natural."]) continue; + if (![identifier hasPrefix:prefix]) continue; NSString *language = [resource valueForKey:@"language"] ?: @""; NSString *normalizedLanguage = [[language stringByReplacingOccurrencesOfString:@"_" withString:@"-"] lowercaseString]; @@ -1101,7 +1121,7 @@ static void BerdDownloadedVoices( // on disk. NSString *content = [resource valueForKey:@"contentPath"]; if (!content.length || ![NSFileManager.defaultManager fileExistsAtPath:content]) { - content = diskAssets[BerdUAFVoiceAssetName(language, name)]; + content = diskAssets[BerdUAFVoiceAssetName(language, name, family)]; } // Newer voices have a code as their name (en-US-F); macOS shows its localized name. NSString *localizedName = [resource respondsToSelector:@selector(localizedName)] diff --git a/src-tauri/crates/berd-call/native/tests/siri_tts_stream_regression.m b/src-tauri/crates/berd-call/native/tests/siri_tts_stream_regression.m index 583d55a26..048e4e612 100644 --- a/src-tauri/crates/berd-call/native/tests/siri_tts_stream_regression.m +++ b/src-tauri/crates/berd-call/native/tests/siri_tts_stream_regression.m @@ -258,17 +258,31 @@ static BOOL BerdTestVoiceDownloadIdentity(NSError **error) { } NSDictionary *assets = BerdUAFVoiceAssets(root); [files removeItemAtPath:root error:nil]; - if (![assets[BerdUAFVoiceAssetName(@"en-US", @"Damon")] hasSuffix:@"/a/AssetData"] || - ![assets[BerdUAFVoiceAssetName(@"en-US", @"en-US-F")] hasSuffix:@"/b/AssetData"] || - assets[BerdUAFVoiceAssetName(@"en-US", @"Quinn")] || - assets[BerdUAFVoiceAssetName(@"en-US", @"Simone")] || - assets[BerdUAFVoiceAssetName(@"en-GB", @"Damon")]) { + if (![assets[BerdUAFVoiceAssetName(@"en-US", @"Damon", @"natural")] hasSuffix:@"/a/AssetData"] || + ![assets[BerdUAFVoiceAssetName(@"en-US", @"en-US-F", @"natural")] hasSuffix:@"/b/AssetData"] || + assets[BerdUAFVoiceAssetName(@"en-US", @"Quinn", @"natural")] || + ![assets[BerdUAFVoiceAssetName(@"en-US", @"Quinn", @"neural")] hasSuffix:@"/c/AssetData"] || + assets[BerdUAFVoiceAssetName(@"en-US", @"Simone", @"natural")] || + assets[BerdUAFVoiceAssetName(@"en-GB", @"Damon", @"natural")]) { if (error) *error = BerdError(108, @"Siri voice assets on disk were matched wrongly."); return NO; } return YES; } +static BOOL BerdTestSiriVoiceFamily(NSError **error) { + NSDictionary *neural = @{ @"identifier" : @"com.apple.ttsbundle.gryphon-neural_Nora_en-US_premium" }; + NSDictionary *natural = @{ @"identifier" : @"com.apple.siri.natural.en-US.Nora" }; + if (![BerdSiriVoiceFamily(@[ neural, natural ]) isEqualToString:@"natural"] || + ![BerdSiriVoiceFamily(@[ neural ]) isEqualToString:@"neural"] || + ![neural[@"identifier"] hasPrefix:BerdSiriVoicePrefix(@"neural")] || + [@"com.apple.ttsbundle.gryphon-neuralAX_Nora_en-US_premium" hasPrefix:BerdSiriVoicePrefix(@"neural")]) { + if (error) *error = BerdError(109, @"Siri voices were listed from the wrong family."); + return NO; + } + return YES; +} + int main(void) { @autoreleasepool { NSError *error = nil; @@ -280,6 +294,10 @@ int main(void) { fprintf(stderr, "voice download identity: %s\n", error.localizedDescription.UTF8String); return 1; } + if (!BerdTestSiriVoiceFamily(&error)) { + fprintf(stderr, "Siri voice family: %s\n", error.localizedDescription.UTF8String); + return 1; + } if (!BerdTestPCMNormalization(&error)) { fprintf(stderr, "normalize PCM: %s\n", error.localizedDescription.UTF8String); return 1;