I encountered similar problem where in I was not able to record voice in ios 16,I was getting the below error
Error Domain=NSOSStatusErrorDomain Code=-50 "(null)"
I had changed the category from record to playAndRecord and
add defaultToSpeaker in options.
Post this changes it was working as expected.