Spaces:
Running
Running
Update server.js
Browse files
server.js
CHANGED
|
@@ -13,8 +13,14 @@ app.use(express.static('public'));
|
|
| 13 |
async function fetchHFFile(path) {
|
| 14 |
const url = `https://huggingface.co/datasets/${REPO_ID}/resolve/main/${path}`;
|
| 15 |
console.log(`[Loading] ${path}...`);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 16 |
try {
|
| 17 |
-
const res = await fetch(url, { headers
|
| 18 |
if (!res.ok) {
|
| 19 |
console.error(`[Error] Failed to fetch ${path}: ${res.status} ${res.statusText}`);
|
| 20 |
return [];
|
|
@@ -35,8 +41,14 @@ async function fetchHFFile(path) {
|
|
| 35 |
// --- List Files Helper ---
|
| 36 |
async function listHFFiles(folder) {
|
| 37 |
const url = `https://huggingface.co/api/datasets/${REPO_ID}/tree/main/${folder}`;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 38 |
try {
|
| 39 |
-
const res = await fetch(url, { headers
|
| 40 |
if (!res.ok) {
|
| 41 |
console.error(`[Error] Failed to list files: ${res.status}`);
|
| 42 |
return [];
|
|
@@ -108,7 +120,7 @@ async function loadAndProcessData() {
|
|
| 108 |
if(!ttsGrouped[r.model]) ttsGrouped[r.model] = [];
|
| 109 |
const meta = langMap[r.lang_code] || { lang_code_key: r.lang_code };
|
| 110 |
r.iso = meta.lang_code_key;
|
| 111 |
-
r.Language = meta.name;
|
| 112 |
ttsGrouped[r.model].push(r);
|
| 113 |
});
|
| 114 |
|
|
|
|
| 13 |
async function fetchHFFile(path) {
|
| 14 |
const url = `https://huggingface.co/datasets/${REPO_ID}/resolve/main/${path}`;
|
| 15 |
console.log(`[Loading] ${path}...`);
|
| 16 |
+
|
| 17 |
+
const headers = {};
|
| 18 |
+
if (HF_TOKEN) {
|
| 19 |
+
headers["Authorization"] = `Bearer ${HF_TOKEN}`;
|
| 20 |
+
}
|
| 21 |
+
|
| 22 |
try {
|
| 23 |
+
const res = await fetch(url, { headers });
|
| 24 |
if (!res.ok) {
|
| 25 |
console.error(`[Error] Failed to fetch ${path}: ${res.status} ${res.statusText}`);
|
| 26 |
return [];
|
|
|
|
| 41 |
// --- List Files Helper ---
|
| 42 |
async function listHFFiles(folder) {
|
| 43 |
const url = `https://huggingface.co/api/datasets/${REPO_ID}/tree/main/${folder}`;
|
| 44 |
+
|
| 45 |
+
const headers = {};
|
| 46 |
+
if (HF_TOKEN) {
|
| 47 |
+
headers["Authorization"] = `Bearer ${HF_TOKEN}`;
|
| 48 |
+
}
|
| 49 |
+
|
| 50 |
try {
|
| 51 |
+
const res = await fetch(url, { headers });
|
| 52 |
if (!res.ok) {
|
| 53 |
console.error(`[Error] Failed to list files: ${res.status}`);
|
| 54 |
return [];
|
|
|
|
| 120 |
if(!ttsGrouped[r.model]) ttsGrouped[r.model] = [];
|
| 121 |
const meta = langMap[r.lang_code] || { lang_code_key: r.lang_code };
|
| 122 |
r.iso = meta.lang_code_key;
|
| 123 |
+
r.Language = meta.name;
|
| 124 |
ttsGrouped[r.model].push(r);
|
| 125 |
});
|
| 126 |
|