File size: 1,275 Bytes
3334ac8
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
$(document).ready(function () {
  let recording = false;

  $("#startBtn").click(function () {
    const youtubeUrl = $("#urlInput").val().trim();
    if (youtubeUrl === "") {
      showMessage("Please enter a valid YouTube Livestream URL.", "danger");
      return;
    }

    // Call the start_process route in Flask
    $.ajax({
      type: "POST",
      url: "/start_process",
      data: { url: youtubeUrl },
      success: function (data) {
        showMessage(data.message, "success");
        recording = true;
      },
      error: function (xhr, status, error) {
        showMessage("Error: " + xhr.responseText, "danger");
      },
    });
  });

  $("#stopBtn").click(function () {
    showMessage("Stopping transcription. This may take upto 30 sec.", "success");
    // Call the stop_process route in Flask
    $.ajax({
      type: "POST",
      url: "/stop_process",
      success: function (data) {
        showMessage(data.message, "success");
        recording = false;
      },
      error: function (xhr, status, error) {
        showMessage("Error: " + xhr.responseText, "danger");
      },
    });
  });

  function showMessage(message, type) {
    $("#message").html(
      `<div class="alert alert-${type}" role="alert">${message}</div>`
    );
  }
});