PageSourceSearch

https://www.museudalinguaportuguesa.org.br/wp-content/plugins/univ…/uvs.audio-input-handler.js?ver=1790925512

js museudalinguaportuguesa.org.br collected 2026-10-02 07:19:26 UTC 3,254 bytes, 95 lines download raw bytes

1// *****************************************************************************************************
2// *******              speak2web UNIVERSAL VOICE SEARCH                                     ***********
3// *******               Get your subscription at                                            ***********
4// *******                    https://speak2web.com/plugin#plans                             ***********
5// *******               Need support? https://speak2web.com/support                         ***********
6// *******               Licensed GPLv2+                                                     ***********
7//******************************************************************************************************
8
9window.AudioContext = window.AudioContext || window.webkitAudioContext;
10
11var uvsAudioContext = null;
12var uvsAudioInput = null,
13    uvsRealAudioInput = null,
14    uvsInputPoint = null,
15    uvsAudioRecorder = null;
16var uvsRecIndex = 0;
17var initCB = null;
18let uvsStream = null;
19
20/**
21 * Function to initialize capture audio resources
22 * 
23 * @param { cb: function } A callback function
24 */
25function uvsInitAudio(cb) {
26    initCB = cb;
27
28    // Check when last service log was updated
29    try {
30        let uvsLastUpdatedAtTimestamp = uvsServiceLogs.updatedAt || null;
31
32        if (uvsLastUpdatedAtTimestamp !== null) {
33            uvsLastUpdatedAtTimestamp = Number(uvsLastUpdatedAtTimestamp);
34            let currentUtcTimestamp = Math.round(new Date().getTime() / 1000);
35
36            // Add 24 hours to last updated timestamp
37            uvsLastUpdatedAtTimestamp = uvsLastUpdatedAtTimestamp + (24 * 3600);
38
39            // Check if last service call log update was older than 24 hours
40            if (currentUtcTimestamp >= uvsLastUpdatedAtTimestamp) {
41                // Log service call count
42                uvsLogServiceCall(1);
43            }
44        }
45    } catch (err) {
46        // do nothing
47    }
48
49    uvsAudioContext = new AudioContext();
50
51    navigator.mediaDevices.getUserMedia({ "audio": !0 })
52        .then(uvsGotStream)
53        .catch(function (e) {
54            // Play 'micConnect' playback
55            uvsAudioPlayer.configure(uvsAlternativeResponse['micConnect']);
56            uvsAudioPlayer.play();
57            console.log("VF: We caught an error while gaining access to audio input due to: ", e.message);
58        }
59        );
60}
61
62/**
63 * A callback function to obtain audio stream
64 * 
65 * @param { stream: MediaStream } An audio track 
66 */
67function uvsGotStream(stream) {
68    uvsInputPoint = uvsAudioContext.createGain();
69    uvsStream = stream;
70
71    // Create an AudioNode from the stream.
72    uvsRealAudioInput = uvsAudioContext.createMediaStreamSource(stream);
73    uvsAudioInput = uvsRealAudioInput;
74    uvsAudioInput.connect(uvsInputPoint);
75
76    uvsAudioRecorder = new Recorder(uvsInputPoint);
77    initCB(uvsAudioRecorder);
78}
79
80/**
81 * Function to stop accessing audio resource
82 *
83 */
84function uvsStopAudio() {
85    try {
86        uvsStream.getTracks().forEach(function (track) {
87            track.stop();
88        });
89
90        uvsAudioContext.close();
91        uvsAudioContext = null;
92    } catch (err) {
93        console.log('UVS Exception: Unable to release audio resource due to: ' + err.message);
94    }
95}

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.