Our ASR API never requires a MIME type unless you are making a fetch request with a JSON body, in which case it must be application/json.
The proposal is to remove this requirement from file requests, which will simplify the SDKs. We unfurl the body from an object, right now. We can just allow the user to pass audio data directly to the prerecorded file methods, and have it turned directly into a body for the POST request.
Existing use:
const result = deepgram.listen.prerecorded.transcribeFile({ buffer: audioBuffer, mimetype: "audio/mp4"}, options);
Existing SDK code:
async transcribeFile(
source: FileSource,
options?: PrerecordedOptions,
endpoint = "v1/listen"
): Promise<DeepgramResponse<SyncPrerecordedResponse>> {
if (source.mimetype === undefined || source.mimetype.length === 0) {
throw new DeepgramError(
"Mimetype must be provided if the source is a Buffer or a Readable"
);
}
this.headers["Content-Type"] = source.mimetype;
let body;
if (isBufferSource(source)) {
body = source.buffer;
} else if (isReadStreamSource(source)) {
body = source.stream;
} else {
throw new DeepgramError("Unknown transcription source type");
}
// ...
return await this.post(this.fetch as Fetch, url, body, {
headers: this.headers,
});
}
Proposed use:
const result = deepgram.listen.prerecorded.transcribeFile(audioBuffer, options);
Our ASR API never requires a MIME type unless you are making a fetch request with a JSON body, in which case it must be
application/json
.The proposal is to remove this requirement from file requests, which will simplify the SDKs. We unfurl the body from an object, right now. We can just allow the user to pass audio data directly to the prerecorded file methods, and have it turned directly into a body for the
POST
request.Existing use:
Existing SDK code:
Proposed use:
Proposed SDK code: