I have a cross-platform TTS crate that works mostly fine on Intel macs (it crashes for some users but works for most.) Unfortunately, the AVFoundation backend doesn't work at all on M1s, and I'm wondering if anyone can either offer pointers or PRs? I myself don't have an M1 and am pretty limited in what I can check.
The specific module that's failing is here. Specifically, this function runs, but doesn't speak. Callbacks seem to run, but the cancel callback runs immediately after speech is attempted. Apple's own docs claim this shouldn't run unless speech is stopped, but the only code I have to do this isn't run according to my logging.
I'm not sure if there's a better way to call these APIs other than how I am currently--using the objc crate to send calls to Objective C. I don't suppose Apple has a hidden C-FFI-compatible interface I could call instead?
So far I've tried commenting out the lines that explicitly set utterance properties for volume/pitch/rate, so all the function does is create the
NSString and call the ObjC method after assigning the string to the utterance. No luck.
One thing I've noticed is that ARM cross-compilation seems to bring up casting errors that the compiler usually catches for me. Here, for instance, I had to add an
i8 cast to make the code compile on M1s. And this backend works fine on M1s, so clearly I'm doing something right. But given that I have to drop into these unsafe blocks to poke the ObjC APIs, and given the cast errors that the compiler caught for me, I'm wondering if the more complex AVFoundation code is hitting a similar issue on the M1, but since it's in an unsafe block, the compiler isn't able to help. Suggestions welcome--I've been wracking my brain on this one for days and just don't know how to solve it. Sorry I can't distill it to a minimal example. If you have an M1, running:
cargo run --example hello_world
should run the example that fails. And the issue I'm having lies somewhere in the AVFoundation code, which is only a couple hundred lines or so.
Thanks a bunch.