Michael Natanael commited on
Commit
6b6d018
·
1 Parent(s): 2fc0c7d

Improve user interface

Browse files
static/css/tailwind.css CHANGED
@@ -529,35 +529,35 @@ video {
529
  @media (min-width: 640px) {
530
 
531
  .container {
532
- max-width: 640px;
533
  }
534
  }
535
 
536
  @media (min-width: 768px) {
537
 
538
  .container {
539
- max-width: 768px;
540
  }
541
  }
542
 
543
  @media (min-width: 1024px) {
544
 
545
  .container {
546
- max-width: 1024px;
547
  }
548
  }
549
 
550
  @media (min-width: 1280px) {
551
 
552
  .container {
553
- max-width: 1280px;
554
  }
555
  }
556
 
557
  @media (min-width: 1536px) {
558
 
559
  .container {
560
- max-width: 1536px;
561
  }
562
  }
563
 
@@ -716,7 +716,7 @@ video {
716
  }
717
 
718
  .min-h-screen {
719
- min-height: 100vh;
720
  }
721
 
722
  .w-4 {
@@ -1112,10 +1112,10 @@ audio::-webkit-media-controls-panel {
1112
  }
1113
 
1114
  .container {
1115
- width: 41rem
1116
- /* 656px */
1117
- ;
1118
  max-width: 95vw;
 
 
1119
  }
1120
 
1121
  .hover\:bg-blue-800:hover {
 
529
  @media (min-width: 640px) {
530
 
531
  .container {
532
+ max-width: 540px;
533
  }
534
  }
535
 
536
  @media (min-width: 768px) {
537
 
538
  .container {
539
+ max-width: 640px;
540
  }
541
  }
542
 
543
  @media (min-width: 1024px) {
544
 
545
  .container {
546
+ max-width: 768px;
547
  }
548
  }
549
 
550
  @media (min-width: 1280px) {
551
 
552
  .container {
553
+ max-width: 1024px;
554
  }
555
  }
556
 
557
  @media (min-width: 1536px) {
558
 
559
  .container {
560
+ max-width: 1280px;
561
  }
562
  }
563
 
 
716
  }
717
 
718
  .min-h-screen {
719
+ min-height: 90vh;
720
  }
721
 
722
  .w-4 {
 
1112
  }
1113
 
1114
  .container {
1115
+ width: 70rem;
 
 
1116
  max-width: 95vw;
1117
+ margin-top: 3rem;
1118
+ margin-bottom: 3rem;
1119
  }
1120
 
1121
  .hover\:bg-blue-800:hover {
templates/index.html CHANGED
@@ -1,84 +1,88 @@
1
  {% extends 'base.html' %}
2
 
3
  {% block head %}
4
- <title>Whisper Web - Index</title>
5
  {% endblock %}
6
 
7
  {% block body %}
8
- <div id="root">
9
- <div class="flex justify-center items-center min-h-screen">
10
- <div class="container flex flex-col justify-center items-center">
11
- <h1 class="text-5xl font-extrabold tracking-tight text-slate-900 sm:text-7xl text-center">Whisper Web</h1>
12
- <h2 class="mt-3 mb-5 px-4 text-center text-1xl font-semibold tracking-tight text-slate-900 sm:text-2xl">
13
- Speech-to-Text</h2>
14
- <div
15
- class="flex flex-col justify-center items-center rounded-lg bg-white shadow-xl shadow-black/5 ring-1 ring-slate-700/10">
16
- <div class="flex flex-row space-x-2 py-2 w-full px-2">
17
- <button id="uploadButton"
18
- class="flex items-center justify-center rounded-lg p-2 bg-blue text-slate-500 hover:text-indigo-600 hover:bg-indigo-50 transition-all duration-200">
19
- <div class="w-7 h-7"><svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24"
20
- stroke-width="1.5" stroke="currentColor">
21
- <path stroke-linecap="round" stroke-linejoin="round"
22
- d="M3.75 9.776c.112-.017.227-.026.344-.026h15.812c.117 0 .232.009.344.026m-16.5 0a2.25 2.25 0 00-1.883 2.542l.857 6a2.25 2.25 0 002.227 1.932H19.05a2.25 2.25 0 002.227-1.932l.857-6a2.25 2.25 0 00-1.883-2.542m-16.5 0V6A2.25 2.25 0 016 3.75h3.879a1.5 1.5 0 011.06.44l2.122 2.12a1.5 1.5 0 001.06.44H18A2.25 2.25 0 0120.25 9v.776">
23
- </path>
24
- </svg></div>
25
- <div class="ml-2 break-text text-center text-md w-30">From file</div>
26
- </button>
27
- <div class="w-[1px] bg-slate-200"></div>
28
- <button id="recordButton"
29
- class="flex items-center justify-center rounded-lg p-2 bg-blue text-slate-500 hover:text-indigo-600 hover:bg-indigo-50 transition-all duration-200">
30
- <div class="w-7 h-7"><svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24"
31
- stroke-width="1.5" stroke="currentColor">
32
- <path stroke-linecap="round" stroke-linejoin="round"
33
- d="M12 18.75a6 6 0 006-6v-1.5m-6 7.5a6 6 0 01-6-6v-1.5m6 7.5v3.75m-3.75 0h7.5M12 15.75a3 3 0 01-3-3V4.5a3 3 0 116 0v8.25a3 3 0 01-3 3z">
34
- </path>
35
- </svg></div>
36
- <div id="recordText" class="ml-2 break-text text-center text-md w-30">Record</div>
37
- </button>
38
- </div>
39
- <div class="w-full bg-gray-200 rounded-full h-1 dark:bg-gray-700">
40
- <div class="bg-blue-600 h-1 rounded-full transition-all duration-100" style="width: 0%;"></div>
41
- </div>
42
  </div>
43
-
44
- <!-- Hidden playback and transcribe sections -->
45
- <div id="playback" class="flex relative z-10 p-4 w-full hidden">
46
- <audio id="audioPlayer" controls
47
- class="w-full h-14 rounded-lg bg-white shadow-xl shadow-black/5 ring-1 ring-slate-700/10">
48
- <source id="audioSource" type="audio/mpeg" src="">
49
- </audio>
50
- </div>
51
- <div id="transcribe" class="relative w-full flex justify-center items-center hidden">
52
- <form action="/transcribe" method="POST" enctype="multipart/form-data">
53
- <input type="file" name="file" id="fileInput" accept=".mp3" class="hidden">
54
- <button type="submit"
55
- class="text-white bg-blue-700 hover:bg-blue-800 focus:ring-4 focus:ring-blue-300 font-medium rounded-lg text-sm px-5 py-2.5 text-center mr-2 dark:bg-blue-600 dark:hover:bg-blue-700 dark:focus:ring-blue-800 inline-flex items-center">
56
- Transcribe Audio
57
- </button>
58
- </form>
59
  </div>
 
60
 
61
- <div class="w-full flex flex-col my-2 p-4 max-h-[20rem] overflow-y-auto"></div>
62
-
63
- <!-- Text Input for Manual Lyrics Prediction -->
64
- <div class="w-full mt-8" id="input-text">
65
- <form action="/predict-text" method="POST" class="flex flex-col space-y-4">
66
- <label for="lyricsInput" class="text-lg font-semibold text-slate-700">Or paste your lyric
67
- here:</label>
68
- <textarea name="lyrics" id="lyricsInput" rows="5"
69
- class="w-full rounded-lg border border-gray-300 p-3 text-sm focus:outline-none focus:ring-2 focus:ring-blue-500"
70
- placeholder="Type or paste Indonesian lyrics..."></textarea>
71
- <br>
72
- <button type="submit"
73
- class="text-white bg-blue-700 hover:bg-blue-800 focus:ring-4 focus:ring-blue-300 font-medium rounded-lg text-sm px-5 py-2.5 text-center mr-2 dark:bg-blue-600 dark:hover:bg-blue-700 dark:focus:ring-blue-800">
74
- Predict Age Group
75
- </button>
76
- </form>
77
- </div>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
78
  </div>
79
- <div class="absolute bottom-4">By Michael Natanael</div>
80
  </div>
81
- </div>
 
 
 
82
  {% endblock %}
83
 
84
  {% block script %}
@@ -110,6 +114,24 @@
110
  }
111
  });
