Deploying the model

After successfully adding a basic play and stop functionality to the application, let's now access the hosted model to generate, fetch, and play a new audio file every time. The following steps discuss in detail how we can access the model inside the application:

  1. First of all, we define the fetchResponse() method to generate and fetch new audio files:
void fetchResponse() async {   final response =     await http.get('http://35.225.134.65:8000/generate');   if (response.statusCode == 200) {     var v = json.decode(response.body);     fileName = v["result"] ;   } else {     throw Exception('Failed to load');   } }

We begin by fetching the response from the API using http.get() and passing in the URL where the model is hosted. The response from ...

Get Mobile Deep Learning with TensorFlow Lite, ML Kit and Flutter now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.