The "say" command works fine with personal voice, but it doesn't do the necessary tasks to request permissions to be granted to the Terminal app.
The problem is that Mac OS Sonoma does not allow you to manually add an application to the list of authorized apps, even though there is a "+" sign in Settings - Accessibility - Personal Voice - Allow applications to use your personal voice.
To fix this, you can compile and run an objective-c command line tool that requests permissions when it's run from terminal from the first time, then terminal will be granted with Personal Voice permissions and "say" (and any other command line tool that uses personal voice speech synthesis) will work.
A very tiny implementation would be: (Requires Xcode 15 or latest Command Line Tools)
#import <AVFoundation/AVFoundation.h>
int main(){
[AVSpeechSynthesizer requestPersonalVoiceAuthorizationWithCompletionHandler:^(AVSpeechSynthesisPersonalVoiceAuthorizationStatus status){
// authorization popup should be visible now
}];
[[NSRunLoop currentRunLoop] run];
return 0;
}
Save it as: mysay.c
and you can compile it at command line with:
gcc -x objective-c -framework AVFoundation -framework Foundation mysay.c -o mysay
and run it as
./mysay
Mac OS should then popup a message asking to grant permissions to Terminal. After accepting this, say -v YourVoiceName "Hello world"
should work