112
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
113
  async function startRecording() {
114
  const stream = await navigator.mediaDevices.getUserMedia({ audio: true });
115
  mediaRecorder = new MediaRecorder(stream);
@@ -165,5 +187,11 @@
165
  document.getElementById("transcribe").classList.remove("hidden");
166
  document.getElementById("input-text").classList.add("hidden");
167
  }
 
 
 
 
 
 
168
  </script>
169
  {% endblock %}
 
1
  {% extends 'base.html' %}
2
 
3
  {% block head %}
4
+ <title>Indonesian Lyrics Classification By Age Group - Index</title>
5
  {% endblock %}
6
 
7
  {% block body %}
8
+ <main class="flex flex-row justify-center items-center min-h-screen">
9
+ <div class="container flex flex-col justify-center items-center">
10
+ <h1 class="mb-5 text-5xl font-extrabold tracking-tight text-slate-900 sm:text-7xl text-center">Indonesian Lyrics
11
+ Classification By Age Group</h1>
12
+ <h2 class="mt-4 mb-2 px-4 text-center text-1xl font-semibold tracking-tight text-slate-900 sm:text-2xl">
13
+ Upload or Record Your Lyrics:</h2>
14
+ <div
15
+ class="mb-3 flex flex-col justify-center items-center rounded-lg bg-white shadow-xl shadow-black/5 ring-1 ring-slate-700/10">
16
+ <div class="flex flex-row space-x-2 py-2 w-full px-2">
17
+ <button id="uploadButton"
18
+ class="flex items-center justify-center rounded-lg p-2 bg-blue text-slate-500 hover:text-indigo-600 hover:bg-indigo-50 transition-all duration-200">
19
+ <div class="w-7 h-7"><svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24"
20
+ stroke-width="1.5" stroke="currentColor">
21
+ <path stroke-linecap="round" stroke-linejoin="round"
22
+ d="M3.75 9.776c.112-.017.227-.026.344-.026h15.812c.117 0 .232.009.344.026m-16.5 0a2.25 2.25 0 00-1.883 2.542l.857 6a2.25 2.25 0 002.227 1.932H19.05a2.25 2.25 0 002.227-1.932l.857-6a2.25 2.25 0 00-1.883-2.542m-16.5 0V6A2.25 2.25 0 016 3.75h3.879a1.5 1.5 0 011.06.44l2.122 2.12a1.5 1.5 0 001.06.44H18A2.25 2.25 0 0120.25 9v.776">
23
+ </path>
24
+ </svg></div>
25
+ <div class="ml-2 break-text text-center text-md w-30">From File</div>
26
+ </button>
27
+ <div class="w-[1px] bg-slate-200"></div>
28
+ <button id="recordButton"
29
+ class="flex items-center justify-center rounded-lg p-2 bg-blue text-slate-500 hover:text-indigo-600 hover:bg-indigo-50 transition-all duration-200">
30
+ <div class="w-7 h-7"><svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24"
31
+ stroke-width="1.5" stroke="currentColor">
32
+ <path stroke-linecap="round" stroke-linejoin="round"
33
+ d="M12 18.75a6 6 0 006-6v-1.5m-6 7.5a6 6 0 01-6-6v-1.5m6 7.5v3.75m-3.75 0h7.5M12 15.75a3 3 0 01-3-3V4.5a3 3 0 116 0v8.25a3 3 0 01-3 3z">
34
+ </path>
35
+ </svg></div>
36
+ <div id="recordText" class="ml-2 break-text text-center text-md w-30">Record</div>
37
+ </button>
 
 
 
 
38
  </div>
