use of com.amplifyframework.predictions.aws.NetworkPolicy in project amplify-android by aws-amplify.
the class SpeechGeneratorConfiguration method fromJson.
/**
* Construct an instance of {@link SpeechGeneratorConfiguration} from
* plugin configuration JSON object.
* @param configurationJson the plugin configuration
* @return the configuration for speech generation
* @throws JSONException if convert configuration is malformed
*/
@Nullable
public static SpeechGeneratorConfiguration fromJson(@NonNull JSONObject configurationJson) throws JSONException {
if (!configurationJson.has(CONFIG_NAME)) {
return null;
}
JSONObject speechGeneratorJson = configurationJson.getJSONObject(CONFIG_NAME);
String voice = speechGeneratorJson.getString("voice");
String language = speechGeneratorJson.getString("language");
String networkPolicyString = speechGeneratorJson.getString("defaultNetworkPolicy");
final NetworkPolicy networkPolicy = NetworkPolicy.fromKey(networkPolicyString);
return new SpeechGeneratorConfiguration(voice, language, networkPolicy);
}
Aggregations