scripts.js

The following is the scripts.js file. Much of the Universal Translator's dynamic behaviors are implemented in JavaScript. scripts.js is interacting with the endpoints and stitching together the overall user experience of the application:

"use strict";const serverUrl = "http://127.0.0.1:8000";...class HttpError extends Error {    constructor(response) {        super(`${response.status} for ${response.url}`);        this.name = "HttpError";        this.response = response;    }}

This snippet defines the serverUrl as the address of chalice local. It also defines the HttpError to handle the exceptions that might occur during the HTTP requests:

let audioRecorder;let recordedAudio;const maxAudioLength = 30000;let audioFile = {};const mediaConstraints = { audio: ...

Get Hands-On Artificial Intelligence on Amazon Web Services 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.