transcribeFromFile method

  1. @override
Future<String> transcribeFromFile(
  1. File file
)
override

This method should not add strings to the transcribed stream.

Implementation

@override
Future<String> transcribeFromFile(File file) async {
  var url = 'https://api.openai.com/v1/audio/transcriptions';
  var form = FormData.fromMap({
    'file': await MultipartFile.fromFile(file.path),
    'model': model.toString(),
    if (language != null) 'language': language,
    if (prompt != null) 'prompt': prompt,
    if (temperature != null) 'temperature': temperature,
  });
  var response = await _dio.post(
    url,
    data: form,
  );
  Map<String, dynamic> map = response.data;
  String text = map['text'];
  return text;
}