audioUrl method
audioUrl is a class for making HTTP requests to the SOZLUK API using the word parameter and print word in the console.
Implementation
Future<String> audioUrl(String word) async {
try {
final res = await _get(_yazimUri(word));
var body = res.body;
var decoded = jsonDecode(body);
var json = decoded[0];
var sozlukanlam = json["seskod"];
debugPrint('Voice Code: $sozlukanlam');
var anlamSesUrl = 'https://sozluk.gov.tr/ses/' + sozlukanlam + '.wav';
return anlamSesUrl;
} on NoSuchMethodError {
throw StateError(
"ERR-003 - Couldn't find any audio files with this word.");
} catch (e) {
throw Exception("Failed to fetch audio url for '$word': $e");
}
}