getTranscript method
Implementation
Future<TranscriptResponse> getTranscript(String audioId) => http
.get(Uri.parse("$GET_AUDIO_LYRIC?audio_id=$audioId"), headers: {'api-key': apiKey!})
.timeout(const Duration(seconds: 30))
.then((r) async {
try {
switch (r.statusCode) {
case 200:
case 400:
return TranscriptResponse.fromJson(json.decode(r.body));
default:
var msg = r.body.replaceAll("'", "\"");
var map = Map<String, dynamic>.from(json.decode(msg));
return TranscriptResponse(r.statusCode,
"${map.keys.elementAt(0).toUpperCase()}: ${map[map.keys.elementAt(0)][0]}");
}
} catch (_) {
return TranscriptResponse.fromJson(json.decode(r.body));
}
});