Michael Natanael commited on
Commit
8da3a98
·
1 Parent(s): aae98e8

Pengguna mengunggah file audio non-lirik atau rusak. Muncul pesan error bahwa file yang diunggah

Browse files
Files changed (2) hide show
  1. app.py +1 -1
  2. templates/index.html +23 -1
app.py CHANGED
@@ -134,7 +134,7 @@ 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")
 
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")
templates/index.html CHANGED
@@ -126,8 +126,30 @@
126
  });
127
 
128
  document.getElementById("fileInput").addEventListener("change", function (event) {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
129
  if (event.target.files.length > 0) {
130
- let file = event.target.files[0];
131
  let fileURL = URL.createObjectURL(file);
132
  updateAudioPlayer(fileURL);
133
  }
 
126
  });
127
 
128
  document.getElementById("fileInput").addEventListener("change", function (event) {
129
+ const file = event.target.files[0];
130
+ const validTypes = ["audio/mpeg"];
131
+
132
+ // 1. Check if file exists
133
+ if (!file) {
134
+ alert("Please select a file first");
135
+ return;
136
+ }
137
+
138
+ // 2. Validate file type
139
+ if (!validTypes.includes(file.type)) {
140
+ alert("Invalid file type. Please upload MP3 file");
141
+ return;
142
+ }
143
+
144
+ // 3. Validate file size (max 10MB)
145
+ const maxSize = 10 * 1024 * 1024; // 10MB
146
+ if (file.size > maxSize) {
147
+ alert("File too large. Maximum size is 10MB");
148
+ return;
149
+ }
150
+
151
+ // 4. Create audio player
152
  if (event.target.files.length > 0) {
 
153
  let fileURL = URL.createObjectURL(file);
154
  updateAudioPlayer(fileURL);
155
  }