39
+ <div class="w-full bg-gray-200 rounded-full h-1 dark:bg-gray-700">
40
+ <div class="bg-blue-600 h-1 rounded-full transition-all duration-100" style="width: 0%;"></div>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
41
  </div>
42
+ </div>
43
 
44
+ <!-- Hidden playback and transcribe sections -->
45
+ <div id="playback" class="mb-3 flex relative z-10 p-4 w-full hidden">
46
+ <audio id="audioPlayer" controls
47
+ class="w-full h-14 rounded-lg bg-white shadow-xl shadow-black/5 ring-1 ring-slate-700/10">
48
+ <source id="audioSource" type="audio/mpeg" src="">
49
+ </audio>
50
+ </div>
51
+ <div id="transcribe" class="relative w-full flex justify-center items-center hidden">
52
+ <form action="/transcribe" method="POST" enctype="multipart/form-data">
53
+ <input type="file" name="file" id="fileInput" accept=".mp3" class="hidden">
54
+ <button type="button" onclick="showInputText()"
55
+ class="text-white bg-red-500 hover:bg-red-600 font-medium rounded-lg text-2xl px-5 py-2.5 text-center">
56
+ Cancel
57
+ </button>
58
+ <button type="submit"
59
+ class="text-white bg-blue-700 hover:bg-blue-800 font-medium rounded-lg text-2xl px-5 py-2.5 text-center">
60
+ Predict Age Group
61
+ </button>
62
+ </form>
63
+ </div>
64
+
65
+ <!-- Text Input for Manual Lyrics Prediction -->
66
+ <div class="mt-4 w-full mt-8" id="input-text">
67
+ <form action="/predict-text" method="POST" class="flex flex-col space-y-4">
68
+ <label for="lyricsInput"
69
+ class="mb-2 text-1xl font-semibold tracking-tight text-slate-900 sm:text-2xl">Or Input Your Lyrics
70
+ Here:</label>
71
+ <textarea name="lyrics" id="lyricsInput" rows="6" required
72
+ class="w-full rounded-lg border border-gray-300 px-2 py-2 text-2xl focus:outline-none focus:ring-2 focus:ring-blue-500"
73
+ placeholder="Type or paste Indonesian lyrics..."></textarea>
74
+ <br>
75
+ <button type="submit"
76
+ class="text-white bg-blue-700 hover:bg-blue-800 font-medium rounded-lg text-2xl px-5 py-2.5 text-center">
77
+ Predict Age Group
78
+ </button>
79
+ </form>
80
  </div>
 
