import "package:http/http.dart" as http;
class WhisperService {
final String urlToWhisper;
final String whisperModelVersion;
final String whisperApiKey;
WhisperService(
{required this.urlToWhisper,
required this.whisperModelVersion,
required this.whisperApiKey});
Future<String> startPrediction(urlToAudio) async {
String result;
var url = Uri.https(urlToWhisper, whisperModelVersion);
var response = await http.post(url, body: {
'version': whisperModelVersion,
'input': {
'audio': urlToAudio,
"model": "large-v3",
"translate": false,
"temperature": 0,
"transcription": "plain text",
"suppress_tokens": "-1",
"logprob_threshold": -1,
"no_speech_threshold": 0.6,
"condition_on_previous_text": true,
"compression_ratio_threshold": 2.4,
"temperature_increment_on_fallback": 0.2
}
}, headers: {
'Authorization': whisperApiKey
});
result = response.toString();
print(response.request);
print(response.body);
print(response.headers);
return result;
}
Future<String> getPrediction(predictionUrl) async {
String result;
var url = Uri.https(predictionUrl);
var response =
await http.get(url, headers: {'Authorization': whisperApiKey});
result = response.toString();
return result;
}
}