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 O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.