81
  </div>
82
+ </main>
83
+ <footer class="flex flex-row justify-center items-center">
84
+ <div class="mb-5 text-gray-500">By Michael Natanael</div>
85
+ </footer>
86
  {% endblock %}
87
 
88
  {% block script %}
 
114
  }
115
  });
116
 
117
+ document.querySelectorAll('form').forEach(form => {
118
+ form.addEventListener('submit', function (e) {
119
+ const cancelBtn = this.querySelector('[type="button"]');
120
+ const submitBtn = this.querySelector('[type="submit"]');
121
+ cancelBtn.disabled = true;
122
+ submitBtn.disabled = true;
123
+ submitBtn.innerHTML = `
124
+ <svg aria-hidden="true" role="status" class="inline w-4 h-4 me-3 text-white animate-spin" viewBox="0 0 100 101" fill="none" xmlns="http://www.w3.org/2000/svg">
125
+ <path d="M100 50.5908C100 78.2051 77.6142 100.591 50 100.591C22.3858 100.591 0 78.2051 0 50.5908C0 22.9766 22.3858 0.59082 50 0.59082C77.6142 0.59082 100 22.9766 100 50.5908ZM9.08144 50.5908C9.08144 73.1895 27.4013 91.5094 50 91.5094C72.5987 91.5094 90.9186 73.1895 90.9186 50.5908C90.9186 27.9921 72.5987 9.67226 50 9.67226C27.4013 9.67226 9.08144 27.9921 9.08144 50.5908Z"
126
+ fill="#E5E7EB" />
127
+ <path d="M93.9676 39.0409C96.393 38.4038 97.8624 35.9116 97.0079 33.5539C95.2932 28.8227 92.871 24.3692 89.8167 20.348C85.8452 15.1192 80.8826 10.7238 75.2124 7.41289C69.5422 4.10194 63.2754 1.94025 56.7698 1.05124C51.7666 0.367541 46.6976 0.446843 41.7345 1.27873C39.2613 1.69328 37.813 4.19778 38.4501 6.62326C39.0873 9.04874 41.5694 10.4717 44.0505 10.1071C47.8511 9.54855 51.7191 9.52689 55.5402 10.0491C60.8642 10.7766 65.9928 12.5457 70.6331 15.2552C75.2735 17.9648 79.3347 21.5619 82.5849 25.841C84.9175 28.9121 86.7997 32.2913 88.1811 35.8758C89.083 38.2158 91.5421 39.6781 93.9676 39.0409Z"
128
+ fill="currentColor" />
129
+ </svg>
130
+ Loading...
131
+ `;
132
+ });
133
+ });
134
+
135
  async function startRecording() {
136
  const stream = await navigator.mediaDevices.getUserMedia({ audio: true });
137
  mediaRecorder = new MediaRecorder(stream);
 
187
  document.getElementById("transcribe").classList.remove("hidden");
188
  document.getElementById("input-text").classList.add("hidden");
189
  }
190
+
191
+ function showInputText() {
192
+ document.getElementById("playback").classList.add("hidden");
193
+ document.getElementById("transcribe").classList.add("hidden");
194
+ document.getElementById("input-text").classList.remove("hidden");
195
+ }
196
  </script>
197
  {% endblock %}
templates/transcribe.html CHANGED
@@ -1,32 +1,70 @@
1
  {% extends 'base.html' %}
2
 
3
  {% block head %}
4
- <title>Whisper Web - Transcription</title>
5
  {% endblock %}
6
 
7
  {% block body %}
