downloadModel function

Future<String> downloadModel({
  1. required WhisperModel model,
  2. required String destinationPath,
})

Download model to destinationPath

Implementation

Future<String> downloadModel({
  required WhisperModel model,
  required String destinationPath,
}) async {
  logger.info('Download model ${model.modelName}');
  final httpClient = HttpClient();

  final request = await httpClient.getUrl(
    model.modelUri,
  );

  final response = await request.close();

  final bytes = await consolidateHttpClientResponseBytes(response);

  final File file = File(
    model.getPath(destinationPath),
  );
  await file.writeAsBytes(bytes);

  return file.path;
}