OpenAI icon indicating copy to clipboard operation
OpenAI copied to clipboard

streamline `performSpeechRequest`

Open kalafus opened this issue 1 year ago • 1 comments

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

kalafus avatar Feb 14 '24 22:02 kalafus

Quality Gate Passed Quality Gate passed

Issues
0 New issues

Measures
0 Security Hotspots
No data about Coverage
1.0% Duplication on New Code

See analysis details on SonarCloud

sonarqubecloud[bot] avatar Feb 16 '24 01:02 sonarqubecloud[bot]