8
- <div class="flex justify-center items-center min-h-screen">
9
- <div class="container text-center">
10
- <h1 class="text-4xl font-bold mb-6">Transcription Result</h1>
11
- <p class="text-xl mb-4">{{ task }}</p>
12
-
13
- <h2 class="text-2xl font-semibold text-blue-600 mt-4">Predicted Age Group:</h2>
14
- <p class="text-lg">{{ prediction }}</p>
15
-
16
- <div class="mt-4 text-left inline-block">
17
- <h3 class="text-md font-semibold">Class Probabilities:</h3>
18
- <ul class="mt-2">
19
- {% for label, prob in probabilities %}
20
- <li>{{ label }}: {{ prob }}</li>
21
- {% endfor %}
22
- </ul>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
23
  </div>
24
 
 
 
 
25
  {% if total_time %}
26
- <div class="mt-4 text-center text-sm text-gray-500">
27
  ⏱️ Total Processing Time: <strong>{{ total_time }}</strong>
28
  </div>
29
  {% endif %}
 
 
 
 
 
 
 
 
30
  </div>
31
- </div>
 
 
 
32
  {% endblock %}
 
1
  {% extends 'base.html' %}
2
 
3
  {% block head %}
4
+ <title>Indonesian Lyrics Classification By Age Group - Prediction</title>
5
  {% endblock %}
6
 
7
  {% block body %}
8
+ <main class="flex flex-row justify-center items-center min-h-screen">
9
+ <div class="container max-w-xl w-full bg-white rounded-2xl shadow-lg p-8 text-center space-y-6">
10
+
11
+ <!-- Lyrics -->
12
+ <div class="mb-5">
13
+ <h1 class="text-lg font-semibold text-gray-800 sm:text-xl">🎵 Lyrics</h1>
14
+ <p class="text-center px-2 py-2 text-1xl sm:text-lg">{{ task }}</p>
15
+ </div>
16
+
17
+ <hr class="my-12 h-0.5 border-t-0 bg-neutral-100 dark:bg-white/10" />
18
+
19
+ <!-- Predicted Age Group -->
20
+ <div class="mt-4 mb-5">
21
+ <h2 class="text-lg font-semibold text-gray-800">Predicted Age Group</h2>
22
+ <span class="text-center text-lg font-extrabold text-slate-900 sm:text-2xl">
23
+ {{ prediction }}
24
+ </span>
25
+ </div>
26
+
27
+ <hr class="my-12 h-0.5 border-t-0 bg-neutral-100 dark:bg-white/10" />
28
+
29
+ <!-- Class Probabilities -->
30
+ <div class="mt-4 mb-5 flex flex-col text-center items-center">
31
+ <h3 class="text-lg font-semibold text-gray-800 mb-2">📊 Class Probabilities</h3>
32
+ <div class="space-y-3">
33
+ <table>
34
+ {% for label, prob in probabilities %}
35
+ <tr class="{{ 'bg-green-500' if label == prediction else '' }}">
36
+ <td class="px-2 text-left">
37
+ <span class="capitalize text-gray-600 text-1xl sm:text-lg {{ 'font-medium' if label == prediction else '' }}">{{ label }}</span>
38
+ </td>
39
+ <td class="px-5"></td>
40
+ <td class="px-2 text-right">
41
+ <span class="text-gray-800 text-1xl sm:text-lg {{ 'font-medium' if label == prediction else '' }}">{{ prob }}</span>
42
+ </td>
43
+ </tr>
44
+ {% endfor %}
45
+ </table>
46
+ </div>
47
  </div>
48
 
49
+ <hr class="my-12 h-0.5 border-t-0 bg-neutral-100 dark:bg-white/10" />
50
+
51
+ <!-- Processing Time -->
52
  {% if total_time %}
53
+ <div class="mt-4 mb-5 text-gray-500">
54
  ⏱️ Total Processing Time: <strong>{{ total_time }}</strong>
55
  </div>
56
  {% endif %}
57
+
58
+ <!-- Action Button -->
59
+ <div class="w-full flex flex-col my-2 overflow-y-auto"></div>
60
+ <div class="mt-4">
61
+ <a href="/" class="bg-blue-700 hover:bg-blue-800 text-white font-medium py-2 px-4 rounded-lg text-2xl">
62
+ 🔁 Try Another Lyrics
63
+ </a>
64
+ </div>
65
  </div>
66
+ </main>
67
+ <footer class="flex flex-row justify-center items-center">
68
+ <div class="mb-5 text-gray-500">By Michael Natanael</div>
69
+ </footer>
70
  {% endblock %}