Michael Natanael commited on
Commit
687e763
·
1 Parent(s): 1a8fd8f

change faster_whisper to whisper-large-v3 groqcloud

Browse files
app.py CHANGED
@@ -18,6 +18,7 @@ from flask_sqlalchemy import SQLAlchemy
18
  from flask_login import UserMixin
19
  from werkzeug.security import generate_password_hash, check_password_hash
20
  from faster_whisper import WhisperModel
 
21
  import tempfile
22
  import os
23
  import datetime
@@ -132,6 +133,9 @@ def download_checkpoint_if_needed(url, save_path):
132
  print(show_schema_info())
133
  download_checkpoint_if_needed(CHECKPOINT_URL, CHECKPOINT_PATH)
134
 
 
 
 
135
  # Load tokenizer
136
  tokenizer = BertTokenizer.from_pretrained("indolem/indobert-base-uncased")
137
 
@@ -230,7 +234,17 @@ def transcribe():
230
  temp_audio_path = temp_audio.name
231
 
232
  # Step 1: Transcribe
233
- transcribed_text = faster_whisper(temp_audio_path).strip()
 
 
 
 
 
 
 
 
 
 
234
  os.remove(temp_audio_path)
235
 
236
  # Step 2: BERT Prediction
 
18
  from flask_login import UserMixin
19
  from werkzeug.security import generate_password_hash, check_password_hash
20
  from faster_whisper import WhisperModel
21
+ from groq import Groq
22
  import tempfile
23
  import os
24
  import datetime
 
133
  print(show_schema_info())
134
  download_checkpoint_if_needed(CHECKPOINT_URL, CHECKPOINT_PATH)
135
 
136
+ # Load groq
137
+ client = Groq(api_key="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")
138
+
139
  # Load tokenizer
140
  tokenizer = BertTokenizer.from_pretrained("indolem/indobert-base-uncased")
141
 
 
234
  temp_audio_path = temp_audio.name
235
 
236
  # Step 1: Transcribe
237
+ # transcribed_text = faster_whisper(temp_audio_path).strip()
238
+ with open(temp_audio_path, "rb") as file:
239
+ transcription = client.audio.transcriptions.create(
240
+ file=(temp_audio_path, file.read()),
241
+ model="whisper-large-v3",
242
+ prompt="Transkripsikan hanya bagian lirik lagu saja",
243
+ language="id",
244
+ response_format="verbose_json",
245
+ temperature=0,
246
+ )
247
+ transcribed_text = transcription.text.strip()
248
  os.remove(temp_audio_path)
249
 
250
  # Step 2: BERT Prediction
static/img/black-song.svg ADDED
static/img/white-song.svg ADDED
templates/base.html CHANGED
@@ -8,6 +8,8 @@
8
  <script src="https://cdn.jsdelivr.net/npm/@tailwindcss/browser@4"></script>
9
  <link href="https://cdn.jsdelivr.net/npm/flowbite@3.1.2/dist/flowbite.min.css" rel="stylesheet" />
10
  <link rel="stylesheet" href="{{ url_for('static', filename='css/main.css') }}">
 
 
11
  {% block head %}{% endblock %}
12
  </head>
13
 
 
8
  <script src="https://cdn.jsdelivr.net/npm/@tailwindcss/browser@4"></script>
9
  <link href="https://cdn.jsdelivr.net/npm/flowbite@3.1.2/dist/flowbite.min.css" rel="stylesheet" />
10
  <link rel="stylesheet" href="{{ url_for('static', filename='css/main.css') }}">
11
+ <link rel="icon" href="{{ url_for('static', filename='img/black-song.svg') }}" media="(prefers-color-scheme: light)">
12
+ <link rel="icon" href="{{ url_for('static', filename='img/white-song.svg') }}" media="(prefers-color-scheme: dark)">
13
  {% block head %}{% endblock %}
14
  </head>
15
 
templates/login.html CHANGED
@@ -35,7 +35,7 @@
35
  {% endif %}
36
  {% endwith %}
37
  <div class="flex flex-col items-center justify-center px-6 py-8 mx-auto md:h-screen lg:py-0">
38
- <a href="/" class="flex flex-col gap-3 items-center mb-6 text-2xl font-semibold text-gray-900">
39
  <div class="flex">
40
  <img src="/static/img/Logo PNJ.png" class="h-8" alt="Politeknik Negeri Jakarta">
41
  <img src="/static/img/BLU SPEED LOGO.png" class="h-8" alt="Politeknik Negeri Jakarta">
@@ -94,8 +94,8 @@
94
  <label for="remember" class="text-gray-500">Remember me</label>
95
  </div>
96
  </div>
97
- <a href="#" class="text-sm font-medium text-primary-600 hover:underline">Forgot
98
- password?</a>
99
  </div>
100
  <div class="flex gap-3">
101
  <button type="submit"
 
35
  {% endif %}
36
  {% endwith %}
37
  <div class="flex flex-col items-center justify-center px-6 py-8 mx-auto md:h-screen lg:py-0">
