OpenAI
OpenAI copied to clipboard
streamline `performSpeechRequest`
What
remove special handling of performSpeechRequest
handle receiving raw (non-JSON-wrapped) data in the same workflow as all other incoming data.
Why
AudioSpeechResult
wrapper uniquely does not represent JSON wrapped Data, but the endpoint rather returns raw Data.
Since it's not JSON encoded, there's no way to use JSONDecoder and init(Decoder:) to correctly handle the returned data, but exceptional handling can be added for Data return type to skip JSONDecoder and return the raw Data object. Exception first attempts to decode using builtin Data type JSONDecoder, and only returns raw data when Data type is specified, and JSONDecode as Data type has failed, so this is a pretty reusable approach.
Affected Areas
performSpeechRequest
Quality Gate passed
Issues
0 New issues
Measures
0 Security Hotspots
No data about Coverage
1.0% Duplication on New Code