38
+ <a href="#" class="flex flex-col gap-3 items-center mb-6 text-2xl font-semibold text-gray-900">
39
  <div class="flex">
40
  <img src="/static/img/Logo PNJ.png" class="h-8" alt="Politeknik Negeri Jakarta">
41
  <img src="/static/img/BLU SPEED LOGO.png" class="h-8" alt="Politeknik Negeri Jakarta">
 
94
  <label for="remember" class="text-gray-500">Remember me</label>
95
  </div>
96
  </div>
97
+ <!-- <a href="#" class="text-sm font-medium text-primary-600 hover:underline">Forgot
98
+ password?</a> -->
99
  </div>
100
  <div class="flex gap-3">
101
  <button type="submit"
templates/navbar.html CHANGED
@@ -55,7 +55,34 @@
55
  </a>
56
  </li>
57
  {% else %}
58
- <li>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
59
  <a href="/login"
60
  class="text-blue-700 hover:text-white border border-blue-700 hover:bg-blue-800 focus:ring-4 focus:outline-none focus:ring-blue-300 font-medium rounded-lg text-sm px-4 py-2 text-center me-2">Login</a>
61
  <a href="/register"
 
55
  </a>
56
  </li>
57
  {% else %}
58
+ <li class="flex items-center">
59
+ <button class="me-2" data-popover-target="popover-description" data-popover-placement="bottom-end"
60
+ type="button"><svg class="w-7 h-7 ms-2 text-gray-400 hover:text-gray-500" aria-hidden="true"
61
+ fill="currentColor" viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg">
62
+ <path fill-rule="evenodd"
63
+ d="M18 10a8 8 0 11-16 0 8 8 0 0116 0zm-8-3a1 1 0 00-.867.5 1 1 0 11-1.731-1A3 3 0 0113 8a3.001 3.001 0 01-2 2.83V11a1 1 0 11-2 0v-1a1 1 0 011-1 1 1 0 100-2zm0 8a1 1 0 100-2 1 1 0 000 2z"
64
+ clip-rule="evenodd"></path>
65
+ </svg><span class="sr-only">Show information</span></button>
66
+ <div data-popover id="popover-description" role="tooltip"
67
+ class="absolute z-10 invisible inline-block text-sm text-gray-500 transition-opacity duration-300 bg-white border border-gray-200 rounded-lg shadow-xs opacity-0 w-90">
68
+ <div class="p-3 space-y-2">
69
+ <h3 class="font-semibold text-gray-900">Main Features:</h3>
70
+ <ul class="max-w-md space-y-1 list-disc list-inside">
71
+ <li>Automatic Speech-to-Text Conversion</li>
72
+ <li>Manual Lyrics Input (in text format)</li>
73
+ <li>Lyrics Classification Based on Listener's Age</li>
74
+ <li>Probability Prediction for Each Age Category</li>
75
+ <li>Prediction History (available for logged-in users)</li>
76
+ </ul>
77
+ <a href="/login"
78
+ class="flex items-center font-medium text-blue-600 hover:text-blue-700 hover:underline">Login to save your prediction history <svg class="w-2 h-2 ms-1.5 rtl:rotate-180" aria-hidden="true"
79
+ xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 6 10">
80
+ <path stroke="currentColor" stroke-linecap="round" stroke-linejoin="round"
81
+ stroke-width="2" d="m1 9 4-4-4-4" />
82
+ </svg></a>
83
+ </div>
84
+ <div data-popper-arrow></div>
85
+ </div>
86
  <a href="/login"
87
  class="text-blue-700 hover:text-white border border-blue-700 hover:bg-blue-800 focus:ring-4 focus:outline-none focus:ring-blue-300 font-medium rounded-lg text-sm px-4 py-2 text-center me-2">Login</a>
88
  <a href="/register"
templates/register.html CHANGED
@@ -7,7 +7,7 @@
7
  {% block body %}
8
  <section class="bg-white">
9
  <div class="flex flex-col items-center justify-center px-6 py-8 mx-auto md:h-screen lg:py-0">
10
- <a href="/" class="flex flex-col gap-3 items-center mb-6 text-2xl font-semibold text-gray-900">
11
  <div class="flex">
12
  <img src="/static/img/Logo PNJ.png" class="h-8" alt="Politeknik Negeri Jakarta">
13
  <img src="/static/img/BLU SPEED LOGO.png" class="h-8" alt="Politeknik Negeri Jakarta">
 
7
  {% block body %}
8
  <section class="bg-white">
9
  <div class="flex flex-col items-center justify-center px-6 py-8 mx-auto md:h-screen lg:py-0">
10
+ <a href="#" class="flex flex-col gap-3 items-center mb-6 text-2xl font-semibold text-gray-900">
11
  <div class="flex">
12
  <img src="/static/img/Logo PNJ.png" class="h-8" alt="Politeknik Negeri Jakarta">
13
  <img src="/static/img/BLU SPEED LOGO.png" class="h-8" alt="Politeknik Negeri Jakarta">