Spaces:
Running
Running
File size: 191,852 Bytes
d35ed81 1c430d1 0587958 d35ed81 cdac885 3a2a2e5 0587958 3a2a2e5 cdac885 d35ed81 0587958 d35ed81 0587958 d35ed81 0587958 d35ed81 0587958 d35ed81 0587958 d35ed81 0587958 d35ed81 0587958 d35ed81 0587958 3a2a2e5 0587958 d35ed81 0587958 9a8a812 cdac885 9a8a812 d35ed81 0587958 6bad670 0587958 6bad670 0587958 6bad670 0587958 d35ed81 6bad670 0587958 d35ed81 0587958 d2356ec 0587958 d35ed81 0587958 d35ed81 0587958 d2356ec d35ed81 d2356ec 0587958 d2356ec d35ed81 0587958 d35ed81 439049f d2356ec 0587958 d35ed81 d2356ec d35ed81 0587958 d35ed81 58cc9a8 d2356ec 58cc9a8 d35ed81 d2356ec 0587958 d2356ec d35ed81 0587958 d2356ec 0587958 d2356ec 0587958 d2356ec d35ed81 0587958 d2356ec d35ed81 0587958 d2356ec 0587958 d2356ec 0587958 d2356ec d35ed81 0587958 06d670f 77edcd1 06d670f 77edcd1 06d670f 63fd7b5 77edcd1 63fd7b5 77edcd1 63fd7b5 77edcd1 63fd7b5 77edcd1 63fd7b5 06d670f 77edcd1 06d670f 17f9926 06d670f 63fd7b5 77edcd1 17f9926 77edcd1 06d670f c09c6fe 3a2a2e5 d2356ec 0587958 3a2a2e5 d2356ec d35ed81 0587958 d2356ec 3a2a2e5 cdac885 d2356ec 3a2a2e5 d2356ec cdac885 3a2a2e5 d35ed81 cdac885 3a2a2e5 cdac885 0587958 d35ed81 0587958 d2356ec d35ed81 0587958 80c4199 3a2a2e5 0587958 d35ed81 d2356ec 0587958 d2356ec cdac885 d2356ec 0587958 d2356ec 0587958 3a2a2e5 0587958 d2356ec cdac885 d2356ec 0587958 d2356ec 0587958 d2356ec d35ed81 d2356ec d35ed81 d2356ec d35ed81 d2356ec 0587958 d35ed81 d2356ec 0587958 d2356ec d35ed81 d2356ec 0587958 d2356ec 0587958 d2356ec 0587958 d2356ec d35ed81 cdac885 d2356ec 0587958 d2356ec 0587958 d2356ec 0587958 d2356ec 0587958 d2356ec 0587958 d2356ec 0587958 d2356ec 0587958 d2356ec 0587958 d2356ec d35ed81 0587958 d2356ec 0587958 d2356ec 0587958 d2356ec 0587958 d35ed81 b1aa6a1 d35ed81 d2356ec 0587958 b1aa6a1 08a8ac3 aac8723 76d7048 aac8723 cdac885 aac8723 cdac885 08a8ac3 0587958 cdac885 0587958 d2356ec d35ed81 0587958 d35ed81 0587958 d2356ec 0587958 d2356ec 0587958 d2356ec 0587958 d2356ec d35ed81 0587958 d35ed81 0587958 d2356ec 0587958 d2356ec 0587958 cdac885 0587958 d2356ec 0587958 d2356ec 0587958 d2356ec 0587958 26317f7 d2356ec 0587958 d2356ec 3a2a2e5 cdac885 0587958 cdac885 d2356ec 0587958 ed26441 0587958 d2356ec d35ed81 58cc9a8 a063aac 58cc9a8 c71e540 d35ed81 cdac885 ed26441 9a8a812 1c430d1 077bd66 d948705 0587958 cdac885 d35ed81 0587958 d35ed81 0587958 9a8a812 1c430d1 0587958 cdac885 ed26441 6bad670 0587958 6bad670 d35ed81 0587958 d35ed81 0587958 d2356ec 0587958 06c91a9 aac8723 0587958 2c50831 66a3cea 2c50831 e4c1bcb 56e5321 d2356ec 0587958 d2356ec 0587958 ed26441 70ab5e2 ed26441 439049f 0587958 d35ed81 0587958 d35ed81 d2356ec 0587958 a6cc4b6 58cc9a8 799af78 58cc9a8 0587958 3a2a2e5 0587958 3a2a2e5 0587958 3a2a2e5 d35ed81 06d670f 5ed0832 06d670f 0587958 06d670f 0587958 a19ca6d 0587958 06d670f 0587958 3a2a2e5 0587958 d2356ec 0587958 d2356ec 0587958 d35ed81 aac8723 58cc9a8 799af78 58cc9a8 aac8723 a382702 aac8723 9619737 aac8723 2c50831 58cc9a8 799af78 58cc9a8 2c50831 66a3cea 2c50831 66a3cea 58cc9a8 799af78 58cc9a8 2c50831 66a3cea 3e35161 66a3cea 2c50831 66a3cea 2c50831 58cc9a8 799af78 58cc9a8 2c50831 aac8723 d2356ec 06c91a9 d2356ec aac8723 76d7048 d2356ec dcef6f0 d2356ec e4c1bcb 58cc9a8 799af78 58cc9a8 e4c1bcb 0587958 d2356ec 0587958 d35ed81 0587958 56e5321 0587958 56e5321 06c91a9 56e5321 66a3cea 56e5321 0587958 a3611db 58cc9a8 0587958 56e5321 0587958 d35ed81 0587958 2c50831 d35ed81 0587958 d35ed81 0587958 58cc9a8 0587958 58cc9a8 76d7048 58cc9a8 0587958 58cc9a8 0587958 dcef6f0 0587958 d35ed81 0587958 77deeb4 d35ed81 d2356ec 0587958 d35ed81 0587958 1c430d1 439049f 5f5d462 0587958 d2356ec 0587958 1c430d1 0587958 d2356ec 0587958 d35ed81 d2356ec 0587958 d2356ec 0587958 d2356ec 0587958 d2356ec 0587958 d2356ec 0587958 d2356ec 0587958 d2356ec c6bc456 d2356ec c6bc456 d2356ec ff50d21 d2356ec 026c735 d2356ec 0587958 d2356ec 0587958 06d670f 0587958 d2356ec 0587958 d2356ec 0587958 d2356ec c6bc456 0587958 3a2a2e5 d2356ec 3a2a2e5 56e5321 3a2a2e5 56e5321 49664c5 7e16fc0 49664c5 3a2a2e5 56e5321 3a2a2e5 439049f 5f5d462 439049f 5f5d462 439049f 5f5d462 439049f 5f5d462 439049f d2356ec b7f0f1d 5f5d462 b7f0f1d ed26441 32bf5d3 ed26441 5f5d462 4915664 8bbf5b5 bb4298d 8969803 5f5d462 b7f0f1d 5f5d462 8969803 b7f0f1d 5f5d462 b7f0f1d f1bb4a2 b7f0f1d 5f5d462 d2356ec b7f0f1d 5f5d462 0587958 d2356ec 0587958 d2356ec 0587958 dcef6f0 0587958 58cc9a8 0587958 58cc9a8 76d7048 58cc9a8 76d7048 58cc9a8 e0cb8bc 58cc9a8 e0cb8bc 58cc9a8 e0cb8bc 58cc9a8 e0cb8bc 58cc9a8 e0cb8bc 58cc9a8 0587958 d2356ec 0587958 dcef6f0 0587958 dcef6f0 0587958 d2356ec 0587958 d2356ec 0587958 aac8723 e0cb8bc aac8723 ad06f60 aac8723 e0cb8bc aac8723 e0cb8bc aac8723 e0cb8bc 439049f aac8723 5f5d462 aac8723 b7f0f1d 5f5d462 aac8723 9619737 c6bc456 9619737 e4c1bcb 0935499 e4c1bcb e0cb8bc e4c1bcb feede45 e4c1bcb feede45 439049f feede45 e4c1bcb 5f5d462 e4c1bcb b7f0f1d 5f5d462 e4c1bcb 0587958 d35ed81 487bfc6 d35ed81 d2356ec 9a8a812 487bfc6 9a8a812 487bfc6 9a8a812 487bfc6 9a8a812 487bfc6 d2356ec 487bfc6 9a8a812 487bfc6 9a8a812 d35ed81 ed26441 d35ed81 487bfc6 d35ed81 d2356ec d35ed81 6bad670 ed26441 d2356ec d35ed81 0587958 ed26441 d2356ec aac8723 d2356ec 0587958 06d670f 439049f d35ed81 0587958 d35ed81 0587958 aac8723 d2356ec 06d670f 0587958 d35ed81 b1aa6a1 56e5321 06c91a9 56e5321 06c91a9 56e5321 06c91a9 56e5321 66a3cea 56e5321 66a3cea 56e5321 66a3cea 56e5321 58cc9a8 56e5321 58cc9a8 56e5321 0587958 d35ed81 56e5321 58cc9a8 a3611db 58cc9a8 c17a188 58cc9a8 799af78 58cc9a8 799af78 58cc9a8 799af78 58cc9a8 66a3cea 2c50831 5f5d462 2c50831 b7f0f1d 5f5d462 2c50831 0935499 77deeb4 0935499 ba34677 0935499 c71e540 ba34677 c71e540 06c91a9 c71e540 0935499 e0cb8bc 0935499 e0cb8bc 0935499 ba34677 0935499 c71e540 0935499 2c50831 e0cb8bc 2c50831 ad06f60 2c50831 ad06f60 2c50831 e0cb8bc 2c50831 e0cb8bc 2c50831 0935499 c71e540 2c50831 e0cb8bc 2c50831 e0cb8bc 2c50831 e0cb8bc 439049f feede45 2c50831 66a3cea 2c50831 0935499 2c50831 66a3cea 2c50831 e0cb8bc 2c50831 3e35161 e0cb8bc 2c50831 e0cb8bc 439049f feede45 2c50831 e0cb8bc 2c50831 e0cb8bc 2c50831 e0cb8bc 439049f feede45 2c50831 d2356ec 06d670f d35ed81 0587958 d35ed81 06d670f d35ed81 0587958 06d670f d35ed81 0587958 d35ed81 0587958 d35ed81 e0cb8bc d35ed81 0587958 d35ed81 d2356ec 0587958 d2356ec d35ed81 0587958 ad06f60 0587958 d35ed81 0587958 d35ed81 e0cb8bc 0587958 06d670f d35ed81 0587958 e0cb8bc d35ed81 e0cb8bc 439049f d35ed81 d2356ec d35ed81 d2356ec d35ed81 0587958 d35ed81 06d670f c09c6fe 06d670f 77edcd1 06d670f 77edcd1 06d670f c09c6fe 06d670f c09c6fe 77edcd1 c09c6fe 77edcd1 c09c6fe 06d670f 77edcd1 c09c6fe 77edcd1 06d670f c09c6fe 06d670f 77edcd1 06d670f 77edcd1 c09c6fe 77edcd1 06d670f 77edcd1 c09c6fe 77edcd1 c09c6fe 77edcd1 06d670f 77edcd1 06d670f 77edcd1 63fd7b5 77edcd1 853c602 06d670f 77edcd1 853c602 17f9926 853c602 17f9926 853c602 77edcd1 853c602 77edcd1 63fd7b5 77edcd1 06d670f 77edcd1 06d670f 77edcd1 06d670f 77edcd1 06d670f 77edcd1 06d670f 77edcd1 06d670f 77edcd1 17f9926 06d670f 77edcd1 06d670f 77edcd1 06d670f 77edcd1 06d670f 77edcd1 c09c6fe 06d670f c09c6fe 77edcd1 c09c6fe 77edcd1 06d670f 77edcd1 06d670f c09c6fe 06d670f c09c6fe 06d670f c09c6fe 77edcd1 c09c6fe 77edcd1 c09c6fe 06d670f c09c6fe 06d670f c09c6fe 06d670f c09c6fe 20074f0 06d670f c09c6fe 0587958 d2356ec d35ed81 06d670f d35ed81 d2356ec d35ed81 1c430d1 d35ed81 0587958 1c430d1 0587958 d35ed81 0587958 d2356ec feede45 0587958 feede45 0587958 feede45 d2356ec 0587958 d2356ec 1c430d1 d35ed81 a77713e d5824e0 a77713e 0587958 d35ed81 7837aa2 | 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 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 1446 1447 1448 1449 1450 1451 1452 1453 1454 1455 1456 1457 1458 1459 1460 1461 1462 1463 1464 1465 1466 1467 1468 1469 1470 1471 1472 1473 1474 1475 1476 1477 1478 1479 1480 1481 1482 1483 1484 1485 1486 1487 1488 1489 1490 1491 1492 1493 1494 1495 1496 1497 1498 1499 1500 1501 1502 1503 1504 1505 1506 1507 1508 1509 1510 1511 1512 1513 1514 1515 1516 1517 1518 1519 1520 1521 1522 1523 1524 1525 1526 1527 1528 1529 1530 1531 1532 1533 1534 1535 1536 1537 1538 1539 1540 1541 1542 1543 1544 1545 1546 1547 1548 1549 1550 1551 1552 1553 1554 1555 1556 1557 1558 1559 1560 1561 1562 1563 1564 1565 1566 1567 1568 1569 1570 1571 1572 1573 1574 1575 1576 1577 1578 1579 1580 1581 1582 1583 1584 1585 1586 1587 1588 1589 1590 1591 1592 1593 1594 1595 1596 1597 1598 1599 1600 1601 1602 1603 1604 1605 1606 1607 1608 1609 1610 1611 1612 1613 1614 1615 1616 1617 1618 1619 1620 1621 1622 1623 1624 1625 1626 1627 1628 1629 1630 1631 1632 1633 1634 1635 1636 1637 1638 1639 1640 1641 1642 1643 1644 1645 1646 1647 1648 1649 1650 1651 1652 1653 1654 1655 1656 1657 1658 1659 1660 1661 1662 1663 1664 1665 1666 1667 1668 1669 1670 1671 1672 1673 1674 1675 1676 1677 1678 1679 1680 1681 1682 1683 1684 1685 1686 1687 1688 1689 1690 1691 1692 1693 1694 1695 1696 1697 1698 1699 1700 1701 1702 1703 1704 1705 1706 1707 1708 1709 1710 1711 1712 1713 1714 1715 1716 1717 1718 1719 1720 1721 1722 1723 1724 1725 1726 1727 1728 1729 1730 1731 1732 1733 1734 1735 1736 1737 1738 1739 1740 1741 1742 1743 1744 1745 1746 1747 1748 1749 1750 1751 1752 1753 1754 1755 1756 1757 1758 1759 1760 1761 1762 1763 1764 1765 1766 1767 1768 1769 1770 1771 1772 1773 1774 1775 1776 1777 1778 1779 1780 1781 1782 1783 1784 1785 1786 1787 1788 1789 1790 1791 1792 1793 1794 1795 1796 1797 1798 1799 1800 1801 1802 1803 1804 1805 1806 1807 1808 1809 1810 1811 1812 1813 1814 1815 1816 1817 1818 1819 1820 1821 1822 1823 1824 1825 1826 1827 1828 1829 1830 1831 1832 1833 1834 1835 1836 1837 1838 1839 1840 1841 1842 1843 1844 1845 1846 1847 1848 1849 1850 1851 1852 1853 1854 1855 1856 1857 1858 1859 1860 1861 1862 1863 1864 1865 1866 1867 1868 1869 1870 1871 1872 1873 1874 1875 1876 1877 1878 1879 1880 1881 1882 1883 1884 1885 1886 1887 1888 1889 1890 1891 1892 1893 1894 1895 1896 1897 1898 1899 1900 1901 1902 1903 1904 1905 1906 1907 1908 1909 1910 1911 1912 1913 1914 1915 1916 1917 1918 1919 1920 1921 1922 1923 1924 1925 1926 1927 1928 1929 1930 1931 1932 1933 1934 1935 1936 1937 1938 1939 1940 1941 1942 1943 1944 1945 1946 1947 1948 1949 1950 1951 1952 1953 1954 1955 1956 1957 1958 1959 1960 1961 1962 1963 1964 1965 1966 1967 1968 1969 1970 1971 1972 1973 1974 1975 1976 1977 1978 1979 1980 1981 1982 1983 1984 1985 1986 1987 1988 1989 1990 1991 1992 1993 1994 1995 1996 1997 1998 1999 2000 2001 2002 2003 2004 2005 2006 2007 2008 2009 2010 2011 2012 2013 2014 2015 2016 2017 2018 2019 2020 2021 2022 2023 2024 2025 2026 2027 2028 2029 2030 2031 2032 2033 2034 2035 2036 2037 2038 2039 2040 2041 2042 2043 2044 2045 2046 2047 2048 2049 2050 2051 2052 2053 2054 2055 2056 2057 2058 2059 2060 2061 2062 2063 2064 2065 2066 2067 2068 2069 2070 2071 2072 2073 2074 2075 2076 2077 2078 2079 2080 2081 2082 2083 2084 2085 2086 2087 2088 2089 2090 2091 2092 2093 2094 2095 2096 2097 2098 2099 2100 2101 2102 2103 2104 2105 2106 2107 2108 2109 2110 2111 2112 2113 2114 2115 2116 2117 2118 2119 2120 2121 2122 2123 2124 2125 2126 2127 2128 2129 2130 2131 2132 2133 2134 2135 2136 2137 2138 2139 2140 2141 2142 2143 2144 2145 2146 2147 2148 2149 2150 2151 2152 2153 2154 2155 2156 2157 2158 2159 2160 2161 2162 2163 2164 2165 2166 2167 2168 2169 2170 2171 2172 2173 2174 2175 2176 2177 2178 2179 2180 2181 2182 2183 2184 2185 2186 2187 2188 2189 2190 2191 2192 2193 2194 2195 2196 2197 2198 2199 2200 2201 2202 2203 2204 2205 2206 2207 2208 2209 2210 2211 2212 2213 2214 2215 2216 2217 2218 2219 2220 2221 2222 2223 2224 2225 2226 2227 2228 2229 2230 2231 2232 2233 2234 2235 2236 2237 2238 2239 2240 2241 2242 2243 2244 2245 2246 2247 2248 2249 2250 2251 2252 2253 2254 2255 2256 2257 2258 2259 2260 2261 2262 2263 2264 2265 2266 2267 2268 2269 2270 2271 2272 2273 2274 2275 2276 2277 2278 2279 2280 2281 2282 2283 2284 2285 2286 2287 2288 2289 2290 2291 2292 2293 2294 2295 2296 2297 2298 2299 2300 2301 2302 2303 2304 2305 2306 2307 2308 2309 2310 2311 2312 2313 2314 2315 2316 2317 2318 2319 2320 2321 2322 2323 2324 2325 2326 2327 2328 2329 2330 2331 2332 2333 2334 2335 2336 2337 2338 2339 2340 2341 2342 2343 2344 2345 2346 2347 2348 2349 2350 2351 2352 2353 2354 2355 2356 2357 2358 2359 2360 2361 2362 2363 2364 2365 2366 2367 2368 2369 2370 2371 2372 2373 2374 2375 2376 2377 2378 2379 2380 2381 2382 2383 2384 2385 2386 2387 2388 2389 2390 2391 2392 2393 2394 2395 2396 2397 2398 2399 2400 2401 2402 2403 2404 2405 2406 2407 2408 2409 2410 2411 2412 2413 2414 2415 2416 2417 2418 2419 2420 2421 2422 2423 2424 2425 2426 2427 2428 2429 2430 2431 2432 2433 2434 2435 2436 2437 2438 2439 2440 2441 2442 2443 2444 2445 2446 2447 2448 2449 2450 2451 2452 2453 2454 2455 2456 2457 2458 2459 2460 2461 2462 2463 2464 2465 2466 2467 2468 2469 2470 2471 2472 2473 2474 2475 2476 2477 2478 2479 2480 2481 2482 2483 2484 2485 2486 2487 2488 2489 2490 2491 2492 2493 2494 2495 2496 2497 2498 2499 2500 2501 2502 2503 2504 2505 2506 2507 2508 2509 2510 2511 2512 2513 2514 2515 2516 2517 2518 2519 2520 2521 2522 2523 2524 2525 2526 2527 2528 2529 2530 2531 2532 2533 2534 2535 2536 2537 2538 2539 2540 2541 2542 2543 2544 2545 2546 2547 2548 2549 2550 2551 2552 2553 2554 2555 2556 2557 2558 2559 2560 2561 2562 2563 2564 2565 2566 2567 2568 2569 2570 2571 2572 2573 2574 2575 2576 2577 2578 2579 2580 2581 2582 2583 2584 2585 2586 2587 2588 2589 2590 2591 2592 2593 2594 2595 2596 2597 2598 2599 2600 2601 2602 2603 2604 2605 2606 2607 2608 2609 2610 2611 2612 2613 2614 2615 2616 2617 2618 2619 2620 2621 2622 2623 2624 2625 2626 2627 2628 2629 2630 2631 2632 2633 2634 2635 2636 2637 2638 2639 2640 2641 2642 2643 2644 2645 2646 2647 2648 2649 2650 2651 2652 2653 2654 2655 2656 2657 2658 2659 2660 2661 2662 2663 2664 2665 2666 2667 2668 2669 2670 2671 2672 2673 2674 2675 2676 2677 2678 2679 2680 2681 2682 2683 2684 2685 2686 2687 2688 2689 2690 2691 2692 2693 2694 2695 2696 2697 2698 2699 2700 2701 2702 2703 2704 2705 2706 2707 2708 2709 2710 2711 2712 2713 2714 2715 2716 2717 2718 2719 2720 2721 2722 2723 2724 2725 2726 2727 2728 2729 2730 2731 2732 2733 2734 2735 2736 2737 2738 2739 2740 2741 2742 2743 2744 2745 2746 2747 2748 2749 2750 2751 2752 2753 2754 2755 2756 2757 2758 2759 2760 2761 2762 2763 2764 2765 2766 2767 2768 2769 2770 2771 2772 2773 2774 2775 2776 2777 2778 2779 2780 2781 2782 2783 2784 2785 2786 2787 2788 2789 2790 2791 2792 2793 2794 2795 2796 2797 2798 2799 2800 2801 2802 2803 2804 2805 2806 2807 2808 2809 2810 2811 2812 2813 2814 2815 2816 2817 2818 2819 2820 2821 2822 2823 2824 2825 2826 2827 2828 2829 2830 2831 2832 2833 2834 2835 2836 2837 2838 2839 2840 2841 2842 2843 2844 2845 2846 2847 2848 2849 2850 2851 2852 2853 2854 2855 2856 2857 2858 2859 2860 2861 2862 2863 2864 2865 2866 2867 2868 2869 2870 2871 2872 2873 2874 2875 2876 2877 2878 2879 2880 2881 2882 2883 2884 2885 2886 2887 2888 2889 2890 2891 2892 2893 2894 2895 2896 2897 2898 2899 2900 2901 2902 2903 2904 2905 2906 2907 2908 2909 2910 2911 2912 2913 2914 2915 2916 2917 2918 2919 2920 2921 2922 2923 2924 2925 2926 2927 2928 2929 2930 2931 2932 2933 2934 2935 2936 2937 2938 2939 2940 2941 2942 2943 2944 2945 2946 2947 2948 2949 2950 2951 2952 2953 2954 2955 2956 2957 2958 2959 2960 2961 2962 2963 2964 2965 2966 2967 2968 2969 2970 2971 2972 2973 2974 2975 2976 2977 2978 2979 2980 2981 2982 2983 2984 2985 2986 2987 2988 2989 2990 2991 2992 2993 2994 2995 2996 2997 2998 2999 3000 3001 3002 3003 3004 3005 3006 3007 3008 3009 3010 3011 3012 3013 3014 3015 3016 3017 3018 3019 3020 3021 3022 3023 3024 3025 3026 3027 3028 3029 3030 3031 3032 3033 3034 3035 3036 3037 3038 3039 3040 3041 3042 3043 3044 3045 3046 3047 3048 3049 3050 3051 3052 3053 3054 3055 3056 3057 3058 3059 3060 3061 3062 3063 3064 3065 3066 3067 3068 3069 3070 3071 3072 3073 3074 3075 3076 3077 3078 3079 3080 3081 3082 3083 3084 3085 3086 3087 3088 3089 3090 3091 3092 3093 3094 3095 3096 3097 3098 3099 3100 3101 3102 3103 3104 3105 3106 3107 3108 3109 3110 3111 3112 3113 3114 3115 3116 3117 3118 3119 3120 3121 3122 3123 3124 3125 3126 3127 3128 3129 3130 3131 3132 3133 3134 3135 3136 3137 3138 3139 3140 3141 3142 3143 3144 3145 3146 3147 3148 3149 3150 3151 3152 3153 3154 3155 3156 3157 3158 3159 3160 3161 3162 3163 3164 3165 3166 3167 3168 3169 3170 3171 3172 3173 3174 3175 3176 3177 3178 3179 3180 3181 3182 3183 3184 3185 3186 3187 3188 3189 3190 3191 3192 3193 3194 3195 3196 3197 3198 3199 3200 3201 3202 3203 3204 3205 3206 3207 3208 3209 3210 3211 3212 3213 3214 3215 3216 3217 3218 3219 3220 3221 3222 3223 3224 3225 3226 3227 3228 3229 3230 3231 3232 3233 3234 3235 3236 3237 3238 3239 3240 3241 3242 3243 3244 3245 3246 3247 3248 3249 3250 3251 3252 3253 3254 3255 3256 3257 3258 3259 3260 3261 3262 3263 3264 3265 3266 3267 3268 3269 3270 3271 3272 3273 3274 3275 3276 3277 3278 3279 3280 3281 3282 3283 3284 3285 3286 3287 3288 3289 3290 3291 3292 3293 3294 3295 3296 3297 3298 3299 3300 3301 3302 3303 3304 3305 3306 3307 3308 3309 3310 3311 3312 3313 3314 3315 3316 3317 3318 3319 3320 3321 3322 3323 3324 3325 3326 3327 3328 3329 3330 3331 3332 3333 3334 3335 3336 3337 3338 3339 3340 3341 3342 3343 3344 3345 3346 3347 3348 3349 3350 3351 3352 3353 3354 3355 3356 3357 3358 3359 3360 3361 3362 3363 3364 3365 3366 3367 3368 3369 3370 3371 3372 3373 3374 3375 3376 3377 3378 3379 3380 3381 3382 3383 3384 3385 3386 3387 3388 3389 3390 3391 3392 3393 3394 3395 3396 3397 3398 3399 3400 3401 3402 3403 3404 3405 3406 3407 3408 3409 3410 3411 3412 3413 3414 3415 3416 3417 3418 3419 3420 3421 3422 3423 3424 3425 3426 3427 3428 3429 3430 3431 3432 3433 3434 3435 3436 3437 3438 3439 3440 3441 3442 3443 3444 3445 3446 3447 3448 3449 3450 3451 3452 3453 3454 3455 3456 3457 3458 3459 3460 3461 3462 3463 3464 3465 3466 3467 3468 3469 3470 3471 3472 3473 3474 3475 3476 3477 3478 3479 3480 3481 3482 3483 3484 3485 3486 3487 3488 3489 3490 3491 3492 3493 3494 3495 3496 3497 3498 3499 3500 3501 3502 3503 3504 3505 3506 3507 3508 3509 3510 3511 3512 3513 3514 3515 3516 3517 3518 3519 3520 3521 3522 3523 3524 3525 3526 3527 3528 3529 3530 3531 3532 3533 3534 3535 3536 3537 3538 3539 3540 3541 3542 3543 3544 3545 3546 3547 3548 3549 3550 3551 3552 3553 3554 3555 3556 3557 3558 3559 3560 3561 3562 3563 3564 3565 3566 3567 3568 3569 3570 3571 3572 3573 3574 3575 3576 3577 3578 3579 3580 3581 3582 3583 3584 3585 3586 3587 3588 3589 3590 3591 3592 3593 3594 3595 3596 3597 3598 3599 3600 3601 3602 3603 3604 3605 3606 3607 3608 3609 3610 3611 3612 3613 3614 3615 3616 3617 3618 3619 3620 3621 3622 3623 3624 3625 3626 3627 3628 3629 3630 3631 3632 3633 3634 3635 3636 3637 3638 3639 3640 3641 3642 3643 3644 3645 3646 3647 3648 3649 3650 3651 3652 3653 3654 3655 3656 3657 3658 3659 3660 3661 3662 3663 3664 3665 3666 3667 3668 3669 3670 3671 3672 3673 3674 3675 3676 3677 3678 3679 3680 3681 3682 3683 3684 3685 3686 3687 3688 3689 3690 3691 3692 3693 3694 3695 3696 3697 3698 3699 3700 3701 3702 3703 3704 3705 3706 3707 3708 3709 3710 3711 3712 3713 3714 3715 3716 3717 3718 3719 3720 3721 3722 3723 3724 3725 3726 3727 3728 3729 3730 3731 3732 3733 3734 3735 3736 3737 3738 3739 3740 3741 3742 3743 3744 3745 3746 3747 3748 3749 3750 3751 3752 3753 3754 3755 3756 3757 3758 3759 3760 3761 3762 3763 3764 3765 3766 3767 3768 3769 3770 3771 3772 3773 3774 3775 3776 3777 3778 3779 3780 3781 3782 3783 3784 3785 3786 3787 3788 3789 3790 3791 3792 3793 3794 3795 3796 3797 3798 3799 3800 3801 3802 3803 3804 3805 3806 3807 3808 3809 3810 3811 3812 3813 3814 3815 3816 3817 3818 3819 3820 3821 3822 3823 3824 3825 3826 3827 3828 3829 3830 3831 3832 3833 3834 3835 3836 3837 3838 3839 3840 3841 3842 3843 3844 3845 3846 3847 3848 3849 3850 3851 3852 3853 3854 3855 3856 3857 3858 3859 3860 3861 3862 3863 3864 3865 3866 3867 3868 3869 3870 3871 3872 3873 3874 3875 3876 3877 3878 3879 3880 3881 3882 3883 3884 3885 3886 3887 3888 3889 3890 3891 3892 3893 3894 3895 3896 3897 3898 3899 3900 3901 3902 3903 3904 3905 3906 3907 3908 3909 3910 3911 3912 3913 3914 3915 3916 3917 3918 3919 3920 3921 3922 3923 3924 3925 3926 3927 3928 3929 3930 3931 3932 3933 3934 3935 3936 3937 3938 3939 3940 3941 3942 3943 3944 3945 3946 3947 3948 3949 3950 3951 3952 3953 3954 3955 3956 3957 3958 3959 3960 3961 3962 3963 3964 3965 3966 3967 3968 3969 3970 3971 3972 3973 3974 3975 3976 3977 3978 3979 3980 3981 3982 3983 3984 3985 3986 3987 3988 3989 3990 3991 3992 3993 3994 3995 3996 3997 3998 3999 4000 4001 4002 4003 4004 4005 4006 4007 4008 4009 4010 4011 4012 4013 4014 4015 4016 4017 4018 4019 4020 4021 4022 4023 4024 4025 4026 4027 4028 4029 4030 4031 4032 4033 4034 4035 4036 4037 4038 4039 4040 4041 4042 4043 4044 4045 4046 4047 4048 4049 4050 4051 4052 4053 4054 4055 4056 4057 4058 4059 4060 4061 4062 4063 4064 4065 4066 4067 4068 4069 4070 4071 4072 4073 4074 4075 4076 4077 4078 4079 4080 4081 4082 4083 4084 4085 4086 4087 4088 4089 4090 4091 4092 4093 4094 4095 4096 4097 4098 4099 4100 4101 4102 4103 4104 4105 4106 4107 4108 4109 4110 4111 4112 4113 4114 4115 4116 4117 4118 4119 4120 4121 4122 4123 4124 4125 4126 4127 4128 4129 4130 4131 4132 4133 4134 4135 4136 4137 4138 4139 4140 4141 4142 4143 4144 4145 4146 4147 4148 4149 4150 4151 4152 4153 4154 4155 4156 4157 4158 4159 4160 4161 4162 4163 4164 4165 4166 4167 4168 4169 4170 4171 4172 4173 4174 4175 4176 4177 4178 4179 4180 4181 4182 4183 4184 4185 4186 4187 4188 4189 4190 4191 4192 4193 4194 4195 4196 4197 4198 4199 4200 4201 4202 4203 4204 4205 4206 4207 4208 4209 4210 4211 4212 4213 4214 4215 4216 4217 4218 4219 4220 4221 4222 4223 4224 4225 4226 4227 4228 4229 4230 4231 4232 4233 4234 4235 4236 4237 4238 4239 4240 4241 4242 4243 4244 4245 4246 4247 4248 4249 4250 4251 4252 4253 4254 4255 4256 4257 4258 4259 4260 4261 4262 4263 4264 4265 4266 4267 4268 4269 4270 4271 4272 4273 4274 4275 4276 4277 4278 4279 4280 4281 4282 4283 4284 4285 4286 4287 4288 4289 4290 4291 4292 4293 4294 4295 4296 4297 4298 4299 4300 4301 4302 4303 4304 4305 4306 4307 4308 4309 4310 4311 4312 4313 4314 4315 4316 4317 4318 4319 4320 4321 4322 4323 4324 4325 4326 4327 4328 4329 4330 4331 4332 4333 4334 4335 4336 4337 4338 4339 4340 4341 4342 4343 4344 4345 4346 4347 4348 4349 4350 4351 4352 4353 4354 4355 4356 4357 4358 4359 4360 4361 4362 4363 4364 4365 4366 4367 4368 4369 4370 4371 4372 4373 4374 4375 4376 4377 4378 4379 4380 4381 | <!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>ZeroLabs</title>
<link rel="preconnect" href="https://fonts.googleapis.com">
<link href="https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap" rel="stylesheet">
<style>
:root, [data-theme="dark"] {
--bg: #0f0e0d;
--surface: #1c1917;
--surface2: #292524;
--surface3: #44403c;
--border: #44403c;
--border-hover: #57534e;
--text: #fafaf9;
--text-secondary: #a8a29e;
--text-muted: #78716c;
--accent: #f59e0b;
--accent-hover: #fbbf24;
--accent-subtle: rgba(245,158,11,0.1);
--accent-glow: rgba(245,158,11,0.12);
--danger: #ef4444;
--success: #22c55e;
--warning: #fbbf24;
--btn-text: #1c1917;
--shadow-color: rgba(0,0,0,0.3);
--btn-shadow: #92400e;
--btn-shadow-hf: #b45309;
}
[data-theme="light"] {
--bg: #fafaf9;
--surface: #ffffff;
--surface2: #f5f5f4;
--surface3: #e7e5e4;
--border: #d6d3d1;
--border-hover: #a8a29e;
--text: #1c1917;
--text-secondary: #57534e;
--text-muted: #78716c;
--accent: #d97706;
--accent-hover: #b45309;
--accent-subtle: rgba(217,119,6,0.08);
--accent-glow: rgba(217,119,6,0.1);
--danger: #dc2626;
--success: #16a34a;
--warning: #d97706;
--btn-text: #ffffff;
--shadow-color: rgba(0,0,0,0.1);
--btn-shadow: #92400e;
--btn-shadow-hf: #7c2d12;
}
* { margin: 0; padding: 0; box-sizing: border-box; }
body {
font-family: 'Inter', -apple-system, sans-serif;
background: var(--bg);
color: var(--text);
height: 100vh;
overflow: hidden;
}
.app-layout {
display: grid;
grid-template-columns: 260px 1fr;
grid-template-rows: 56px 1fr;
height: 100vh;
}
.header {
grid-column: 1 / -1;
display: flex;
align-items: center;
justify-content: space-between;
padding: 0 20px;
background: var(--surface);
border-bottom: 1px solid var(--border);
z-index: 10;
}
.logo {
font-size: 17px;
font-weight: 700;
letter-spacing: -0.3px;
display: flex;
align-items: center;
gap: 8px;
}
.logo-icon {
width: 28px;
height: 28px;
background: linear-gradient(135deg, var(--accent), #d97706);
border-radius: 7px;
display: flex;
align-items: center;
justify-content: center;
font-size: 16px;
font-weight: 800;
color: var(--btn-text);
font-family: 'Inter', sans-serif;
}
.header-right {
display: flex;
align-items: center;
gap: 12px;
}
.user-pill {
position: relative;
display: flex;
align-items: center;
gap: 8px;
padding: 4px 12px 4px 4px;
background: var(--surface2);
border: 1px solid var(--border);
border-radius: 20px;
font-size: 13px;
color: var(--text-secondary);
cursor: pointer;
transition: all 0.1s;
}
.user-pill:hover { border-color: var(--border-hover); color: var(--text); }
.user-pill img {
width: 24px;
height: 24px;
border-radius: 50%;
}
.user-menu {
position: absolute; top: calc(100% + 6px); right: 0;
min-width: 160px; background: var(--surface); border: 1px solid var(--border); border-radius: 10px;
box-shadow: 0 8px 24px var(--shadow-color); padding: 4px; z-index: 50;
display: none;
}
.user-menu.visible { display: block; }
.user-menu-item {
display: flex; align-items: center; gap: 8px; width: 100%;
padding: 8px 10px; border: none; background: transparent;
font-family: 'Inter', sans-serif; font-size: 13px; color: var(--text);
text-align: left; border-radius: 6px; cursor: pointer;
}
.user-menu-item:hover { background: var(--surface2); }
.user-menu-item svg { width: 14px; height: 14px; flex-shrink: 0; }
.sidebar {
background: var(--surface);
border-right: 1px solid var(--border);
display: flex;
flex-direction: column;
overflow: hidden;
}
.sidebar-section {
padding: 16px 12px 8px;
}
.sidebar-label {
font-size: 11px;
font-weight: 600;
text-transform: uppercase;
letter-spacing: 0.8px;
color: var(--text-muted);
padding: 0 8px;
margin-bottom: 8px;
}
.nav-item {
display: flex;
align-items: center;
gap: 10px;
padding: 8px 12px;
border-radius: 8px;
font-size: 13px;
color: var(--text-secondary);
cursor: pointer;
transition: all 0.1s;
border: none;
background: none;
width: 100%;
text-align: left;
}
.nav-item:hover { background: var(--surface2); color: var(--text); }
.nav-item.active { background: var(--accent-subtle); color: var(--accent-hover); }
.nav-item svg { width: 18px; height: 18px; flex-shrink: 0; }
.sidebar-voices {
flex: 1;
overflow-y: auto;
padding: 0 12px 12px;
}
.voice-card {
display: flex;
align-items: center;
gap: 10px;
padding: 10px;
border-radius: 8px;
cursor: pointer;
transition: all 0.1s;
margin-bottom: 2px;
border: 1px solid transparent;
}
.voice-card:hover { background: var(--surface2); }
.voice-card.selected { background: var(--accent-subtle); border-color: var(--accent); }
.voice-avatar {
width: 36px;
height: 36px;
border-radius: 8px;
display: flex;
align-items: center;
justify-content: center;
font-size: 16px;
flex-shrink: 0;
color: white;
font-weight: 600;
}
.voice-meta { flex: 1; min-width: 0; }
.voice-name { font-size: 13px; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.voice-detail { font-size: 11px; color: var(--text-muted); }
.voice-card .delete-voice {
opacity: 0; padding: 4px; border: none; background: none;
color: var(--text-muted); cursor: pointer; border-radius: 4px; transition: all 0.1s;
}
.voice-card:hover .delete-voice { opacity: 1; }
.voice-card .delete-voice:hover { color: var(--danger); background: rgba(239,68,68,0.1); }
/* ── Usage tracker ── */
.usage-tracker {
padding: 12px;
margin: 0 12px 12px;
background: var(--surface2);
border: 1px solid var(--border);
border-radius: 10px;
}
.usage-header {
display: flex;
align-items: center;
justify-content: space-between;
margin-bottom: 8px;
}
.usage-label { font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.5px; color: var(--text-muted); }
.usage-value { font-size: 11px; color: var(--text-secondary); font-variant-numeric: tabular-nums; }
.usage-bar {
width: 100%;
height: 4px;
background: var(--surface3);
border-radius: 2px;
overflow: hidden;
margin-bottom: 6px;
}
.usage-fill {
height: 100%;
background: var(--accent);
border-radius: 2px;
transition: width 0.5s ease;
}
.usage-fill.warning { background: var(--warning); }
.usage-fill.danger { background: var(--danger); }
.usage-sub { font-size: 10px; color: var(--text-muted); }
/* ── Content ── */
.content {
overflow-y: auto;
padding: 32px;
display: flex;
justify-content: center;
}
.content-inner { width: 100%; max-width: 720px; }
.page { display: none; }
.page.active { display: block; }
.page-header { margin-bottom: 28px; position: relative; padding-right: 100px; }
.page-title { font-size: 22px; font-weight: 700; letter-spacing: -0.5px; margin-bottom: 6px; }
.page-desc { font-size: 14px; color: var(--text-muted); }
.page-api-toggle {
position: absolute; top: 2px; right: 0;
padding: 6px 11px; border-radius: 7px; border: 1px solid var(--border); background: var(--surface);
color: var(--text-muted); font-family: 'Inter', sans-serif; font-size: 12px; font-weight: 500;
display: inline-flex; align-items: center; gap: 6px; cursor: pointer; transition: all 0.1s;
}
.page-api-toggle:hover { color: var(--text); border-color: var(--border-hover); }
.page-api-toggle.open { color: var(--text); background: var(--surface2); border-color: var(--border-hover); }
.page-api-toggle svg { width: 13px; height: 13px; }
.page-api-panel { margin: -12px 0 24px 0; padding: 14px; background: var(--surface); border: 1px solid var(--border); border-radius: 10px; }
.page-api-panel .api-tabs { margin-bottom: 12px; }
.page-api-panel .code-block { margin: 0; }
/* Voice selector */
.voice-selector {
display: flex; align-items: center; gap: 12px;
padding: 14px 16px; background: var(--surface); border: 1px solid var(--border);
border-radius: 12px; margin-bottom: 16px; cursor: pointer; transition: border-color 0.15s;
}
.voice-selector:hover { border-color: var(--border-hover); }
.voice-selector .voice-avatar { width: 40px; height: 40px; }
.voice-selector-info { flex: 1; }
.voice-selector-name { font-size: 14px; font-weight: 600; }
.voice-selector-hint { font-size: 12px; color: var(--text-muted); }
.voice-selector-change { font-size: 12px; color: var(--accent); font-weight: 500; }
/* Editor */
.editor {
background: var(--surface); border: 1px solid var(--border);
border-radius: 12px; overflow: hidden; margin-bottom: 16px;
}
.editor textarea {
width: 100%; min-height: 180px; background: transparent; border: none;
padding: 20px; color: var(--text); font-family: 'Inter', sans-serif;
font-size: 15px; line-height: 1.6; resize: vertical;
}
.editor textarea:focus { outline: none; }
.editor textarea::placeholder { color: var(--text-muted); }
.editor-footer {
display: flex; align-items: center; justify-content: space-between;
padding: 10px 20px; border-top: 1px solid var(--border); background: var(--surface2);
}
.editor-left { display: flex; align-items: center; gap: 12px; }
.editor-stat { font-size: 12px; color: var(--text-muted); }
.lang-select {
padding: 4px 8px; background: var(--surface3); border: 1px solid var(--border);
border-radius: 6px; color: var(--text-secondary); font-size: 12px; font-family: 'Inter', sans-serif;
}
.lang-select:focus { outline: none; border-color: var(--accent); }
/* Adaptive rich-document editor (synthesis) */
#page-synthesis { position: relative; }
.gen-editor { position: relative; margin-bottom: 16px; }
/* Rich document editor */
.ab-doc {
border: 1px solid var(--border); border-radius: 12px 12px 0 0; background: var(--surface);
padding: 14px 14px 14px 6px; min-height: 180px; max-height: 60vh; overflow-y: auto;
}
/* Single-segment "simple" mode looks just like a plain text field */
.ab-doc.simple { padding: 6px 8px; }
.ab-doc.simple .ab-chip, .ab-doc.simple .ab-row-side { display: none; }
.ab-doc.simple .ab-para { padding: 8px 10px; font-size: 15px; }
.ab-doc.simple .ab-row { padding: 0; }
.ab-row { display: flex; align-items: flex-start; gap: 10px; padding: 4px 0; position: relative; }
.ab-chip {
flex: none; width: 56px; background: none; border: none; cursor: pointer; padding: 0;
display: flex; flex-direction: column; align-items: center; gap: 2px; margin-top: 1px;
}
.ab-chip-av {
width: 30px; height: 30px; border-radius: 50%; border: 2px solid var(--border);
color: #fff; font-size: 12px; font-weight: 700;
display: flex; align-items: center; justify-content: center; gap: 1px; position: relative;
}
.ab-chip-av svg { width: 9px; height: 9px; opacity: 0.85; }
.ab-chip.overridden .ab-chip-av { box-shadow: 0 0 0 2px var(--accent); }
.ab-chip-name {
font-size: 10px; font-weight: 600; color: var(--text-muted); max-width: 56px;
overflow: hidden; text-overflow: ellipsis; white-space: nowrap; line-height: 1.2;
}
.ab-chip:hover .ab-chip-name { color: var(--text-secondary); }
.ab-para {
flex: 1; font-size: 15px; line-height: 1.55; color: var(--text); padding: 4px 8px;
border-radius: 6px; background: transparent; outline: none; min-height: 1.55em;
white-space: pre-wrap; word-break: break-word;
}
.ab-para:hover { background: var(--surface2); }
.ab-para:focus { background: var(--surface2); }
.ab-para:empty::before { content: "Type or paste your text here…"; color: var(--text-muted); pointer-events: none; }
.ab-row-side { flex: none; display: flex; align-items: center; gap: 6px; margin-top: 2px; }
.ab-dl-one {
width: 26px; height: 26px; border-radius: 6px; border: 1px solid var(--border);
background: var(--surface3); color: var(--text-secondary); cursor: pointer; padding: 0;
display: flex; align-items: center; justify-content: center;
}
.ab-dl-one:hover { color: var(--text); border-color: var(--border-hover); }
.ab-dl-one svg { width: 13px; height: 13px; }
.ab-dl-one.busy { opacity: 0.5; pointer-events: none; }
.ab-dl-one:disabled { opacity: 0.3; cursor: not-allowed; border-color: var(--border); }
.ab-dl-one:disabled:hover { color: var(--text-secondary); border-color: var(--border); background: var(--surface3); }
.ab-join {
position: absolute; left: 28px; bottom: -9px; z-index: 5;
width: 20px; height: 18px; border-radius: 5px; border: 1px solid var(--border);
background: var(--surface); color: var(--text-muted); cursor: pointer; padding: 0;
display: none; align-items: center; justify-content: center; opacity: 0;
transition: opacity 0.1s;
}
.ab-row:hover .ab-join { display: flex; opacity: 1; }
.ab-join:hover { color: var(--text); border-color: var(--border-hover); background: var(--surface2); }
.ab-join svg { width: 11px; height: 11px; }
.ab-row-del {
width: 24px; height: 24px; border-radius: 6px; border: 1px solid transparent;
background: none; color: var(--text-muted); cursor: pointer; padding: 0;
display: flex; align-items: center; justify-content: center; font-size: 15px; line-height: 1;
}
.ab-row-del:hover { color: #dc2626; border-color: var(--border); background: var(--surface3); }
.ab-play-one {
width: 26px; height: 26px; border-radius: 6px; border: 1px solid var(--border);
background: var(--surface3); color: var(--text-secondary); cursor: pointer; padding: 0;
display: flex; align-items: center; justify-content: center;
}
.ab-play-one:hover { color: var(--text); border-color: var(--border-hover); }
.ab-play-one svg { width: 13px; height: 13px; }
.ab-play-one.busy { opacity: 0.5; pointer-events: none; }
/* subtle "audio ready" tint once a segment has been generated */
.ab-play-one.ready { background: rgba(245,158,11,0.16); border-color: var(--accent); color: var(--accent); }
.ab-play-one.ready:hover { background: var(--accent); color: var(--btn-text); }
.ab-row-status { font-size: 11px; font-weight: 600; color: var(--text-muted); min-width: 14px; }
.ab-row-status.done { color: #16a34a; }
.ab-row-status.error { color: #dc2626; }
.ab-row-status.active { color: var(--accent); }
.ab-voice-menu {
display: none; position: absolute; z-index: 60; background: var(--surface);
border: 1px solid var(--border-hover); border-radius: 10px; box-shadow: 0 8px 24px rgba(0,0,0,0.18);
padding: 6px; min-width: 180px; max-height: 260px; overflow-y: auto;
}
.ab-voice-menu.visible { display: block; }
.ab-voice-menu button {
display: flex; align-items: center; gap: 8px; width: 100%; text-align: left;
padding: 7px 9px; border: none; background: none; cursor: pointer; border-radius: 7px;
font-size: 13px; color: var(--text); font-family: 'Inter', sans-serif;
}
.ab-voice-menu button:hover { background: var(--surface2); }
.ab-voice-menu .ab-mav {
width: 22px; height: 22px; border-radius: 50%; flex: none; color: #fff; font-size: 11px;
font-weight: 700; display: flex; align-items: center; justify-content: center;
}
.gen-suggest {
display: none; align-items: center; gap: 12px; justify-content: space-between;
padding: 10px 14px; background: rgba(245,158,11,0.08);
border: 1px solid rgba(245,158,11,0.18); border-top: none;
}
.gen-suggest.visible { display: flex; }
.gen-suggest-text { font-size: 12px; color: var(--accent-hover); line-height: 1.4; }
.gen-suggest-btn {
flex: none; padding: 6px 14px; background: var(--accent); border: none; border-radius: 7px;
color: var(--btn-text); font-size: 12px; font-weight: 600; cursor: pointer;
font-family: 'Inter', sans-serif;
}
.gen-suggest-btn:hover { background: var(--accent-hover); }
.seg-stat { display: none; }
.seg-stat.visible { display: inline; }
/* Settings accordion */
.settings-accordion {
margin-bottom: 16px;
}
.settings-toggle {
display: flex; align-items: center; gap: 6px;
padding: 8px 0; font-size: 12px; font-weight: 500;
color: var(--text-muted); cursor: pointer; border: none; background: none;
font-family: 'Inter', sans-serif; transition: color 0.1s;
}
.settings-toggle:hover { color: var(--text-secondary); }
.settings-toggle svg { width: 14px; height: 14px; transition: transform 0.2s; }
.settings-toggle.open svg { transform: rotate(90deg); }
.settings-body { display: none; padding-top: 8px; }
.settings-body.open { display: block; }
.settings-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.setting-group { background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 14px 16px; }
.setting-label { font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.5px; color: var(--text-muted); margin-bottom: 8px; }
.setting-value { display: flex; align-items: center; gap: 10px; }
.setting-value input[type="range"] { flex: 1; accent-color: var(--accent); height: 4px; }
.setting-num { font-size: 13px; color: var(--text-secondary); min-width: 30px; text-align: right; font-variant-numeric: tabular-nums; }
/* Voice picker dropdown */
.voice-picker-dropdown {
position: absolute; top: 100%; left: 0; right: 0;
background: var(--surface); border: 1px solid var(--border);
border-radius: 10px; margin-top: 4px; z-index: 20;
box-shadow: 0 8px 24px rgba(0,0,0,0.4);
max-height: 240px; overflow-y: auto; display: none;
}
.voice-picker-dropdown.visible { display: block; }
.voice-picker-item {
display: flex; align-items: center; gap: 10px;
padding: 10px 14px; cursor: pointer; transition: background 0.1s;
border: none; background: none; width: 100%; text-align: left;
color: var(--text); font-family: 'Inter', sans-serif; font-size: 13px;
}
.voice-picker-item:hover { background: var(--surface2); }
.voice-picker-item .voice-avatar { width: 30px; height: 30px; font-size: 13px; }
.voice-picker-item:last-child { border-top: 1px solid var(--border); color: var(--accent); }
.voice-selector { position: relative; }
/* Generate */
.generate-bar { display: flex; gap: 12px; align-items: center; }
.btn-generate {
flex: 1; padding: 14px 24px;
background: linear-gradient(135deg, #fbbf24, var(--accent));
color: var(--btn-text); border: none; border-radius: 10px;
font-size: 14px; font-weight: 600; font-family: 'Inter', sans-serif;
cursor: pointer; transition: all 0.15s;
display: flex; align-items: center; justify-content: center; gap: 8px;
box-shadow: 0 4px 0 var(--btn-shadow), 0 6px 12px var(--shadow-color);
transform: translateY(0);
}
.btn-generate:hover { filter: brightness(1.05); transform: translateY(-2px); box-shadow: 0 6px 0 var(--btn-shadow), 0 8px 16px var(--shadow-color); }
.btn-generate:active { transform: translateY(2px); box-shadow: 0 1px 0 var(--btn-shadow), 0 2px 4px var(--shadow-color); }
.btn-generate:disabled { opacity: 0.4; cursor: not-allowed; transform: none; filter: none; box-shadow: none; }
.btn-generate .spinner { width: 16px; height: 16px; border: 2px solid rgba(0,0,0,0.2); border-top-color: var(--btn-text); border-radius: 50%; animation: spin 0.6s linear infinite; display: none; }
.btn-generate.loading .spinner { display: block; }
.btn-generate.loading .btn-text { display: none; }
@keyframes spin { to { transform: rotate(360deg); } }
/* Status */
.status-bar {
margin-top: 12px; padding: 10px 14px; border-radius: 8px;
font-size: 13px; display: none; gap: 8px; flex-direction: column;
}
.status-bar.visible { display: flex; }
.status-bar.visible.success { display: none; } /* hide "Generated in Xs" lines for now */
.status-bar.info { background: rgba(245,158,11,0.08); color: var(--accent-hover); border: 1px solid rgba(245,158,11,0.15); }
.status-bar.success { background: rgba(34,197,94,0.08); color: var(--success); border: 1px solid rgba(34,197,94,0.15); }
.status-bar.error { background: rgba(239,68,68,0.08); color: var(--danger); border: 1px solid rgba(239,68,68,0.15); }
.status-text { line-height: 1.4; }
.status-cta {
display: inline-flex; align-items: center; gap: 6px;
padding: 6px 14px; border-radius: 6px; font-size: 12px; font-weight: 600;
font-family: 'Inter', sans-serif; cursor: pointer; border: none;
transition: all 0.15s; margin-top: 4px; text-decoration: none; width: fit-content;
}
.status-cta.upgrade { background: #ff9d00; color: #000; }
.status-cta.upgrade:hover { background: #ffb340; }
.status-cta.credits { background: var(--accent); color: var(--btn-text); }
.status-cta.credits:hover { background: var(--accent-hover); }
.progress-track { width: 100%; height: 3px; background: var(--surface3); border-radius: 2px; margin-top: 6px; overflow: hidden; display: none; }
.progress-track.visible { display: block; }
.progress-fill { height: 100%; background: linear-gradient(90deg, var(--accent), #fcd34d); border-radius: 2px; transition: width 0.3s; width: 0%; }
/* Player */
.player-card { margin-top: 16px; background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 16px 20px; display: none; }
.player-card.visible { display: block; }
.player-top { display: flex; align-items: center; gap: 12px; margin-bottom: 12px; }
.play-btn {
width: 40px; height: 40px; border-radius: 50%; background: var(--accent);
border: none; color: var(--btn-text); cursor: pointer;
display: flex; align-items: center; justify-content: center; flex-shrink: 0; transition: all 0.15s;
}
.play-btn:hover { background: var(--accent-hover); transform: scale(1.05); }
.play-btn svg { width: 18px; height: 18px; }
.player-info { flex: 1; }
.player-title { font-size: 14px; font-weight: 500; }
.player-meta { font-size: 12px; color: var(--text-muted); }
.icon-btn {
width: 32px; height: 32px; border-radius: 6px; border: 1px solid var(--border);
background: transparent; color: var(--text-secondary); cursor: pointer;
display: flex; align-items: center; justify-content: center; transition: all 0.1s;
}
.icon-btn:hover { background: var(--surface2); color: var(--text); border-color: var(--border-hover); }
.player-audio { width: 100%; height: 32px; }
/* ── Voices Page ── */
.voices-grid {
display: grid;
grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
gap: 12px;
}
.voice-tile {
background: var(--surface);
border: 1px solid var(--border);
border-radius: 12px;
padding: 20px;
transition: all 0.15s;
cursor: default;
position: relative;
}
.voice-tile:hover { border-color: var(--border-hover); }
.voice-tile-avatar {
width: 48px; height: 48px; border-radius: 12px;
display: flex; align-items: center; justify-content: center;
font-size: 22px; font-weight: 700; color: white; margin-bottom: 12px;
}
.voice-tile-name { font-size: 15px; font-weight: 600; margin-bottom: 4px; }
.voice-tile-file { font-size: 12px; color: var(--text-muted); margin-bottom: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.voice-tile-actions { display: flex; gap: 6px; }
.voice-tile-btn {
padding: 6px 12px; border-radius: 6px; font-size: 12px; font-weight: 500;
font-family: 'Inter', sans-serif; cursor: pointer; border: none; transition: all 0.1s;
}
.voice-tile-btn.use { background: var(--accent); color: var(--btn-text); font-weight: 600; }
.voice-tile-btn.use:hover { background: var(--accent-hover); }
.voice-tile-btn.del { background: transparent; color: var(--text-muted); border: 1px solid var(--border); }
.voice-tile-btn.del:hover { color: var(--danger); border-color: var(--danger); }
.voice-tile-date {
position: absolute; top: 12px; right: 12px;
font-size: 10px; color: var(--text-muted);
}
.add-voice-tile {
background: transparent;
border: 2px dashed var(--border);
border-radius: 12px;
padding: 20px;
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
gap: 8px;
cursor: pointer;
color: var(--text-muted);
font-size: 13px;
transition: all 0.15s;
min-height: 160px;
}
.add-voice-tile:hover { border-color: var(--accent); color: var(--accent-hover); }
.add-voice-tile svg { opacity: 0.5; }
/* ── History ── */
.history-list { display: flex; flex-direction: column; gap: 8px; }
.history-item {
display: flex; align-items: center; gap: 14px;
padding: 14px 16px; background: var(--surface); border: 1px solid var(--border);
border-radius: 10px; transition: border-color 0.1s;
}
.history-item:hover { border-color: var(--border-hover); }
.history-play {
width: 36px; height: 36px; border-radius: 50%;
background: var(--surface3); border: 1px solid var(--border);
color: var(--text-secondary); cursor: pointer;
display: flex; align-items: center; justify-content: center;
flex-shrink: 0; transition: all 0.1s;
}
.history-play:hover { background: var(--accent); color: white; border-color: var(--accent); }
.history-play svg { width: 14px; height: 14px; }
.history-info { flex: 1; min-width: 0; }
.history-text { font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.history-sub { font-size: 11px; color: var(--text-muted); margin-top: 2px; }
.history-download {
padding: 6px 12px; border-radius: 6px; border: 1px solid var(--border);
background: transparent; color: var(--text-secondary); font-size: 12px;
cursor: pointer; font-family: 'Inter', sans-serif; transition: all 0.1s;
}
.history-download:hover { background: var(--surface2); color: var(--text); }
.empty-state { text-align: center; padding: 60px 20px; color: var(--text-muted); font-size: 14px; }
.empty-state-icon { font-size: 40px; margin-bottom: 12px; opacity: 0.5; }
/* ── API ── */
.api-tabs { display: flex; gap: 2px; background: var(--surface2); border-radius: 8px; padding: 3px; margin-bottom: 16px; }
.api-tab {
padding: 7px 16px; border-radius: 6px; font-size: 13px; cursor: pointer;
color: var(--text-muted); background: transparent; border: none;
font-family: 'Inter', sans-serif; font-weight: 500; transition: all 0.1s;
}
.api-tab.active { background: var(--surface3); color: var(--text); }
.api-tab:hover { color: var(--text-secondary); }
.code-block { position: relative; }
.code-block pre {
background: var(--surface); border: 1px solid var(--border); border-radius: 10px;
padding: 20px; overflow-x: auto; font-size: 13px; line-height: 1.6;
font-family: 'JetBrains Mono', 'Fira Code', monospace;
}
pre {
background: var(--surface); border: 1px solid var(--border); border-radius: 10px;
padding: 20px; overflow-x: auto; font-size: 13px; line-height: 1.6;
font-family: 'JetBrains Mono', 'Fira Code', monospace;
}
.copy-btn {
position: absolute; top: 8px; right: 8px;
padding: 5px 10px; border-radius: 6px; font-size: 11px; font-weight: 500;
font-family: 'Inter', sans-serif; cursor: pointer; border: 1px solid var(--border);
background: var(--surface2); color: var(--text-muted); transition: all 0.15s;
display: flex; align-items: center; gap: 4px;
}
.copy-btn:hover { background: var(--surface3); color: var(--text); border-color: var(--border-hover); }
.copy-btn.copied { background: rgba(34,197,94,0.15); color: var(--success); border-color: rgba(34,197,94,0.3); }
.agent-tip {
margin-top: 20px; padding: 16px; background: var(--accent-subtle);
border: 1px solid rgba(245,158,11,0.2); border-radius: 10px;
font-size: 13px; color: var(--text-secondary); line-height: 1.5;
}
.agent-tip strong { color: var(--accent-hover); }
/* ── Voice Design ── */
.design-textarea {
width: 100%; min-height: 80px; background: var(--surface2);
border: 1px solid var(--border); border-radius: 8px; padding: 12px;
color: var(--text); font-family: 'Inter', sans-serif; font-size: 14px;
resize: vertical; line-height: 1.5;
}
.design-textarea:focus { outline: none; border-color: var(--accent); }
.design-textarea::placeholder { color: var(--text-muted); }
.design-field { margin-bottom: 16px; }
.design-label { font-size: 12px; font-weight: 500; color: var(--text-secondary); margin-bottom: 6px; }
/* ── Preset voice tiles ── */
.preset-section-title {
font-size: 13px; font-weight: 600; color: var(--text-muted);
text-transform: uppercase; letter-spacing: 0.5px; margin-bottom: 12px;
padding-bottom: 8px; border-bottom: 1px solid var(--border);
}
.voices-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.voices-head-add {
font-family: 'Inter', sans-serif; font-size: 11px; font-weight: 600;
text-transform: none; letter-spacing: 0; color: var(--accent);
background: none; border: none; cursor: pointer; padding: 0;
}
.voices-head-add:hover { color: var(--accent-hover); text-decoration: underline; }
.preset-tile {
background: var(--surface); border: 1px solid var(--border); border-radius: 12px;
padding: 16px; transition: all 0.15s; cursor: default; position: relative;
display: flex; align-items: center; gap: 14px;
}
.preset-tile:hover { border-color: var(--border-hover); }
.preset-tile-avatar {
width: 44px; height: 44px; border-radius: 10px;
display: flex; align-items: center; justify-content: center;
font-size: 18px; font-weight: 700; color: white; flex-shrink: 0;
background: linear-gradient(135deg, #d97706, #f59e0b);
}
.preset-tile-info { flex: 1; min-width: 0; }
.preset-tile-name { font-size: 14px; font-weight: 600; margin-bottom: 2px; }
.preset-tile-tag { font-size: 11px; color: var(--text-muted); }
.preset-tile-actions { display: flex; gap: 6px; align-items: center; }
.preview-btn {
width: 32px; height: 32px; border-radius: 50%;
background: var(--surface3); border: 1px solid var(--border);
color: var(--text-secondary); cursor: pointer;
display: flex; align-items: center; justify-content: center;
transition: all 0.1s; flex-shrink: 0;
}
.preview-btn:hover { background: var(--accent); color: var(--btn-text); border-color: var(--accent); }
.preview-btn svg { width: 12px; height: 12px; }
/* ── Theme toggle ── */
.theme-btn {
width: 32px; height: 32px; border-radius: 8px; border: 1px solid var(--border);
background: var(--surface2); color: var(--text-muted); cursor: pointer;
display: flex; align-items: center; justify-content: center; transition: all 0.1s;
}
.theme-btn:hover { color: var(--text); border-color: var(--border-hover); }
.theme-btn svg { width: 16px; height: 16px; }
.footer {
text-align: center; padding: 32px 0 16px; font-size: 12px; color: var(--text-muted);
}
.footer a { color: var(--text-secondary); text-decoration: none; }
.footer a:hover { color: var(--accent); }
.cm { color: var(--text-muted); }
[data-theme="dark"] .s { color: #86efac; }
[data-theme="dark"] .k { color: #fcd34d; }
[data-theme="dark"] .f { color: #93c5fd; }
[data-theme="light"] .s { color: #166534; }
[data-theme="light"] .k { color: #92400e; }
[data-theme="light"] .f { color: #1e40af; }
/* ── Modal ── */
.modal-overlay {
position: fixed; inset: 0; background: rgba(0,0,0,0.6);
backdrop-filter: blur(4px); display: none; align-items: center;
justify-content: center; z-index: 100;
}
.modal-overlay.visible { display: flex; }
.modal {
background: var(--surface); border: 1px solid var(--border);
border-radius: 16px; padding: 28px; width: 440px; max-width: 90vw;
}
.modal-title { font-size: 17px; font-weight: 600; margin-bottom: 6px; }
.modal-desc { font-size: 13px; color: var(--text-muted); margin-bottom: 20px; }
.modal-field { margin-bottom: 16px; }
.modal-field label { display: block; font-size: 12px; font-weight: 500; color: var(--text-secondary); margin-bottom: 6px; }
.modal-field input[type="text"] {
width: 100%; padding: 10px 12px; background: var(--surface2);
border: 1px solid var(--border); border-radius: 8px; color: var(--text);
font-family: 'Inter', sans-serif; font-size: 14px;
}
.modal-field input:focus { outline: none; border-color: var(--accent); }
.upload-area {
border: 2px dashed var(--border); border-radius: 10px; padding: 28px;
text-align: center; cursor: pointer; transition: all 0.15s;
color: var(--text-muted); font-size: 13px;
}
.upload-area:hover { border-color: var(--accent); color: var(--text-secondary); }
.upload-area.has-file { border-color: var(--success); border-style: solid; color: var(--success); }
.upload-area input { display: none; }
.upload-area-sub { font-size: 11px; margin-top: 4px; opacity: 0.7; }
.modal-actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 20px; }
.btn-modal { padding: 9px 20px; border-radius: 8px; font-size: 13px; font-weight: 500; font-family: 'Inter', sans-serif; cursor: pointer; transition: all 0.1s; border: none; }
.btn-cancel { background: var(--surface2); color: var(--text-secondary); border: 1px solid var(--border); }
.btn-cancel:hover { background: var(--surface3); color: var(--text); }
.btn-save { background: var(--accent); color: var(--btn-text); font-weight: 600; }
.btn-save:hover { background: var(--accent-hover); }
.btn-save:disabled { opacity: 0.4; cursor: not-allowed; }
/* ── Landing ── */
#landing {
display: flex; flex-direction: column; align-items: center; justify-content: center;
min-height: 100vh; text-align: center; gap: 20px;
background: radial-gradient(ellipse at 50% 0%, var(--accent-glow) 0%, transparent 60%);
}
#landing h1 {
font-size: 52px; font-weight: 700; letter-spacing: -1.5px;
background: linear-gradient(135deg, var(--text) 0%, var(--text-secondary) 100%);
-webkit-background-clip: text; -webkit-text-fill-color: transparent;
}
#landing .tagline { font-size: 22px; font-weight: 600; letter-spacing: -0.3px; color: var(--text); max-width: 560px; line-height: 1.35; margin-top: -8px; }
#landing .subtitle { color: var(--text-muted); font-size: 17px; max-width: 420px; line-height: 1.5; }
.btn-hf {
padding: 13px 32px; background: #ff9d00; color: #000; border: none; border-radius: 10px;
font-size: 15px; font-weight: 600; font-family: 'Inter', sans-serif; cursor: pointer;
display: inline-flex; align-items: center; gap: 8px; transition: all 0.15s;
box-shadow: 0 4px 0 var(--btn-shadow-hf), 0 6px 12px var(--shadow-color);
}
.btn-hf:hover { background: #ffb340; transform: translateY(-2px); box-shadow: 0 6px 0 var(--btn-shadow-hf), 0 8px 16px var(--shadow-color); }
.btn-hf:active { transform: translateY(2px); box-shadow: 0 1px 0 var(--btn-shadow-hf), 0 2px 4px var(--shadow-color); }
.landing-note { font-size: 12px; color: var(--text-muted); }
.btn-hf-sm {
padding: 7px 16px; font-size: 13px; border-radius: 8px;
box-shadow: 0 3px 0 var(--btn-shadow-hf), 0 4px 8px var(--shadow-color);
}
.btn-hf-sm:hover { box-shadow: 0 4px 0 var(--btn-shadow-hf), 0 6px 12px var(--shadow-color); }
.btn-hf-sm:active { box-shadow: 0 1px 0 var(--btn-shadow-hf), 0 2px 4px var(--shadow-color); }
.guest-cta {
padding: 12px; margin: 0 12px 12px;
background: var(--surface2); border: 1px solid var(--border); border-radius: 10px;
}
.guest-cta-title { font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.5px; color: var(--text-muted); margin-bottom: 4px; }
.guest-cta-sub { font-size: 11px; color: var(--text-secondary); line-height: 1.4; margin-bottom: 10px; }
.guest-cta-btn { width: 100%; justify-content: center; }
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--border-hover); }
@media (max-width: 768px) {
.app-layout { grid-template-columns: 1fr; }
.sidebar { display: none; }
#landing h1 { font-size: 36px; }
.voices-grid { grid-template-columns: 1fr; }
}
.audio-source-tabs { display: flex; gap: 4px; background: var(--surface2); padding: 3px; border-radius: 8px; margin-bottom: 8px; }
.audio-source-tab {
flex: 1; display: inline-flex; align-items: center; justify-content: center; gap: 6px;
padding: 7px 10px; border: none; background: transparent; color: var(--text-muted);
font-family: 'Inter', sans-serif; font-size: 12.5px; font-weight: 500; border-radius: 6px; cursor: pointer; transition: all 0.1s;
}
.audio-source-tab.active { background: var(--surface); color: var(--text); box-shadow: 0 1px 2px var(--shadow-color); }
.audio-source-tab:hover:not(.active) { color: var(--text); }
.audio-source-tab svg { width: 14px; height: 14px; flex-shrink: 0; }
.record-pane { display: flex; align-items: center; gap: 14px; padding: 18px; border: 1px dashed var(--border); border-radius: 10px; background: var(--surface); }
.record-mic-btn {
width: 52px; height: 52px; border-radius: 50%; border: none; cursor: pointer;
background: #ef4444; color: #fff; display: flex; align-items: center; justify-content: center;
flex-shrink: 0; transition: all 0.15s; box-shadow: 0 2px 6px rgba(239, 68, 68, 0.3);
}
.record-mic-btn:hover { transform: scale(1.05); box-shadow: 0 4px 10px rgba(239, 68, 68, 0.45); }
.record-mic-btn svg { width: 22px; height: 22px; }
.record-mic-btn.recording { background: var(--text); box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.6); animation: recPulse 1.4s infinite; }
.record-mic-btn.recording svg { display: none; }
.record-mic-btn.recording::after { content: ""; width: 14px; height: 14px; background: #ef4444; border-radius: 2px; }
@keyframes recPulse { 0% { box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.55); } 70% { box-shadow: 0 0 0 14px rgba(239, 68, 68, 0); } 100% { box-shadow: 0 0 0 0 rgba(239, 68, 68, 0); } }
.record-timer { font-size: 18px; font-weight: 600; color: var(--text); font-variant-numeric: tabular-nums; }
.record-hint { font-size: 12px; color: var(--text-muted); margin-top: 2px; }
.lib-list { display: flex; flex-direction: column; gap: 2px; padding: 6px; background: var(--surface); border: 1px solid var(--border); border-radius: 10px; max-height: 320px; overflow-y: auto; }
.lib-item { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 8px; cursor: pointer; transition: background 0.1s; border: 1px solid transparent; }
.lib-item:hover { background: var(--surface2); }
.lib-item.selected { background: var(--surface2); border-color: var(--border-hover); }
.lib-item .voice-avatar { width: 32px; height: 32px; border-radius: 8px; font-size: 14px; }
.lib-item-meta { display: flex; flex-direction: column; min-width: 0; }
.lib-item-name { font-size: 13px; font-weight: 500; color: var(--text); }
.lib-item-tag { font-size: 11px; color: var(--text-muted); }
.lib-empty { padding: 24px 12px; text-align: center; color: var(--text-muted); font-size: 13px; }
</style>
</head>
<body>
<script>
// Theme: auto (system), dark, light — runs before paint to avoid flash
(function() {
const saved = localStorage.getItem("zl_theme");
function getEffective(pref) {
if (pref === "light" || pref === "dark") return pref;
return window.matchMedia("(prefers-color-scheme: light)").matches ? "light" : "dark";
}
const effective = getEffective(saved || "auto");
document.documentElement.setAttribute("data-theme", effective);
window._themePref = saved || "auto"; // auto, dark, light
window.cycleTheme = function() {
const order = ["auto", "light", "dark"];
const idx = order.indexOf(window._themePref);
window._themePref = order[(idx + 1) % 3];
localStorage.setItem("zl_theme", window._themePref);
const eff = getEffective(window._themePref);
document.documentElement.setAttribute("data-theme", eff);
updateThemeIcons(eff);
};
window.updateThemeIcons = function(eff) {
const sun = '<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><circle cx="12" cy="12" r="5"/><path d="M12 1v2M12 21v2M4.22 4.22l1.42 1.42M18.36 18.36l1.42 1.42M1 12h2M21 12h2M4.22 19.78l1.42-1.42M18.36 5.64l1.42-1.42"/></svg>';
const moon = '<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><path d="M21 12.79A9 9 0 1 1 11.21 3 7 7 0 0 0 21 12.79z"/></svg>';
const auto = '<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><circle cx="12" cy="12" r="10"/><path d="M12 2a10 10 0 0 1 0 20V2z" fill="currentColor"/></svg>';
const icon = window._themePref === "auto" ? auto : eff === "dark" ? moon : sun;
document.querySelectorAll(".theme-btn").forEach(b => b.innerHTML = icon);
};
// Listen for system theme changes when in auto mode
window.matchMedia("(prefers-color-scheme: light)").addEventListener("change", () => {
if (window._themePref === "auto") {
const eff = getEffective("auto");
document.documentElement.setAttribute("data-theme", eff);
updateThemeIcons(eff);
}
});
// Update icons after DOM loads
document.addEventListener("DOMContentLoaded", () => updateThemeIcons(effective));
})();
</script>
<div id="landing" style="display:none">
<div class="logo-icon" style="width:56px;height:56px;font-size:28px;border-radius:14px">0</div>
<h1>ZeroLabs</h1>
<p class="tagline">Open-source audio AI has caught up. See for yourself.</p>
<p class="subtitle">Voice cloning, design, and conversion, audio cleanup, sound effects, and transcription. Powered by open-source models. Generous free tier, then 100x cheaper than proprietary.</p>
<button class="btn-hf" onclick="login()">🤗 Sign in with Hugging Face</button>
<p class="landing-note">Uses your HF ZeroGPU quota · Free tier included</p>
<button class="theme-btn" onclick="cycleTheme()" title="Toggle theme" style="position:fixed;top:16px;right:16px">
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><circle cx="12" cy="12" r="5"/><path d="M12 1v2M12 21v2M4.22 4.22l1.42 1.42M18.36 18.36l1.42 1.42M1 12h2M21 12h2M4.22 19.78l1.42-1.42M18.36 5.64l1.42-1.42"/></svg>
</button>
</div>
<div id="app" class="app-layout" style="display:none">
<div class="header">
<div class="logo">
<div class="logo-icon">0</div>
ZeroLabs
</div>
<div class="header-right">
<button class="theme-btn" onclick="cycleTheme()" title="Toggle theme" id="theme-btn-app">
<svg id="theme-icon-app" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><circle cx="12" cy="12" r="5"/><path d="M12 1v2M12 21v2M4.22 4.22l1.42 1.42M18.36 18.36l1.42 1.42M1 12h2M21 12h2M4.22 19.78l1.42-1.42M18.36 5.64l1.42-1.42"/></svg>
</button>
<button class="btn-hf btn-hf-sm" id="header-signin" onclick="login()" style="display:none">🤗 Sign in</button>
<div class="user-pill" id="user-pill" onclick="toggleUserMenu(event)">
<img id="user-avatar" src="" alt="">
<span id="user-name"></span>
<div class="user-menu" id="user-menu">
<button class="user-menu-item" type="button" onclick="event.stopPropagation();logout()">
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M9 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h4"/><polyline points="16 17 21 12 16 7"/><line x1="21" y1="12" x2="9" y2="12"/></svg>
Log out
</button>
</div>
</div>
</div>
</div>
<div class="sidebar">
<div class="sidebar-section">
<div class="sidebar-label">Create</div>
<button class="nav-item active" data-page="synthesis" onclick="showPage('synthesis', this)">
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><path d="M12 2a3 3 0 0 0-3 3v7a3 3 0 0 0 6 0V5a3 3 0 0 0-3-3Z"/><path d="M19 10v2a7 7 0 0 1-14 0v-2"/><line x1="12" y1="19" x2="12" y2="22"/></svg>
Voice Generation
</button>
<button class="nav-item" data-page="design" onclick="showPage('design', this)">
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><path d="M12 20h9"/><path d="M16.5 3.5a2.121 2.121 0 0 1 3 3L7 19l-4 1 1-4L16.5 3.5z"/></svg>
Voice Design
</button>
<button class="nav-item" data-page="changer" onclick="showPage('changer', this)">
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><circle cx="6" cy="9" r="2.5"/><path d="M3 17a3 3 0 0 1 3-3"/><circle cx="18" cy="9" r="2.5"/><path d="M21 17a3 3 0 0 0-3-3"/><path d="M8 19h8"/><polyline points="14 17 16 19 14 21"/><polyline points="10 17 8 19 10 21"/></svg>
Voice Changer
</button>
<button class="nav-item" data-page="isolate" onclick="showPage('isolate', this)">
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><line x1="12" y1="8" x2="12" y2="16"/><line x1="9" y1="10" x2="9" y2="14"/><line x1="15" y1="10" x2="15" y2="14"/><path d="M6 6c-3 3-3 9 0 12"/><path d="M18 6c3 3 3 9 0 12"/></svg>
Voice Cleaner
</button>
<button class="nav-item" data-page="sfx" onclick="showPage('sfx', this)">
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M12 3 C 12 8 13 11 21 12 C 13 13 12 16 12 21 C 12 16 11 13 3 12 C 11 11 12 8 12 3 Z"/></svg>
Sound Effects
</button>
<button class="nav-item" data-page="transcribe" onclick="showPage('transcribe', this)">
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><path d="M4 7V4h16v3"/><path d="M9 20h6"/><path d="M12 4v16"/></svg>
Transcribe
</button>
</div>
<div class="sidebar-section">
<div class="sidebar-label">Library</div>
<button class="nav-item" data-page="voices" onclick="showPage('voices', this)">
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><path d="M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2"/><circle cx="9" cy="7" r="4"/><path d="M22 21v-2a4 4 0 0 0-3-3.87"/><path d="M16 3.13a4 4 0 0 1 0 7.75"/></svg>
Voice Library
</button>
</div>
<div class="sidebar-voices" id="voice-list"></div>
<div class="sidebar-section">
<div class="sidebar-label">More</div>
<button class="nav-item" data-page="history" onclick="showPage('history', this)">
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><circle cx="12" cy="12" r="10"/><polyline points="12 6 12 12 16 14"/></svg>
History
</button>
<button class="nav-item" data-page="api" onclick="showPage('api', this)">
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><polyline points="16 18 22 12 16 6"/><polyline points="8 6 2 12 8 18"/></svg>
API
</button>
</div>
<!-- Guest CTA (shown when logged out) -->
<div class="guest-cta" id="guest-cta" style="display:none">
<div class="guest-cta-title">You're in guest mode</div>
<div class="guest-cta-sub">3 signed-out free runs. Sign in with Hugging Face to keep using it free for longer.</div>
<button class="btn-hf btn-hf-sm guest-cta-btn" onclick="login()">🤗 Sign in with Hugging Face</button>
</div>
<!-- Usage Tracker -->
<div class="usage-tracker" id="usage-tracker">
<div class="usage-header">
<span class="usage-label">ZeroGPU Quota</span>
<span class="usage-value" id="usage-value">—</span>
</div>
<div class="usage-bar"><div class="usage-fill" id="usage-fill" style="width:0%"></div></div>
<div class="usage-sub" id="usage-sub">Loading…</div>
</div>
</div>
<div class="content">
<div class="content-inner">
<!-- Synthesis Page -->
<div class="page active" id="page-synthesis">
<div class="page-header">
<div class="page-title">Speech Synthesis</div>
<div class="page-desc">Select a voice and type your text to generate speech. Powered by OmniVoice.</div>
<button class="page-api-toggle" type="button" onclick="togglePageApi('synthesis', this)">
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><polyline points="16 18 22 12 16 6"/><polyline points="8 6 2 12 8 18"/></svg>
<span class="page-api-label">View API</span>
</button>
</div>
<div class="voice-selector" id="voice-selector" onclick="toggleVoicePicker(event)">
<div class="voice-avatar" id="sel-voice-avatar" style="background:var(--surface3)">🎤</div>
<div class="voice-selector-info">
<div class="voice-selector-name" id="sel-voice-name">No voice selected</div>
<div class="voice-selector-hint" id="sel-voice-hint">Click to select or add a voice</div>
</div>
<div class="voice-selector-change">
<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><polyline points="6 9 12 15 18 9"/></svg>
</div>
<div class="voice-picker-dropdown" id="voice-picker"></div>
</div>
<div class="gen-editor">
<div class="ab-doc simple" id="gen-doc"></div>
<div class="gen-suggest" id="gen-suggest">
<span class="gen-suggest-text">That's a long passage. Split it into segments for better quality output.</span>
<button type="button" class="gen-suggest-btn" onclick="abBreakDown()">Break it down</button>
</div>
<div class="editor-footer">
<div class="editor-left">
<span class="editor-stat"><span id="char-count">0</span> chars</span>
<span class="editor-stat seg-stat" id="seg-stat"><span id="seg-count">1</span> segments</span>
<select class="lang-select" id="lang-select">
<option value="Auto">Language (Auto)</option>
<option value="English">English</option>
<option value="Chinese">Chinese</option>
<option value="French">French</option>
<option value="German">German</option>
<option value="Spanish">Spanish</option>
<option value="Japanese">Japanese</option>
<option value="Korean">Korean</option>
<option value="Portuguese">Portuguese</option>
<option value="Italian">Italian</option>
<option value="Russian">Russian</option>
<option value="Arabic">Arabic</option>
<option value="Hindi">Hindi</option>
</select>
</div>
</div>
<div class="ab-voice-menu" id="gen-voice-menu"></div>
</div>
<div class="settings-accordion">
<button class="settings-toggle" onclick="this.classList.toggle('open');this.nextElementSibling.classList.toggle('open')">
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><polyline points="9 18 15 12 9 6"/></svg>
Advanced Settings
</button>
<div class="settings-body">
<div class="settings-row">
<div class="setting-group">
<div class="setting-label">Inference Steps</div>
<div class="setting-value">
<input type="range" id="setting-steps" min="4" max="64" value="32">
<span class="setting-num" id="steps-val">32</span>
</div>
</div>
<div class="setting-group">
<div class="setting-label">Speed</div>
<div class="setting-value">
<input type="range" id="setting-speed" min="50" max="150" value="100">
<span class="setting-num" id="speed-val">1.0x</span>
</div>
</div>
</div>
</div>
</div>
<div class="generate-bar">
<button class="btn-generate" id="generate-btn" onclick="generate()" disabled>
<span class="btn-text">Generate Speech</span>
<div class="spinner"></div>
</button>
</div>
<div class="status-bar" id="status"></div>
<div class="progress-track" id="progress-bar"><div class="progress-fill" id="progress-fill"></div></div>
<div class="player-card" id="result">
<div class="player-top">
<button class="play-btn" onclick="togglePlay()">
<svg id="play-icon" viewBox="0 0 24 24" fill="currentColor"><polygon points="5 3 19 12 5 21 5 3"/></svg>
<svg id="pause-icon" viewBox="0 0 24 24" fill="currentColor" style="display:none"><rect x="6" y="4" width="4" height="16"/><rect x="14" y="4" width="4" height="16"/></svg>
</button>
<div class="player-info">
<div class="player-title" id="player-title">Generated audio</div>
<div class="player-meta" id="player-meta"></div>
</div>
<div style="display:flex;gap:6px">
<button class="icon-btn" onclick="downloadAudio()" title="Download">
<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><path d="M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4"/><polyline points="7 10 12 15 17 10"/><line x1="12" y1="15" x2="12" y2="3"/></svg>
</button>
</div>
</div>
<audio id="audio-player" class="player-audio"></audio>
</div>
</div>
<!-- Voice Design Page -->
<div class="page" id="page-design">
<div class="page-header">
<div class="page-title">Voice Design</div>
<div class="page-desc">Describe how you want the voice to sound. Powered by Qwen3-TTS.</div>
<button class="page-api-toggle" type="button" onclick="togglePageApi('design', this)">
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><polyline points="16 18 22 12 16 6"/><polyline points="8 6 2 12 8 18"/></svg>
<span class="page-api-label">View API</span>
</button>
</div>
<div class="editor">
<textarea id="design-text" placeholder="Start typing the text you want to synthesize..."></textarea>
<div class="editor-footer">
<div class="editor-left">
<span class="editor-stat"><span id="design-char-count">0</span> chars</span>
<select class="lang-select" id="design-lang">
<option value="Auto">Language (Auto)</option>
<option value="English">English</option>
<option value="Chinese">Chinese</option>
<option value="Japanese">Japanese</option>
<option value="Korean">Korean</option>
<option value="French">French</option>
<option value="German">German</option>
<option value="Spanish">Spanish</option>
<option value="Portuguese">Portuguese</option>
<option value="Russian">Russian</option>
</select>
</div>
</div>
</div>
<div class="design-field">
<div class="design-label">Voice Description</div>
<textarea class="design-textarea" id="design-voice-desc" placeholder="e.g. Speak in a warm, friendly tone with slight excitement and a deep male voice..."></textarea>
</div>
<div class="generate-bar">
<button class="btn-generate" id="design-generate-btn" onclick="generateDesign()" disabled>
<span class="btn-text">Generate Speech</span>
<div class="spinner"></div>
</button>
</div>
<div class="status-bar" id="design-status"></div>
<div class="progress-track" id="design-progress-bar"><div class="progress-fill" id="design-progress-fill"></div></div>
<div class="player-card" id="design-result">
<div class="player-top">
<button class="play-btn" onclick="toggleDesignPlay()">
<svg id="design-play-icon" viewBox="0 0 24 24" fill="currentColor"><polygon points="5 3 19 12 5 21 5 3"/></svg>
<svg id="design-pause-icon" viewBox="0 0 24 24" fill="currentColor" style="display:none"><rect x="6" y="4" width="4" height="16"/><rect x="14" y="4" width="4" height="16"/></svg>
</button>
<div class="player-info">
<div class="player-title" id="design-player-title">Generated audio</div>
<div class="player-meta" id="design-player-meta"></div>
</div>
<div style="display:flex;gap:6px">
<button class="icon-btn" onclick="downloadDesignAudio()" title="Download">
<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><path d="M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4"/><polyline points="7 10 12 15 17 10"/><line x1="12" y1="15" x2="12" y2="3"/></svg>
</button>
<button class="voice-tile-btn use" onclick="saveDesignVoice()" id="save-design-voice-btn" title="Save to Voice Library" style="font-size:12px;padding:6px 12px">
Save Voice
</button>
</div>
</div>
<audio id="design-audio-player" class="player-audio"></audio>
</div>
</div>
<!-- Voice Changer Page -->
<div class="page" id="page-changer">
<div class="page-header">
<div class="page-title">Voice Changer</div>
<div class="page-desc">Transform speech into any target voice. Powered by Seed-VC.</div>
<button class="page-api-toggle" type="button" onclick="togglePageApi('changer', this)">
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><polyline points="16 18 22 12 16 6"/><polyline points="8 6 2 12 8 18"/></svg>
<span class="page-api-label">View API</span>
</button>
</div>
<div class="setting-label" style="margin-bottom:8px">Source audio</div>
<div class="upload-area" id="vc-source-upload" style="margin-bottom:16px">
<div id="vc-source-label">Drop source audio or click to upload<div class="upload-area-sub">The speech you want to convert</div></div>
<input type="file" id="vc-source-input" accept="audio/*">
</div>
<div class="setting-label" style="margin-bottom:8px">Target voice</div>
<div class="upload-area" id="vc-target-upload" style="margin-bottom:16px">
<div id="vc-target-label">Drop target voice or click to upload<div class="upload-area-sub">Short clip of the voice to convert to</div></div>
<input type="file" id="vc-target-input" accept="audio/*">
</div>
<div class="settings-accordion">
<button class="settings-toggle" onclick="this.classList.toggle('open');this.nextElementSibling.classList.toggle('open')">
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><polyline points="9 18 15 12 9 6"/></svg>
Advanced Settings
</button>
<div class="settings-body">
<div class="settings-row">
<div class="setting-group">
<div class="setting-label">Diffusion Steps</div>
<div class="setting-value">
<input type="range" id="vc-steps" min="4" max="50" value="10">
<span class="setting-num" id="vc-steps-val">10</span>
</div>
</div>
<div class="setting-group">
<div class="setting-label">Similarity</div>
<div class="setting-value">
<input type="range" id="vc-sim" min="0" max="100" value="70">
<span class="setting-num" id="vc-sim-val">0.7</span>
</div>
</div>
</div>
</div>
</div>
<div class="generate-bar">
<button class="btn-generate" id="vc-btn" onclick="voiceChange()" disabled>
<span class="btn-text">Convert Voice</span>
<div class="spinner"></div>
</button>
</div>
<div class="status-bar" id="vc-status"></div>
<div class="progress-track" id="vc-progress-bar"><div class="progress-fill" id="vc-progress-fill"></div></div>
<div class="player-card" id="vc-result">
<div class="player-top">
<button class="play-btn" onclick="togglePlayer('vc')">
<svg id="vc-play-icon" viewBox="0 0 24 24" fill="currentColor"><polygon points="5 3 19 12 5 21 5 3"/></svg>
<svg id="vc-pause-icon" viewBox="0 0 24 24" fill="currentColor" style="display:none"><rect x="6" y="4" width="4" height="16"/><rect x="14" y="4" width="4" height="16"/></svg>
</button>
<div class="player-info">
<div class="player-title" id="vc-player-title">Converted audio</div>
<div class="player-meta" id="vc-player-meta"></div>
</div>
<div style="display:flex;gap:6px">
<button class="icon-btn" onclick="downloadResult('vc')" title="Download">
<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><path d="M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4"/><polyline points="7 10 12 15 17 10"/><line x1="12" y1="15" x2="12" y2="3"/></svg>
</button>
</div>
</div>
<audio id="vc-audio-player" class="player-audio"></audio>
</div>
</div>
<!-- Voice Cleaner Page -->
<div class="page" id="page-isolate">
<div class="page-header">
<div class="page-title">Voice Cleaner</div>
<div class="page-desc">Strip background noise from speech and optionally restore clarity. Powered by Resemble Enhance.</div>
<button class="page-api-toggle" type="button" onclick="togglePageApi('isolate', this)">
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><polyline points="16 18 22 12 16 6"/><polyline points="8 6 2 12 8 18"/></svg>
<span class="page-api-label">View API</span>
</button>
</div>
<div class="upload-area" id="iso-upload" style="margin-bottom:16px">
<div id="iso-upload-label">Drop noisy audio or click to upload<div class="upload-area-sub">MP3, WAV, FLAC, M4A · speech with background noise</div></div>
<input type="file" id="iso-file-input" accept="audio/*">
</div>
<div class="audio-source-tabs" style="margin-bottom:16px" id="iso-mode-tabs">
<button class="audio-source-tab active" data-iso-mode="enhance" type="button" onclick="setIsoMode('enhance')">Remove noise & enhance</button>
<button class="audio-source-tab" data-iso-mode="denoise" type="button" onclick="setIsoMode('denoise')">Remove noise</button>
</div>
<div class="settings-accordion">
<button class="settings-toggle" onclick="this.classList.toggle('open');this.nextElementSibling.classList.toggle('open')">
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><polyline points="9 18 15 12 9 6"/></svg>
Advanced Settings
</button>
<div class="settings-body">
<div class="settings-row">
<div class="setting-group">
<div class="setting-label">NFE Steps</div>
<div class="setting-value">
<input type="range" id="iso-nfe" min="1" max="128" value="64">
<span class="setting-num" id="iso-nfe-val">64</span>
</div>
</div>
<div class="setting-group">
<div class="setting-label">Prior Tau</div>
<div class="setting-value">
<input type="range" id="iso-tau" min="1" max="100" value="50">
<span class="setting-num" id="iso-tau-val">0.5</span>
</div>
</div>
</div>
</div>
</div>
<div class="generate-bar">
<button class="btn-generate" id="iso-btn" onclick="voiceIsolate()" disabled>
<span class="btn-text">Clean Audio</span>
<div class="spinner"></div>
</button>
</div>
<div class="status-bar" id="iso-status"></div>
<div class="progress-track" id="iso-progress-bar"><div class="progress-fill" id="iso-progress-fill"></div></div>
<div class="player-card" id="iso-result">
<div class="player-top">
<button class="play-btn" onclick="togglePlayer('iso')">
<svg id="iso-play-icon" viewBox="0 0 24 24" fill="currentColor"><polygon points="5 3 19 12 5 21 5 3"/></svg>
<svg id="iso-pause-icon" viewBox="0 0 24 24" fill="currentColor" style="display:none"><rect x="6" y="4" width="4" height="16"/><rect x="14" y="4" width="4" height="16"/></svg>
</button>
<div class="player-info">
<div class="player-title" id="iso-player-title">Enhanced audio</div>
<div class="player-meta" id="iso-player-meta"></div>
</div>
<div style="display:flex;gap:6px">
<button class="icon-btn" onclick="downloadResult('iso')" title="Download">
<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><path d="M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4"/><polyline points="7 10 12 15 17 10"/><line x1="12" y1="15" x2="12" y2="3"/></svg>
</button>
</div>
</div>
<audio id="iso-audio-player" class="player-audio"></audio>
</div>
</div>
<!-- Sound Effects Page -->
<div class="page" id="page-sfx">
<div class="page-header">
<div class="page-title">Sound Effects</div>
<div class="page-desc">Generate sound effects from a text prompt. Powered by Stable Audio 3.</div>
<button class="page-api-toggle" type="button" onclick="togglePageApi('sfx', this)">
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><polyline points="16 18 22 12 16 6"/><polyline points="8 6 2 12 8 18"/></svg>
<span class="page-api-label">View API</span>
</button>
</div>
<div class="editor">
<textarea id="sfx-prompt" placeholder="e.g. dog barking, thunder cracking, footsteps on gravel, lo-fi vinyl crackle..."></textarea>
<div class="editor-footer">
<div class="editor-left">
<span class="editor-stat"><span id="sfx-char-count">0</span> chars</span>
</div>
</div>
</div>
<div class="settings-accordion">
<button class="settings-toggle" onclick="this.classList.toggle('open');this.nextElementSibling.classList.toggle('open')">
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><polyline points="9 18 15 12 9 6"/></svg>
Advanced Settings
</button>
<div class="settings-body">
<div class="settings-row">
<div class="setting-group">
<div class="setting-label">Duration</div>
<div class="setting-value">
<input type="range" id="sfx-duration" min="1" max="30" value="5">
<span class="setting-num" id="sfx-duration-val">5s</span>
</div>
</div>
<div class="setting-group">
<div class="setting-label">Inference Steps</div>
<div class="setting-value">
<input type="range" id="sfx-steps" min="4" max="32" value="8">
<span class="setting-num" id="sfx-steps-val">8</span>
</div>
</div>
</div>
</div>
</div>
<div class="generate-bar">
<button class="btn-generate" id="sfx-btn" onclick="soundEffect()" disabled>
<span class="btn-text">Generate Sound</span>
<div class="spinner"></div>
</button>
</div>
<div class="status-bar" id="sfx-status"></div>
<div class="progress-track" id="sfx-progress-bar"><div class="progress-fill" id="sfx-progress-fill"></div></div>
<div class="player-card" id="sfx-result">
<div class="player-top">
<button class="play-btn" onclick="togglePlayer('sfx')">
<svg id="sfx-play-icon" viewBox="0 0 24 24" fill="currentColor"><polygon points="5 3 19 12 5 21 5 3"/></svg>
<svg id="sfx-pause-icon" viewBox="0 0 24 24" fill="currentColor" style="display:none"><rect x="6" y="4" width="4" height="16"/><rect x="14" y="4" width="4" height="16"/></svg>
</button>
<div class="player-info">
<div class="player-title" id="sfx-player-title">Generated sound</div>
<div class="player-meta" id="sfx-player-meta"></div>
</div>
<div style="display:flex;gap:6px">
<button class="icon-btn" onclick="downloadResult('sfx')" title="Download">
<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><path d="M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4"/><polyline points="7 10 12 15 17 10"/><line x1="12" y1="15" x2="12" y2="3"/></svg>
</button>
</div>
</div>
<audio id="sfx-audio-player" class="player-audio"></audio>
</div>
</div>
<!-- Voice Library Page -->
<div class="page" id="page-voices">
<div class="page-header">
<div class="page-title">Voice Library</div>
<div class="page-desc">Preset speakers and your custom cloned voices. Select one to use in Voice Generation.</div>
</div>
<div class="preset-section-title voices-head">
<span>Your Voices</span>
<button class="voices-head-add" type="button" onclick="openAddVoice()">+ Add new voice (clone)</button>
</div>
<div class="voices-grid" id="voices-grid"></div>
<div class="preset-section-title" style="margin-top:28px">Preset Speakers</div>
<div class="voices-grid" id="presets-grid"></div>
</div>
<!-- Transcribe Page -->
<div class="page" id="page-transcribe">
<div class="page-header">
<div class="page-title">Transcribe</div>
<div class="page-desc">Upload an audio file to transcribe it to text. Powered by Cohere Transcribe.</div>
<button class="page-api-toggle" type="button" onclick="togglePageApi('transcribe', this)">
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><polyline points="16 18 22 12 16 6"/><polyline points="8 6 2 12 8 18"/></svg>
<span class="page-api-label">View API</span>
</button>
</div>
<div class="upload-area" id="transcribe-upload" style="margin-bottom:16px">
<div id="transcribe-upload-label">Drop an audio file here or click to upload<div class="upload-area-sub">MP3, WAV, FLAC, M4A supported</div></div>
<input type="file" id="transcribe-file-input" accept="audio/*">
</div>
<div style="display:flex;gap:12px;align-items:center;margin-bottom:16px">
<select class="lang-select" id="transcribe-lang" style="padding:8px 12px;font-size:13px">
<option value="en">English</option>
<option value="fr">French</option>
<option value="de">German</option>
<option value="es">Spanish</option>
<option value="pt">Portuguese</option>
<option value="it">Italian</option>
<option value="nl">Dutch</option>
<option value="pl">Polish</option>
<option value="el">Greek</option>
<option value="ar">Arabic</option>
<option value="ja">Japanese</option>
<option value="ko">Korean</option>
<option value="zh">Chinese</option>
<option value="vi">Vietnamese</option>
</select>
<button class="btn-generate" id="transcribe-btn" onclick="transcribe()" disabled style="flex:1">
<span class="btn-text">Transcribe</span>
<div class="spinner"></div>
</button>
</div>
<div class="status-bar" id="transcribe-status"></div>
<div id="transcribe-result" style="display:none">
<div class="setting-label" style="margin-bottom:8px;margin-top:16px">Transcript</div>
<div style="background:var(--surface);border:1px solid var(--border);border-radius:10px;padding:16px;font-size:14px;line-height:1.6;position:relative">
<div id="transcribe-text"></div>
<button class="copy-btn" onclick="copyTranscript()" style="position:absolute;top:8px;right:8px">
<svg width="12" height="12" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><rect x="9" y="9" width="13" height="13" rx="2"/><path d="M5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1"/></svg> Copy
</button>
</div>
</div>
</div>
<!-- History Page -->
<div class="page" id="page-history">
<div class="page-header">
<div class="page-title">History</div>
<div class="page-desc">Your recent generations.</div>
</div>
<div id="history-container">
<div class="empty-state"><div class="empty-state-icon">🕐</div><div>No generations yet</div></div>
</div>
</div>
<!-- API Page -->
<div class="page" id="page-api">
<div class="page-header">
<div class="page-title">API</div>
<div class="page-desc">Call any of these features directly from your code or AI agent using your HF token.</div>
</div>
<div style="margin-bottom:14px">
<select class="lang-select" id="api-feature" style="padding:8px 12px;font-size:13px;width:100%;max-width:380px">
<option value="synthesis">Voice Generation — OmniVoice</option>
<option value="design">Voice Design — Qwen3-TTS</option>
<option value="changer">Voice Changer — Seed-VC</option>
<option value="isolate">Voice Cleaner — Resemble Enhance</option>
<option value="sfx">Sound Effects — Stable Audio 3</option>
<option value="transcribe">Transcribe — Cohere</option>
</select>
</div>
<div class="agent-tip">
<strong>Use with AI agents</strong> — These API calls work great with Claude Code, Cursor, Windsurf, or any AI coding agent. Paste a snippet into your agent's context and ask it to call the feature. The agent can use your <code style="background:var(--surface2);padding:1px 4px;border-radius:3px;font-size:12px">HF_TOKEN</code> environment variable to authenticate. Works with MCP servers, automation scripts, and CI/CD pipelines too.
</div>
<div class="api-tabs" id="api-main-tabs">
<button class="api-tab active" type="button" data-lang="javascript" onclick="showApiLang('javascript', this)">JavaScript</button>
<button class="api-tab" type="button" data-lang="python" onclick="showApiLang('python', this)">Python</button>
<button class="api-tab" type="button" data-lang="curl" onclick="showApiLang('curl', this)">curl</button>
</div>
<div class="code-block">
<button class="copy-btn" onclick="copyCode(this)"><svg width="12" height="12" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><rect x="9" y="9" width="13" height="13" rx="2"/><path d="M5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1"/></svg> Copy</button>
<pre><code id="api-code"></code></pre>
</div>
</div>
<div class="footer">Powered by <a href="https://huggingface.co/spaces/k2-fsa/OmniVoice" target="_blank">OmniVoice</a>, <a href="https://huggingface.co/spaces/Qwen/Qwen3-TTS" target="_blank">Qwen3-TTS</a>, <a href="https://huggingface.co/spaces/Plachta/Seed-VC" target="_blank">Seed-VC</a>, <a href="https://huggingface.co/spaces/multimodalart/resemble-enhance-zerogpu" target="_blank">Resemble Enhance</a>, <a href="https://huggingface.co/spaces/stabilityai/stable-audio-3" target="_blank">Stable Audio 3</a> & <a href="https://huggingface.co/spaces/CohereLabs/cohere-transcribe-03-2026" target="_blank">Cohere Transcribe</a></div>
</div>
</div>
</div>
<!-- Add Voice Modal -->
<div class="modal-overlay" id="add-voice-modal">
<div class="modal">
<div class="modal-title">Add Voice</div>
<div class="modal-desc">Upload or record a reference audio clip to clone a voice. Short clips (5-30s) work best.</div>
<div class="modal-field">
<label>Voice Name</label>
<input type="text" id="voice-name-input" placeholder="e.g. Joshua, Sarah...">
</div>
<div class="modal-field">
<label>Reference Audio</label>
<div class="audio-source-tabs">
<button class="audio-source-tab active" data-mode="upload" type="button" onclick="setVoiceSourceMode('upload', true)">
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4"/><polyline points="17 8 12 3 7 8"/><line x1="12" y1="3" x2="12" y2="15"/></svg>
Upload
</button>
<button class="audio-source-tab" data-mode="record" type="button" onclick="setVoiceSourceMode('record')">
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><rect x="9" y="2" width="6" height="11" rx="3"/><path d="M5 11a7 7 0 0 0 14 0"/><line x1="12" y1="18" x2="12" y2="22"/></svg>
Record
</button>
</div>
<div class="upload-area" id="modal-upload">
<div id="modal-upload-label">Drop audio file here or click to browse<div class="upload-area-sub">MP3, WAV, FLAC · 5-30 seconds recommended</div></div>
<input type="file" id="modal-file-input" accept="audio/*">
</div>
<div id="modal-record" style="display:none">
<div class="record-pane">
<button class="record-mic-btn" id="record-mic-btn" type="button" onclick="toggleRecord()">
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><rect x="9" y="2" width="6" height="11" rx="3"/><path d="M5 11a7 7 0 0 0 14 0"/><line x1="12" y1="18" x2="12" y2="22"/></svg>
</button>
<div class="record-meta">
<div class="record-timer" id="record-timer">0:00</div>
<div class="record-hint" id="record-hint">Click to record · 5-30s recommended</div>
</div>
</div>
<audio id="record-preview" controls style="display:none;width:100%;margin-top:10px;border-radius:8px"></audio>
</div>
</div>
<label style="display:flex;align-items:flex-start;gap:8px;font-size:12px;color:var(--text-muted);cursor:pointer;margin-bottom:4px;line-height:1.4">
<input type="checkbox" id="voice-consent" style="margin-top:2px;accent-color:var(--accent)">
I confirm I have the right to use this voice and consent to cloning it.
</label>
<div class="modal-actions">
<button class="btn-modal btn-cancel" onclick="closeModal()">Cancel</button>
<button class="btn-modal btn-save" id="save-voice-btn" onclick="saveVoice()" disabled>Save Voice</button>
</div>
</div>
</div>
<script type="module">
import { oauthLoginUrl, oauthHandleRedirectIfPresent } from "https://esm.sh/@huggingface/hub@0.20.0";
const OMNIVOICE_BASE = "https://k2-fsa-omnivoice.hf.space/gradio_api";
const COLORS = ["#7c3aed","#ec4899","#f59e0b","#22c55e","#3b82f6","#ef4444","#06b6d4","#8b5cf6"];
const inputRecorders = {}; // prefix -> { mediaRecorder, stream, chunks, timerInterval, startTime }
const inputRecordHandlers = {}; // prefix -> (file) => void
let accessToken = null;
let userInfo = null;
let isPro = false;
let selectedVoice = null;
let resultAudioUrl = null;
let modalFileData = null;
let history = JSON.parse(localStorage.getItem("zl_history") || "[]");
let quotaTimer = null;
let lastQuota = null;
// ── IndexedDB ──
function openDB() {
return new Promise((resolve, reject) => {
const req = indexedDB.open("ZeroLabs", 1);
req.onupgradeneeded = () => req.result.createObjectStore("voices", { keyPath: "id" });
req.onsuccess = () => resolve(req.result);
req.onerror = () => reject(req.error);
});
}
async function getVoices() {
const db = await openDB();
return new Promise((res, rej) => {
const r = db.transaction("voices","readonly").objectStore("voices").getAll();
r.onsuccess = () => res(r.result);
r.onerror = () => rej(r.error);
});
}
async function putVoice(v) {
const db = await openDB();
return new Promise((res, rej) => {
const tx = db.transaction("voices","readwrite");
tx.objectStore("voices").put(v);
tx.oncomplete = () => res();
tx.onerror = () => rej(tx.error);
});
}
async function deleteVoiceDB(id) {
const db = await openDB();
return new Promise((res, rej) => {
const tx = db.transaction("voices","readwrite");
tx.objectStore("voices").delete(id);
tx.oncomplete = () => res();
tx.onerror = () => rej(tx.error);
});
}
// ── Render sidebar voices ──
async function renderSidebarVoices() {
const voices = await getVoices();
document.getElementById("voice-list").innerHTML = voices.map(v => `
<div class="voice-card ${selectedVoice?.id === v.id ? 'selected' : ''}" onclick="selectVoice('${v.id}')">
<div class="voice-avatar" style="background:${v.color}">${v.name[0].toUpperCase()}</div>
<div class="voice-meta">
<div class="voice-name">${v.name}</div>
<div class="voice-detail">${v.fileName}</div>
</div>
</div>
`).join("");
}
// ── Render Voices page grid ──
async function renderVoicesPage() {
const voices = await getVoices();
const grid = document.getElementById("voices-grid");
grid.innerHTML = voices.filter(v => !v.isPreset).map(v => {
const date = new Date(v.createdAt).toLocaleDateString();
const escaped = v.name.replace(/'/g, "\\'").replace(/"/g, """);
return `<div class="voice-tile">
<div class="voice-tile-date">${date}</div>
<div class="voice-tile-avatar" style="background:${v.color}">${v.name[0].toUpperCase()}</div>
<div class="voice-tile-name">${v.name} <span onclick="event.stopPropagation();renameVoice('${v.id}','${escaped}')" style="cursor:pointer;opacity:0.4;font-size:12px" title="Rename">✎</span></div>
<div class="voice-tile-file">${v.fileName}</div>
<div class="voice-tile-actions">
<button class="voice-tile-btn use" onclick="selectVoiceAndGo('${v.id}')">Use Voice</button>
<button class="voice-tile-btn del" onclick="deleteVoiceFromPage('${v.id}')">Remove</button>
</div>
</div>`;
}).join("") + `
<div class="add-voice-tile" onclick="openAddVoice()">
<svg width="32" height="32" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5"><line x1="12" y1="5" x2="12" y2="19"/><line x1="5" y1="12" x2="19" y2="12"/></svg>
Add New Voice (clone)
</div>`;
}
window.selectVoice = async function(id) {
const voices = await getVoices();
selectedVoice = voices.find(v => v.id === id);
renderSidebarVoices();
updateVoiceSelector();
updateGenerateBtn();
if (document.getElementById("gen-doc")) renderAbRows(); // refresh default-voice chips
};
window.selectVoiceAndGo = async function(id) {
await window.selectVoice(id);
document.querySelector('[data-page="synthesis"]').click();
};
window.deleteVoice = async function(id) {
await deleteVoiceDB(id);
if (selectedVoice?.id === id) { selectedVoice = null; updateVoiceSelector(); }
renderSidebarVoices();
renderVoicesPage();
updateGenerateBtn();
};
window.deleteVoiceFromPage = window.deleteVoice;
window.renameVoice = async function(id, currentName) {
const newName = prompt("Rename voice:", currentName);
if (!newName || newName.trim() === "" || newName.trim() === currentName) return;
const voices = await getVoices();
const voice = voices.find(v => v.id === id);
if (!voice) return;
voice.name = newName.trim();
await putVoice(voice);
if (selectedVoice?.id === id) { selectedVoice = voice; updateVoiceSelector(); }
renderSidebarVoices();
renderVoicesPage();
};
function updateVoiceSelector() {
const avatar = document.getElementById("sel-voice-avatar");
const name = document.getElementById("sel-voice-name");
const hint = document.getElementById("sel-voice-hint");
if (selectedVoice) {
avatar.textContent = selectedVoice.name[0].toUpperCase();
avatar.style.background = selectedVoice.color;
name.textContent = selectedVoice.name;
hint.textContent = selectedVoice.fileName;
} else {
avatar.textContent = "🎤";
avatar.style.background = "var(--surface3)";
name.textContent = "No voice selected";
hint.textContent = "Click to select or add a voice";
}
}
// ── Voice Picker Dropdown ──
window.toggleVoicePicker = async function(e) {
e.stopPropagation();
const picker = document.getElementById("voice-picker");
if (picker.classList.contains("visible")) {
picker.classList.remove("visible");
return;
}
const voices = await getVoices();
const usedPresetNames = new Set(voices.filter(v => v.isPreset).map(v => v.fileName.replace(/\.wav$/, "")));
const availablePresets = PRESETS.filter(p => !usedPresetNames.has(p.name));
const voicesHtml = voices.map(v => `
<button class="voice-picker-item" onclick="event.stopPropagation();pickVoice('${v.id}')">
<div class="voice-avatar" style="background:${v.color}">${v.name[0].toUpperCase()}</div>
<span>${v.name}</span>
</button>
`).join("");
const presetsHtml = availablePresets.length ? `
<div style="padding:6px 10px 4px;font-size:10px;text-transform:uppercase;letter-spacing:0.06em;color:var(--text-muted);font-weight:600;border-top:1px solid var(--border);margin-top:4px">Presets</div>
${availablePresets.map(p => `
<button class="voice-picker-item" onclick="event.stopPropagation();pickPreset('${p.name}')">
<div class="voice-avatar" style="background:#d97706">${p.name[0]}</div>
<span>${p.name.replace("_", " ")}<span style="opacity:0.5;font-size:11px;margin-left:6px">${p.tag}</span></span>
</button>
`).join("")}` : "";
picker.innerHTML = `
<button class="voice-picker-item" onclick="event.stopPropagation();closePickerAndAdd()" style="border-bottom:1px solid var(--border);margin-bottom:4px;font-weight:500">
+ Add new voice (clone)
</button>` + voicesHtml + presetsHtml;
picker.classList.add("visible");
};
window.pickVoice = async function(id) {
document.getElementById("voice-picker").classList.remove("visible");
await window.selectVoice(id);
};
window.pickPreset = async function(name) {
document.getElementById("voice-picker").classList.remove("visible");
await window.usePreset(name);
};
window.closePickerAndAdd = function() {
document.getElementById("voice-picker").classList.remove("visible");
openAddVoice();
};
document.addEventListener("click", () => {
document.getElementById("voice-picker")?.classList.remove("visible");
});
// ── Usage Tracker (real ZeroGPU quota) ──
function fmtDuration(sec) {
sec = Math.max(0, Math.round(sec));
const m = Math.floor(sec / 60);
const s = sec % 60;
return m > 0 ? `${m}m ${s}s` : `${s}s`;
}
function fmtResetsIn(iso) {
if (!iso) return null;
const ms = new Date(iso).getTime() - Date.now();
if (isNaN(ms) || ms <= 0) return null;
const mins = Math.round(ms / 60000);
if (mins < 60) return `${mins}m`;
const h = Math.floor(mins / 60);
const m = mins % 60;
return m > 0 ? `${h}h ${m}m` : `${h}h`;
}
async function refreshQuota() {
if (!accessToken) return;
const tracker = document.getElementById("usage-tracker");
try {
const res = await fetch("https://huggingface.co/api/spaces/zero-gpu/quota", {
headers: { Authorization: `Bearer ${accessToken}` }
});
if (!res.ok) throw new Error(`quota ${res.status}`);
const q = await res.json();
lastQuota = q;
const base = q.base || 0;
const remaining = Math.max(0, q.current || 0);
const secUsed = Math.max(0, base - remaining);
const runs = q.runs;
const fill = document.getElementById("usage-fill");
const value = document.getElementById("usage-value");
const sub = document.getElementById("usage-sub");
if (runs && runs.limit > 0) {
// Free tier: the daily execution count is the binding limit — headline it.
const pct = Math.min((runs.used / runs.limit) * 100, 100);
fill.style.width = `${pct}%`;
fill.className = "usage-fill" + (pct >= 100 ? " danger" : pct > 60 ? " warning" : "");
value.textContent = `${Math.round(runs.used)}/${Math.round(runs.limit)} runs`;
let line = `${Math.max(0, Math.round(runs.remaining))} free runs left · ${fmtDuration(remaining)} GPU`;
const resetIn = fmtResetsIn(runs.resetsAt);
if (resetIn) line += ` · resets in ${resetIn}`;
sub.textContent = line;
} else {
// Pro / paid: GPU-seconds are the only limit.
const pct = base > 0 ? Math.min((secUsed / base) * 100, 100) : 0;
fill.style.width = `${pct}%`;
fill.className = "usage-fill" + (pct > 80 ? " danger" : pct > 50 ? " warning" : "");
value.textContent = `${fmtDuration(remaining)} left`;
let line = `${fmtDuration(secUsed)} of ${fmtDuration(base)} ${isPro ? "Pro" : ""} GPU quota`.replace(/\s+/g, " ");
if (q.overquotaUsed > 0) line += ` · +${fmtDuration(q.overquotaUsed)} over`;
const resetIn = fmtResetsIn(q.resetsAt);
if (resetIn) line += ` · resets in ${resetIn}`;
sub.textContent = line;
}
if (tracker) tracker.style.display = "";
} catch (err) {
if (tracker) tracker.style.display = "none";
}
}
// ── Smart Error CTAs ──
// Build the body of a status bar for an error. The ZeroGPU backend sends a
// misleading seconds-based message to free users whose real blocker is the
// daily execution count, and wrongly offers paid GPU credits (Pro-only).
// We reframe using the real quota data (lastQuota.runs) and account tier.
function quotaErrorBodyHtml(errMsg) {
if (!errMsg.includes("GPU quota")) {
return `<div class="status-text">${errMsg}</div>`;
}
// Guest hit the anonymous single-run quota — offer a free HF sign-in, which
// unlocks the full free daily ZeroGPU quota. No paid upsell for guests.
if (!accessToken) {
return `<div class="status-text">You've used all 3 free guest runs. Sign in with Hugging Face to keep going — it's free.</div>
<button class="status-cta upgrade" type="button" onclick="login()">🤗 Sign in with Hugging Face to continue for free</button>
<div style="font-size:11px;color:var(--text-muted);margin-top:2px">A free HF account unlocks the full daily ZeroGPU quota</div>`;
}
const runs = lastQuota && lastQuota.runs;
// Free tier hit the daily execution limit (runs present and exhausted).
if (runs && runs.limit > 0 && runs.remaining <= 0) {
const limit = Math.round(runs.limit);
const resetIn = fmtResetsIn(runs.resetsAt);
const resetPhrase = resetIn
? `Come back in ${resetIn.replace(" ", "")} for a reset, or...`
: `Come back tomorrow for a reset, or...`;
return `<div class="status-text">You've used all ${limit} free ZeroGPU runs for today. ${resetPhrase}</div>
<a class="status-cta upgrade" href="https://huggingface.co/subscribe/pro?from=ZeroGPU" target="_blank">🤗 Subscribe to HF PRO to get 40 min/day of execution quota</a>
<div style="font-size:13px;font-weight:700;color:var(--accent);margin-top:4px">That's 1,000+ voice generations a day</div>`;
}
// Free tier with runs left, or unknown tier: ran out of GPU minutes.
if (!isPro) {
return `<div class="status-text">You've used your free daily ZeroGPU minutes.</div>
<a class="status-cta upgrade" href="https://huggingface.co/subscribe/pro?from=ZeroGPU" target="_blank">🤗 Subscribe to HF PRO to get 40 min/day of execution quota</a>
<div style="font-size:13px;font-weight:700;color:var(--accent);margin-top:4px">That's 1,000+ voice generations a day</div>
<div style="font-size:11px;color:var(--text-muted);margin-top:2px">Resets every 24h</div>`;
}
// Pro / paid: real seconds message + credits CTA (credits are Pro-only).
let html = `<div class="status-text">${errMsg}</div>
<a class="status-cta credits" href="https://huggingface.co/settings/billing" target="_blank">Buy additional GPU credits — $1 per 10 min</a>
<div style="font-size:13px;font-weight:700;color:var(--accent);margin-top:4px">That's 250+ voice generations per $1</div>`;
const m = errMsg.match(/Try again in ([\d:]+)/);
if (m && m[1] !== "0:00:00") {
html += `<div style="font-size:11px;color:var(--text-muted);margin-top:2px">Or wait ${m[1]} for your quota to reset</div>`;
}
return html;
}
async function showStatusWithCTA(errorMsg) {
const el = document.getElementById("status");
el.className = "status-bar visible error";
el.innerHTML = quotaErrorBodyHtml(errorMsg);
if (errorMsg.includes("GPU quota")) { await refreshQuota(); el.innerHTML = quotaErrorBodyHtml(errorMsg); }
}
function showStatus(type, msg) {
const el = document.getElementById("status");
el.className = `status-bar visible ${type}`;
el.innerHTML = `<div class="status-text">${msg}</div>`;
}
// ── Modal ──
window.openAddVoice = function() {
document.getElementById("add-voice-modal").classList.add("visible");
document.getElementById("voice-name-input").value = "";
document.getElementById("modal-upload-label").innerHTML = 'Drop audio file here or click to browse<div class="upload-area-sub">MP3, WAV, FLAC · 5-30 seconds recommended</div>';
document.getElementById("modal-upload").classList.remove("has-file");
document.getElementById("save-voice-btn").disabled = true;
document.getElementById("voice-consent").checked = false;
modalFileData = null;
resetRecorder();
setVoiceSourceMode("upload");
};
window.closeModal = function() {
document.getElementById("add-voice-modal").classList.remove("visible");
resetRecorder();
};
// ── Mic recording (alternative to upload) ──
let mediaRecorder = null;
let mediaStream = null;
let recordedChunks = [];
let recordTimerInterval = null;
let recordStartTime = 0;
function resetRecorder() {
if (mediaRecorder && mediaRecorder.state !== "inactive") {
try { mediaRecorder.stop(); } catch {}
}
if (mediaStream) {
mediaStream.getTracks().forEach(t => t.stop());
mediaStream = null;
}
if (recordTimerInterval) { clearInterval(recordTimerInterval); recordTimerInterval = null; }
mediaRecorder = null;
recordedChunks = [];
const btn = document.getElementById("record-mic-btn");
if (btn) btn.classList.remove("recording");
const preview = document.getElementById("record-preview");
if (preview) { preview.removeAttribute("src"); preview.style.display = "none"; }
const timer = document.getElementById("record-timer");
if (timer) timer.textContent = "0:00";
const hint = document.getElementById("record-hint");
if (hint) hint.textContent = "Click to record · 5-30s recommended";
}
window.setVoiceSourceMode = function(mode, openDialog) {
document.querySelectorAll(".audio-source-tab").forEach(t => t.classList.toggle("active", t.dataset.mode === mode));
document.getElementById("modal-upload").style.display = mode === "upload" ? "" : "none";
document.getElementById("modal-record").style.display = mode === "record" ? "" : "none";
if (mode === "upload" && openDialog) document.getElementById("modal-file-input").click();
};
function pickRecorderMimeType() {
const candidates = ["audio/webm;codecs=opus", "audio/webm", "audio/mp4", "audio/ogg;codecs=opus", "audio/ogg"];
for (const t of candidates) {
if (typeof MediaRecorder !== "undefined" && MediaRecorder.isTypeSupported && MediaRecorder.isTypeSupported(t)) return t;
}
return "";
}
// Decode any recorded blob and re-encode as 16-bit PCM WAV so soundfile-based
// upstreams (resemble-enhance, etc.) can read it.
async function recordedBlobToWavFile(blob, baseName) {
const Ctx = window.AudioContext || window.webkitAudioContext;
const ctx = new Ctx();
const arr = await blob.arrayBuffer();
const audioBuf = await ctx.decodeAudioData(arr.slice(0));
ctx.close?.();
const numCh = audioBuf.numberOfChannels;
const sampleRate = audioBuf.sampleRate;
const numFrames = audioBuf.length;
const dataLen = numFrames * numCh * 2;
const buf = new ArrayBuffer(44 + dataLen);
const view = new DataView(buf);
let p = 0;
const w8 = s => { for (let i = 0; i < s.length; i++) view.setUint8(p++, s.charCodeAt(i)); };
const w32 = v => { view.setUint32(p, v, true); p += 4; };
const w16 = v => { view.setUint16(p, v, true); p += 2; };
w8("RIFF"); w32(36 + dataLen); w8("WAVE");
w8("fmt "); w32(16); w16(1); w16(numCh); w32(sampleRate);
w32(sampleRate * numCh * 2); w16(numCh * 2); w16(16);
w8("data"); w32(dataLen);
const channels = [];
for (let c = 0; c < numCh; c++) channels.push(audioBuf.getChannelData(c));
for (let i = 0; i < numFrames; i++) {
for (let c = 0; c < numCh; c++) {
const s = Math.max(-1, Math.min(1, channels[c][i]));
view.setInt16(p, s < 0 ? s * 0x8000 : s * 0x7FFF, true);
p += 2;
}
}
return new File([buf], `${baseName}.wav`, { type: "audio/wav" });
}
window.toggleRecord = async function() {
const btn = document.getElementById("record-mic-btn");
const hint = document.getElementById("record-hint");
if (mediaRecorder && mediaRecorder.state === "recording") {
mediaRecorder.stop();
return;
}
// start
if (!navigator.mediaDevices?.getUserMedia) {
hint.textContent = "Recording not supported in this browser";
return;
}
try {
mediaStream = await navigator.mediaDevices.getUserMedia({ audio: true });
} catch (e) {
hint.textContent = "Microphone access denied";
return;
}
const mimeType = pickRecorderMimeType();
mediaRecorder = mimeType ? new MediaRecorder(mediaStream, { mimeType }) : new MediaRecorder(mediaStream);
recordedChunks = [];
mediaRecorder.ondataavailable = e => { if (e.data && e.data.size) recordedChunks.push(e.data); };
mediaRecorder.onstop = async () => {
clearInterval(recordTimerInterval);
btn.classList.remove("recording");
const elapsedSec = (Date.now() - recordStartTime) / 1000;
const type = mediaRecorder.mimeType || "audio/webm";
const rawBlob = new Blob(recordedChunks, { type });
hint.textContent = "Converting…";
try {
const wavFile = await recordedBlobToWavFile(rawBlob, `recording_${Date.now()}`);
const wavBuf = await wavFile.arrayBuffer();
modalFileData = { name: wavFile.name, data: wavBuf, type: "audio/wav" };
const preview = document.getElementById("record-preview");
preview.src = URL.createObjectURL(wavFile);
preview.style.display = "";
hint.textContent = `Recorded ${elapsedSec.toFixed(1)}s · click mic to re-record`;
checkModalSave();
} catch (err) {
hint.textContent = `Recording failed: ${err.message}`;
}
if (mediaStream) { mediaStream.getTracks().forEach(t => t.stop()); mediaStream = null; }
};
recordStartTime = Date.now();
recordTimerInterval = setInterval(() => {
const e = Math.floor((Date.now() - recordStartTime) / 1000);
document.getElementById("record-timer").textContent = `${Math.floor(e/60)}:${(e%60).toString().padStart(2,"0")}`;
}, 200);
hint.textContent = "Recording… click again to stop";
btn.classList.add("recording");
mediaRecorder.start();
};
const modalUpload = document.getElementById("modal-upload");
const modalFileInput = document.getElementById("modal-file-input");
modalUpload.addEventListener("click", () => modalFileInput.click());
modalUpload.addEventListener("dragover", e => e.preventDefault());
modalUpload.addEventListener("drop", e => { e.preventDefault(); if (e.dataTransfer.files.length) handleModalFile(e.dataTransfer.files[0]); });
modalFileInput.addEventListener("change", () => { if (modalFileInput.files.length) handleModalFile(modalFileInput.files[0]); });
function handleModalFile(file) {
const reader = new FileReader();
reader.onload = () => {
modalFileData = { name: file.name, data: reader.result, type: file.type };
document.getElementById("modal-upload-label").textContent = file.name;
modalUpload.classList.add("has-file");
checkModalSave();
};
reader.readAsArrayBuffer(file);
}
document.getElementById("voice-name-input").addEventListener("input", checkModalSave);
document.getElementById("voice-consent").addEventListener("change", checkModalSave);
function checkModalSave() {
document.getElementById("save-voice-btn").disabled = !(
document.getElementById("voice-name-input").value.trim() &&
modalFileData &&
document.getElementById("voice-consent").checked
);
}
window.saveVoice = async function() {
const voice = {
id: crypto.randomUUID(),
name: document.getElementById("voice-name-input").value.trim(),
fileName: modalFileData.name,
audioData: modalFileData.data,
audioType: modalFileData.type,
color: COLORS[Math.floor(Math.random() * COLORS.length)],
createdAt: Date.now()
};
await putVoice(voice);
selectedVoice = voice;
closeModal();
renderSidebarVoices();
renderVoicesPage();
updateVoiceSelector();
updateGenerateBtn();
};
// ── Preset Speakers ──
const PRESETS = [
{ name: "Aiden", tag: "Male, English" },
{ name: "Dylan", tag: "Male, English" },
{ name: "Eric", tag: "Male, English" },
{ name: "Ono_anna", tag: "Female, Japanese" },
{ name: "Ryan", tag: "Male, English" },
{ name: "Serena", tag: "Female, English" },
{ name: "Sohee", tag: "Female, Korean" },
{ name: "Uncle_fu", tag: "Male, Chinese" },
{ name: "Vivian", tag: "Female, English" },
];
const previewAudio = new Audio();
let currentPreview = null;
function renderPresets() {
const grid = document.getElementById("presets-grid");
grid.innerHTML = PRESETS.map(p => `
<div class="preset-tile">
<div class="preset-tile-avatar">${p.name[0]}</div>
<div class="preset-tile-info">
<div class="preset-tile-name">${p.name.replace("_", " ")}</div>
<div class="preset-tile-tag">${p.tag}</div>
</div>
<div class="preset-tile-actions">
<button class="preview-btn" onclick="previewPreset('${p.name}')" title="Preview">
<svg viewBox="0 0 24 24" fill="currentColor"><polygon points="5 3 19 12 5 21 5 3"/></svg>
</button>
<button class="voice-tile-btn use" onclick="usePreset('${p.name}')">Use</button>
</div>
</div>
`).join("");
}
window.previewPreset = function(name) {
if (currentPreview === name && !previewAudio.paused) {
previewAudio.pause();
currentPreview = null;
return;
}
previewAudio.src = `samples/${name}.wav`;
previewAudio.play();
currentPreview = name;
};
window.usePreset = async function(name) {
// Fetch the sample wav and store as a voice in IndexedDB
const res = await fetch(`samples/${name}.wav`);
const data = await res.arrayBuffer();
const voice = {
id: `preset_${name}`,
name: name.replace("_", " "),
fileName: `${name}.wav`,
audioData: data,
audioType: "audio/wav",
color: "#d97706",
createdAt: Date.now(),
isPreset: true
};
await putVoice(voice);
selectedVoice = voice;
renderSidebarVoices();
renderVoicesPage();
updateVoiceSelector();
updateGenerateBtn();
// Switch to voice clone page
document.querySelector('[data-page="synthesis"]').click();
};
// ── Voice Design (Qwen3-TTS) ──
const QWEN_BASE = "https://qwen-qwen3-tts.hf.space/gradio_api";
let designAudioUrl = null;
const designText = document.getElementById("design-text");
const designDesc = document.getElementById("design-voice-desc");
const designBtn = document.getElementById("design-generate-btn");
designText.addEventListener("input", () => {
document.getElementById("design-char-count").textContent = designText.value.length;
designBtn.disabled = !(designText.value.trim() && designDesc.value.trim());
});
designDesc.addEventListener("input", () => {
designBtn.disabled = !(designText.value.trim() && designDesc.value.trim());
});
window.generateDesign = async function() {
const text = designText.value.trim();
const desc = designDesc.value.trim();
const lang = document.getElementById("design-lang").value;
const btn = designBtn;
const progressBar = document.getElementById("design-progress-bar");
const progressFill = document.getElementById("design-progress-fill");
const result = document.getElementById("design-result");
btn.disabled = true;
btn.classList.add("loading");
result.classList.remove("visible");
showDesignStatus("info", "Joining queue...");
progressBar.classList.add("visible");
progressFill.style.width = "0%";
const sessionHash = crypto.randomUUID();
const t0 = Date.now();
try {
const joinRes = await fetch(`${QWEN_BASE}/queue/join`, {
method: "POST",
headers: {
"Content-Type": "application/json",
...(accessToken ? { Authorization: `Bearer ${accessToken}` } : {})
},
body: JSON.stringify({
data: [text, lang, desc],
fn_index: 0,
session_hash: sessionHash
})
});
if (!joinRes.ok) throw new Error(`Queue join failed: ${joinRes.status}`);
const streamRes = await fetch(
`${QWEN_BASE}/queue/data?session_hash=${sessionHash}`,
{ headers: accessToken ? { Authorization: `Bearer ${accessToken}` } : {} }
);
const reader = streamRes.body.getReader();
const decoder = new TextDecoder();
let buffer = "";
while (true) {
const { done, value } = await reader.read();
if (done) break;
buffer += decoder.decode(value, { stream: true });
const lines = buffer.split("\n\n");
buffer = lines.pop();
for (const line of lines) {
if (!line.startsWith("data: ")) continue;
const data = JSON.parse(line.slice(6));
if (data.msg === "estimation") showDesignStatus("info", `In queue (position ${data.rank})...`);
else if (data.msg === "process_starts") { showDesignStatus("info", "Generating..."); progressFill.style.width = "75%"; }
else if (data.msg === "log") showDesignStatus("info", data.log);
else if (data.msg === "process_completed") {
progressFill.style.width = "100%";
if (data.success) {
const wallSec = (Date.now() - t0) / 1000;
designAudioUrl = data.output.data[0].url;
document.getElementById("design-audio-player").src = designAudioUrl;
document.getElementById("design-player-title").textContent = text.slice(0, 60) + (text.length > 60 ? "..." : "");
setPlayerMeta("design", "Voice Design", `${text.length} chars`);
result.classList.add("visible");
showDesignStatus("success", `Generated in ${wallSec.toFixed(1)}s`);
addToHistory(text, "Voice Design", wallSec, designAudioUrl);
refreshQuota();
} else {
const errMsg = data.output?.error || "Generation failed";
showDesignStatusWithCTA(errMsg);
}
}
}
}
} catch (err) {
showDesignStatusWithCTA(err.message);
} finally {
btn.disabled = false;
btn.classList.remove("loading");
setTimeout(() => { progressBar.classList.remove("visible"); }, 2000);
designBtn.disabled = !(designText.value.trim() && designDesc.value.trim());
}
};
function showDesignStatus(type, msg) {
const el = document.getElementById("design-status");
el.className = `status-bar visible ${type}`;
el.innerHTML = `<div class="status-text">${msg}</div>`;
}
async function showDesignStatusWithCTA(errMsg) {
const el = document.getElementById("design-status");
el.className = "status-bar visible error";
el.innerHTML = quotaErrorBodyHtml(errMsg);
if (errMsg.includes("GPU quota")) { await refreshQuota(); el.innerHTML = quotaErrorBodyHtml(errMsg); }
}
const designAudioEl = document.getElementById("design-audio-player");
window.toggleDesignPlay = function() { designAudioEl.paused ? designAudioEl.play() : designAudioEl.pause(); };
designAudioEl.addEventListener("play", () => { document.getElementById("design-play-icon").style.display = "none"; document.getElementById("design-pause-icon").style.display = "block"; });
designAudioEl.addEventListener("pause", () => { document.getElementById("design-play-icon").style.display = "block"; document.getElementById("design-pause-icon").style.display = "none"; });
window.downloadDesignAudio = async function() {
if (!designAudioUrl) return;
const blob = await fetch(designAudioUrl).then(r => r.blob());
const a = document.createElement("a");
a.href = URL.createObjectURL(blob);
a.download = "zerolabs_design.wav";
a.click();
URL.revokeObjectURL(a.href);
};
window.saveDesignVoice = async function() {
if (!designAudioUrl) return;
const btn = document.getElementById("save-design-voice-btn");
btn.textContent = "Saving...";
btn.disabled = true;
try {
const res = await fetch(designAudioUrl);
const data = await res.arrayBuffer();
const desc = designDesc.value.trim();
const name = desc.length > 20 ? desc.slice(0, 20) + "..." : desc || "Designed Voice";
const voice = {
id: crypto.randomUUID(),
name,
fileName: `designed_voice_${Date.now()}.wav`,
audioData: data,
audioType: "audio/wav",
color: COLORS[Math.floor(Math.random() * COLORS.length)],
createdAt: Date.now()
};
await putVoice(voice);
selectedVoice = voice;
renderSidebarVoices();
renderVoicesPage();
updateVoiceSelector();
updateGenerateBtn();
btn.textContent = "Saved!";
setTimeout(() => { btn.textContent = "Save Voice"; btn.disabled = false; }, 2000);
} catch (err) {
btn.textContent = "Save Voice";
btn.disabled = false;
}
};
// ── Transcribe (Cohere) ──
const COHERE_BASE = "https://coherelabs-cohere-transcribe-03-2026.hf.space/gradio_api";
let transcribeFile = null;
const transcribeUpload = document.getElementById("transcribe-upload");
const transcribeFileInput = document.getElementById("transcribe-file-input");
const transcribeBtn = document.getElementById("transcribe-btn");
transcribeUpload.addEventListener("click", () => transcribeFileInput.click());
transcribeUpload.addEventListener("dragover", e => e.preventDefault());
transcribeUpload.addEventListener("drop", e => {
e.preventDefault();
if (e.dataTransfer.files.length) handleTranscribeFile(e.dataTransfer.files[0]);
});
transcribeFileInput.addEventListener("change", () => {
if (transcribeFileInput.files.length) handleTranscribeFile(transcribeFileInput.files[0]);
});
function handleTranscribeFile(file) {
transcribeFile = file;
document.getElementById("transcribe-upload-label").textContent = file.name;
transcribeUpload.classList.add("has-file");
transcribeBtn.disabled = false;
}
attachAudioInput("transcribe", handleTranscribeFile);
window.transcribe = async function() {
if (!transcribeFile) return;
const lang = document.getElementById("transcribe-lang").value;
const btn = transcribeBtn;
const result = document.getElementById("transcribe-result");
const t0 = Date.now();
btn.disabled = true;
btn.classList.add("loading");
result.style.display = "none";
showTranscribeStatus("info", "Uploading audio...");
try {
const form = new FormData();
form.append("files", transcribeFile);
const uploadRes = await fetch(`${COHERE_BASE}/upload`, {
method: "POST",
headers: accessToken ? { Authorization: `Bearer ${accessToken}` } : {},
body: form
});
const [uploadPath] = await uploadRes.json();
showTranscribeStatus("info", "Transcribing...");
const sessionHash = crypto.randomUUID();
const joinRes = await fetch(`${COHERE_BASE}/queue/join`, {
method: "POST",
headers: {
"Content-Type": "application/json",
...(accessToken ? { Authorization: `Bearer ${accessToken}` } : {})
},
body: JSON.stringify({
data: [
{ path: uploadPath, meta: { _type: "gradio.FileData" }, orig_name: transcribeFile.name },
lang
],
fn_index: 2,
session_hash: sessionHash
})
});
if (!joinRes.ok) throw new Error(`Queue join failed: ${joinRes.status}`);
const streamRes = await fetch(
`${COHERE_BASE}/queue/data?session_hash=${sessionHash}`,
{ headers: accessToken ? { Authorization: `Bearer ${accessToken}` } : {} }
);
const reader = streamRes.body.getReader();
const decoder = new TextDecoder();
let buffer = "";
while (true) {
const { done, value } = await reader.read();
if (done) break;
buffer += decoder.decode(value, { stream: true });
const lines = buffer.split("\n\n");
buffer = lines.pop();
for (const line of lines) {
if (!line.startsWith("data: ")) continue;
const data = JSON.parse(line.slice(6));
if (data.msg === "estimation") showTranscribeStatus("info", `In queue (position ${data.rank})...`);
else if (data.msg === "process_starts") showTranscribeStatus("info", "Transcribing...");
else if (data.msg === "log") showTranscribeStatus("info", data.log);
else if (data.msg === "process_completed") {
if (data.success) {
const transcript = data.output.data[0];
const wallSec = (Date.now() - t0) / 1000;
document.getElementById("transcribe-text").textContent = transcript;
result.style.display = "block";
showTranscribeStatus("success", `Transcribed in ${wallSec.toFixed(1)}s`);
refreshQuota();
addToHistory(transcript.slice(0, 120) + (transcript.length > 120 ? "…" : ""), `Transcribe (${transcribeFile.name})`, wallSec, null);
} else {
showTranscribeStatusWithCTA(data.output?.error || "Transcription failed");
}
}
}
}
} catch (err) {
showTranscribeStatusWithCTA(err.message);
} finally {
btn.disabled = false;
btn.classList.remove("loading");
}
};
function showTranscribeStatus(type, msg) {
const el = document.getElementById("transcribe-status");
el.className = `status-bar visible ${type}`;
el.innerHTML = `<div class="status-text">${msg}</div>`;
}
async function showTranscribeStatusWithCTA(errMsg) {
const el = document.getElementById("transcribe-status");
el.className = "status-bar visible error";
el.innerHTML = quotaErrorBodyHtml(errMsg);
if (errMsg.includes("GPU quota")) { await refreshQuota(); el.innerHTML = quotaErrorBodyHtml(errMsg); }
}
window.copyTranscript = function() {
const text = document.getElementById("transcribe-text").textContent;
navigator.clipboard.writeText(text).then(() => {
const btn = document.querySelector("#transcribe-result .copy-btn");
btn.innerHTML = '<svg width="12" height="12" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><polyline points="20 6 9 17 4 12"/></svg> Copied!';
btn.classList.add("copied");
setTimeout(() => {
btn.innerHTML = '<svg width="12" height="12" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><rect x="9" y="9" width="13" height="13" rx="2"/><path d="M5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1"/></svg> Copy';
btn.classList.remove("copied");
}, 2000);
});
};
// ── OAuth ──
async function initOAuth() {
// Try restoring from OAuth redirect first
const result = await oauthHandleRedirectIfPresent();
if (result) {
accessToken = result.accessToken;
userInfo = result.userInfo;
// Persist for page reloads with expiration
const expiresAt = Date.now() + (result.expiresIn || 28800) * 1000;
sessionStorage.setItem("zl_token", accessToken);
sessionStorage.setItem("zl_user", JSON.stringify(userInfo));
sessionStorage.setItem("zl_expires", expiresAt.toString());
await checkProAndShow();
return;
}
// Try restoring from sessionStorage
const savedToken = sessionStorage.getItem("zl_token");
const savedUser = sessionStorage.getItem("zl_user");
const savedExpires = sessionStorage.getItem("zl_expires");
if (savedToken && savedUser) {
// Check expiration first
if (savedExpires && Date.now() > parseInt(savedExpires)) {
sessionStorage.removeItem("zl_token");
sessionStorage.removeItem("zl_user");
sessionStorage.removeItem("zl_expires");
return;
}
accessToken = savedToken;
userInfo = JSON.parse(savedUser);
// Verify token is still valid
try {
const whoami = await fetch("https://huggingface.co/api/whoami-v2", {
headers: { Authorization: `Bearer ${accessToken}` }
}).then(r => r.json());
if (whoami.name) {
isPro = !!whoami.isPro;
showApp();
return;
}
} catch {}
// Token invalid, clear it
sessionStorage.removeItem("zl_token");
sessionStorage.removeItem("zl_user");
sessionStorage.removeItem("zl_expires");
}
// No valid login — open the app in guest mode. Generations run against the
// anonymous ZeroGPU quota; hitting it prompts a free HF sign-in.
showApp();
}
async function checkProAndShow() {
try {
const whoami = await fetch("https://huggingface.co/api/whoami-v2", {
headers: { Authorization: `Bearer ${accessToken}` }
}).then(r => r.json());
isPro = !!whoami.isPro;
} catch { isPro = false; }
showApp();
}
window.login = async function() {
window.location.href = await oauthLoginUrl({ scopes: "openid profile read-billing" });
};
window.toggleUserMenu = function(e) {
e.stopPropagation();
document.getElementById("user-menu").classList.toggle("visible");
};
window.logout = function() {
sessionStorage.removeItem("zl_token");
sessionStorage.removeItem("zl_user");
sessionStorage.removeItem("zl_expires");
// Clean OAuth params from URL if present, then reload
const url = new URL(window.location.href);
["code", "state", "oauth_redirect", "id_token", "access_token"].forEach(k => url.searchParams.delete(k));
window.location.replace(url.toString().replace(/\?$/, ""));
};
document.addEventListener("click", () => {
document.getElementById("user-menu")?.classList.remove("visible");
});
// Reflect the current auth state across the header pill and the sidebar.
// Guests see a "Sign in" button (top-right) and a sign-in CTA (bottom-left)
// in place of the personalized user pill and live quota tracker.
function updateAuthUI() {
const loggedIn = !!accessToken;
const pill = document.getElementById("user-pill");
const guestBtn = document.getElementById("header-signin");
const tracker = document.getElementById("usage-tracker");
const guestCta = document.getElementById("guest-cta");
if (loggedIn) {
if (pill) pill.style.display = "";
if (guestBtn) guestBtn.style.display = "none";
if (guestCta) guestCta.style.display = "none";
if (userInfo) {
document.getElementById("user-avatar").src = userInfo.avatarUrl;
document.getElementById("user-name").textContent = userInfo.name;
}
// usage-tracker visibility is managed by refreshQuota()
} else {
if (pill) pill.style.display = "none";
if (guestBtn) guestBtn.style.display = "";
if (tracker) tracker.style.display = "none";
if (guestCta) guestCta.style.display = "";
}
}
function showApp() {
document.getElementById("landing").style.display = "none";
document.getElementById("app").style.display = "grid";
updateAuthUI();
renderSidebarVoices();
renderPresets();
renderVoicesPage();
renderHistory();
initSynthDoc();
refreshQuota();
if (quotaTimer) clearInterval(quotaTimer);
quotaTimer = setInterval(refreshQuota, 60000);
}
// ── Pages ──
window.showPage = function(page, el) {
document.querySelectorAll(".page").forEach(p => p.classList.remove("active"));
document.getElementById(`page-${page}`).classList.add("active");
document.querySelectorAll(".nav-item").forEach(n => n.classList.remove("active"));
el.classList.add("active");
if (page === "voices") { renderPresets(); renderVoicesPage(); }
if (page === "history") renderHistory();
if (page === "synthesis") initSynthDoc();
};
window.copyCode = function(btn) {
const code = btn.parentElement.querySelector("code").textContent;
navigator.clipboard.writeText(code).then(() => {
btn.innerHTML = '<svg width="12" height="12" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><polyline points="20 6 9 17 4 12"/></svg> Copied!';
btn.classList.add("copied");
setTimeout(() => {
btn.innerHTML = '<svg width="12" height="12" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><rect x="9" y="9" width="13" height="13" rx="2"/><path d="M5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1"/></svg> Copy';
btn.classList.remove("copied");
}, 2000);
});
};
// ── API page: snippets ──
const API_SNIPPETS = {
synthesis: {
javascript: `// Voice Generation — k2-fsa/OmniVoice
// Auth: set TOKEN to your HF token from https://huggingface.co/settings/tokens
const TOKEN = process.env.HF_TOKEN;
const BASE = "https://k2-fsa-omnivoice.hf.space/gradio_api";
const SESSION = crypto.randomUUID();
// 1. Upload reference voice
const form = new FormData();
form.append("files", audioFile);
const [path] = await fetch(\`\${BASE}/upload\`, {
method: "POST",
headers: { Authorization: \`Bearer \${TOKEN}\` },
body: form
}).then(r => r.json());
// 2. Join queue
await fetch(\`\${BASE}/queue/join\`, {
method: "POST",
headers: { "Content-Type": "application/json", Authorization: \`Bearer \${TOKEN}\` },
body: JSON.stringify({
data: ["Hello world", "English",
{ path, meta: { _type: "gradio.FileData" }, orig_name: "voice.mp3" },
"", "", 32, 2.0, true, 1.0, 0, true, true],
fn_index: 0, session_hash: SESSION })
});
// 3. Stream SSE result
const r = await fetch(\`\${BASE}/queue/data?session_hash=\${SESSION}\`,
{ headers: { Authorization: \`Bearer \${TOKEN}\` } });`,
python: `# Voice Generation — k2-fsa/OmniVoice
# Auth: run \`huggingface-cli login\` or set HF_TOKEN env var
from gradio_client import Client, handle_file
client = Client("k2-fsa/OmniVoice")
audio_path, status = client.predict(
text="Hello world",
lang="English",
ref_aud=handle_file("voice.mp3"),
ref_text="", instruct="",
ns=32, gs=2.0, dn=True,
sp=1.0, du=0, pp=True, po=True,
api_name="/_clone_fn",
)
print(audio_path)`,
curl: `# Voice Generation — k2-fsa/OmniVoice
# Auth: get a token at https://huggingface.co/settings/tokens
export HF_TOKEN=hf_xxx
BASE=https://k2-fsa-omnivoice.hf.space/gradio_api
# 1. Upload reference voice
UPLOAD_PATH=$(curl -s -X POST "$BASE/upload" \\
-H "Authorization: Bearer $HF_TOKEN" \\
-F "files=@voice.mp3" | jq -r '.[0]')
# 2. Join queue
SESSION=$(uuidgen)
curl -s -X POST "$BASE/queue/join" \\
-H "Content-Type: application/json" \\
-H "Authorization: Bearer $HF_TOKEN" \\
-d "{\\"data\\":[\\"Hello world\\",\\"English\\",{\\"path\\":\\"$UPLOAD_PATH\\",\\"meta\\":{\\"_type\\":\\"gradio.FileData\\"},\\"orig_name\\":\\"voice.mp3\\"},\\"\\",\\"\\",32,2.0,true,1.0,0,true,true],\\"fn_index\\":0,\\"session_hash\\":\\"$SESSION\\"}"
# 3. Stream result (SSE)
curl -N "$BASE/queue/data?session_hash=$SESSION" \\
-H "Authorization: Bearer $HF_TOKEN"`
},
design: {
javascript: `// Voice Design — Qwen/Qwen3-TTS
const TOKEN = process.env.HF_TOKEN;
const BASE = "https://qwen-qwen3-tts.hf.space/gradio_api";
const SESSION = crypto.randomUUID();
await fetch(\`\${BASE}/queue/join\`, {
method: "POST",
headers: { "Content-Type": "application/json", Authorization: \`Bearer \${TOKEN}\` },
body: JSON.stringify({
data: ["Hello world", "English", "warm friendly tone, deep male voice"],
fn_index: 0, session_hash: SESSION })
});
const r = await fetch(\`\${BASE}/queue/data?session_hash=\${SESSION}\`,
{ headers: { Authorization: \`Bearer \${TOKEN}\` } });`,
python: `# Voice Design — Qwen/Qwen3-TTS
from gradio_client import Client
client = Client("Qwen/Qwen3-TTS")
audio_path = client.predict(
text="Hello world",
lang="English",
voice_description="warm friendly tone, deep male voice",
fn_index=0,
)
print(audio_path)`,
curl: `# Voice Design — Qwen/Qwen3-TTS
export HF_TOKEN=hf_xxx
BASE=https://qwen-qwen3-tts.hf.space/gradio_api
SESSION=$(uuidgen)
curl -s -X POST "$BASE/queue/join" \\
-H "Content-Type: application/json" \\
-H "Authorization: Bearer $HF_TOKEN" \\
-d "{\\"data\\":[\\"Hello world\\",\\"English\\",\\"warm friendly tone, deep male voice\\"],\\"fn_index\\":0,\\"session_hash\\":\\"$SESSION\\"}"
curl -N "$BASE/queue/data?session_hash=$SESSION" \\
-H "Authorization: Bearer $HF_TOKEN"`
},
changer: {
javascript: `// Voice Changer — Plachta/Seed-VC
const TOKEN = process.env.HF_TOKEN;
const BASE = "https://plachta-seed-vc.hf.space/gradio_api";
const SESSION = crypto.randomUUID();
// Upload source and target voices
async function up(file) {
const f = new FormData(); f.append("files", file);
const [p] = await fetch(\`\${BASE}/upload\`, {
method: "POST", headers: { Authorization: \`Bearer \${TOKEN}\` }, body: f
}).then(r => r.json());
return { path: p, meta: { _type: "gradio.FileData" }, orig_name: file.name };
}
const src = await up(sourceFile);
const tgt = await up(targetFile);
await fetch(\`\${BASE}/queue/join\`, {
method: "POST",
headers: { "Content-Type": "application/json", Authorization: \`Bearer \${TOKEN}\` },
body: JSON.stringify({
data: [src, tgt, 10, 1.0, 0.0, 0.7, 0.9, 1.0, 1.0, false, false],
fn_index: 3, session_hash: SESSION })
});
// Stream and read data[1] (full audio output)
const r = await fetch(\`\${BASE}/queue/data?session_hash=\${SESSION}\`,
{ headers: { Authorization: \`Bearer \${TOKEN}\` } });`,
python: `# Voice Changer — Plachta/Seed-VC
from gradio_client import Client, handle_file
client = Client("Plachta/Seed-VC", download_files=False)
stream_audio, full_audio = client.predict(
source_audio_path=handle_file("source.wav"),
target_audio_path=handle_file("target.wav"),
diffusion_steps=10,
length_adjust=1.0,
intelligebility_cfg_rate=0.0,
similarity_cfg_rate=0.7,
top_p=0.9,
temperature=1.0,
repetition_penalty=1.0,
convert_style=False,
anonymization_only=False,
api_name="/predict",
)
print(full_audio["url"]) # full WAV; stream_audio is HLS, usually ignore`,
curl: `# Voice Changer — Plachta/Seed-VC
export HF_TOKEN=hf_xxx
BASE=https://plachta-seed-vc.hf.space/gradio_api
SRC=$(curl -s -X POST "$BASE/upload" -H "Authorization: Bearer $HF_TOKEN" -F "files=@source.wav" | jq -r '.[0]')
TGT=$(curl -s -X POST "$BASE/upload" -H "Authorization: Bearer $HF_TOKEN" -F "files=@target.wav" | jq -r '.[0]')
SESSION=$(uuidgen)
curl -s -X POST "$BASE/queue/join" \\
-H "Content-Type: application/json" \\
-H "Authorization: Bearer $HF_TOKEN" \\
-d "{\\"data\\":[{\\"path\\":\\"$SRC\\",\\"meta\\":{\\"_type\\":\\"gradio.FileData\\"},\\"orig_name\\":\\"source.wav\\"},{\\"path\\":\\"$TGT\\",\\"meta\\":{\\"_type\\":\\"gradio.FileData\\"},\\"orig_name\\":\\"target.wav\\"},10,1.0,0.0,0.7,0.9,1.0,1.0,false,false],\\"fn_index\\":3,\\"session_hash\\":\\"$SESSION\\"}"
curl -N "$BASE/queue/data?session_hash=$SESSION" \\
-H "Authorization: Bearer $HF_TOKEN"`
},
isolate: {
javascript: `// Voice Cleaner — multimodalart/resemble-enhance-zerogpu
const TOKEN = process.env.HF_TOKEN;
const BASE = "https://multimodalart-resemble-enhance-zerogpu.hf.space/gradio_api";
const SESSION = crypto.randomUUID();
const form = new FormData();
form.append("files", audioFile);
const [path] = await fetch(\`\${BASE}/upload\`, {
method: "POST",
headers: { Authorization: \`Bearer \${TOKEN}\` },
body: form
}).then(r => r.json());
await fetch(\`\${BASE}/queue/join\`, {
method: "POST",
headers: { "Content-Type": "application/json", Authorization: \`Bearer \${TOKEN}\` },
body: JSON.stringify({
data: [
{ path, meta: { _type: "gradio.FileData" }, orig_name: "noisy.wav" },
"Midpoint", 64, 0.5, false
],
fn_index: 2, session_hash: SESSION })
});
// data[0] = denoised, data[1] = enhanced
const r = await fetch(\`\${BASE}/queue/data?session_hash=\${SESSION}\`,
{ headers: { Authorization: \`Bearer \${TOKEN}\` } });`,
python: `# Voice Cleaner — multimodalart/resemble-enhance-zerogpu
from gradio_client import Client, handle_file
client = Client("multimodalart/resemble-enhance-zerogpu")
denoised, enhanced = client.predict(
path=handle_file("noisy.wav"),
solver="Midpoint",
nfe=64,
tau=0.5,
denoising=False,
api_name="/predict",
)
print(enhanced)`,
curl: `# Voice Cleaner — multimodalart/resemble-enhance-zerogpu
export HF_TOKEN=hf_xxx
BASE=https://multimodalart-resemble-enhance-zerogpu.hf.space/gradio_api
UPLOAD=$(curl -s -X POST "$BASE/upload" \\
-H "Authorization: Bearer $HF_TOKEN" \\
-F "files=@noisy.wav" | jq -r '.[0]')
SESSION=$(uuidgen)
curl -s -X POST "$BASE/queue/join" \\
-H "Content-Type: application/json" \\
-H "Authorization: Bearer $HF_TOKEN" \\
-d "{\\"data\\":[{\\"path\\":\\"$UPLOAD\\",\\"meta\\":{\\"_type\\":\\"gradio.FileData\\"},\\"orig_name\\":\\"noisy.wav\\"},\\"Midpoint\\",64,0.5,false],\\"fn_index\\":2,\\"session_hash\\":\\"$SESSION\\"}"
curl -N "$BASE/queue/data?session_hash=$SESSION" \\
-H "Authorization: Bearer $HF_TOKEN"`
},
sfx: {
javascript: `// Sound Effects — stabilityai/stable-audio-3
const TOKEN = process.env.HF_TOKEN;
const BASE = "https://stabilityai-stable-audio-3.hf.space/gradio_api";
const SESSION = crypto.randomUUID();
await fetch(\`\${BASE}/queue/join\`, {
method: "POST",
headers: { "Content-Type": "application/json", Authorization: \`Bearer \${TOKEN}\` },
body: JSON.stringify({
// variant_key, prompt, duration, steps, cfg_scale, sampler_type, seed
data: ["medium", "dog barking", 5, 8, 1.0, "pingpong", 0],
fn_index: 3, session_hash: SESSION })
});
const r = await fetch(\`\${BASE}/queue/data?session_hash=\${SESSION}\`,
{ headers: { Authorization: \`Bearer \${TOKEN}\` } });`,
python: `# Sound Effects — stabilityai/stable-audio-3
from gradio_client import Client
client = Client("stabilityai/stable-audio-3")
audio_path = client.predict(
variant_key="medium",
prompt="dog barking",
duration=5,
steps=8,
cfg_scale=1.0,
sampler_type="pingpong",
seed=0,
api_name="/infer",
)
print(audio_path)`,
curl: `# Sound Effects — stabilityai/stable-audio-3
export HF_TOKEN=hf_xxx
BASE=https://stabilityai-stable-audio-3.hf.space/gradio_api
SESSION=$(uuidgen)
curl -s -X POST "$BASE/queue/join" \\
-H "Content-Type: application/json" \\
-H "Authorization: Bearer $HF_TOKEN" \\
-d "{\\"data\\":[\\"medium\\",\\"dog barking\\",5,8,1.0,\\"pingpong\\",0],\\"fn_index\\":3,\\"session_hash\\":\\"$SESSION\\"}"
curl -N "$BASE/queue/data?session_hash=$SESSION" \\
-H "Authorization: Bearer $HF_TOKEN"`
},
transcribe: {
javascript: `// Transcribe — CohereLabs/cohere-transcribe-03-2026
const TOKEN = process.env.HF_TOKEN;
const BASE = "https://coherelabs-cohere-transcribe-03-2026.hf.space/gradio_api";
const SESSION = crypto.randomUUID();
const form = new FormData();
form.append("files", audioFile);
const [path] = await fetch(\`\${BASE}/upload\`, {
method: "POST",
headers: { Authorization: \`Bearer \${TOKEN}\` },
body: form
}).then(r => r.json());
await fetch(\`\${BASE}/queue/join\`, {
method: "POST",
headers: { "Content-Type": "application/json", Authorization: \`Bearer \${TOKEN}\` },
body: JSON.stringify({
data: [
{ path, meta: { _type: "gradio.FileData" }, orig_name: "audio.mp3" },
"en"
],
fn_index: 2, session_hash: SESSION })
});
const r = await fetch(\`\${BASE}/queue/data?session_hash=\${SESSION}\`,
{ headers: { Authorization: \`Bearer \${TOKEN}\` } });`,
python: `# Transcribe — CohereLabs/cohere-transcribe-03-2026
from gradio_client import Client, handle_file
client = Client("CohereLabs/cohere-transcribe-03-2026")
transcript = client.predict(
audio=handle_file("audio.mp3"),
language="en",
fn_index=2,
)
print(transcript)`,
curl: `# Transcribe — CohereLabs/cohere-transcribe-03-2026
export HF_TOKEN=hf_xxx
BASE=https://coherelabs-cohere-transcribe-03-2026.hf.space/gradio_api
UPLOAD=$(curl -s -X POST "$BASE/upload" \\
-H "Authorization: Bearer $HF_TOKEN" \\
-F "files=@audio.mp3" | jq -r '.[0]')
SESSION=$(uuidgen)
curl -s -X POST "$BASE/queue/join" \\
-H "Content-Type: application/json" \\
-H "Authorization: Bearer $HF_TOKEN" \\
-d "{\\"data\\":[{\\"path\\":\\"$UPLOAD\\",\\"meta\\":{\\"_type\\":\\"gradio.FileData\\"},\\"orig_name\\":\\"audio.mp3\\"},\\"en\\"],\\"fn_index\\":2,\\"session_hash\\":\\"$SESSION\\"}"
curl -N "$BASE/queue/data?session_hash=$SESSION" \\
-H "Authorization: Bearer $HF_TOKEN"`
}
};
let currentApiLang = "javascript";
function renderApiCode() {
const feature = document.getElementById("api-feature").value;
document.getElementById("api-code").textContent = API_SNIPPETS[feature][currentApiLang];
}
function syncMainApiTabs() {
document.querySelectorAll("#api-main-tabs .api-tab").forEach(t => t.classList.toggle("active", t.dataset.lang === currentApiLang));
}
window.showApiLang = function(lang) {
currentApiLang = lang;
syncMainApiTabs();
renderApiCode();
};
document.getElementById("api-feature").addEventListener("change", renderApiCode);
renderApiCode();
// ── Per-page inline API panels ──
const API_PANEL_TABS_HTML = `
<div class="agent-tip" style="margin-bottom:12px">
<strong>Use with AI agents</strong> — Paste this snippet into Claude Code, Cursor, Windsurf, or any AI agent. The agent can use your <code style="background:var(--surface2);padding:1px 4px;border-radius:3px;font-size:12px">HF_TOKEN</code> environment variable to authenticate.
</div>
<div class="api-tabs">
<button class="api-tab" type="button" data-lang="javascript" onclick="showInlineApiLang('javascript', this)">JavaScript</button>
<button class="api-tab" type="button" data-lang="python" onclick="showInlineApiLang('python', this)">Python</button>
<button class="api-tab" type="button" data-lang="curl" onclick="showInlineApiLang('curl', this)">curl</button>
</div>
<div class="code-block">
<button class="copy-btn" onclick="copyCode(this)"><svg width="12" height="12" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><rect x="9" y="9" width="13" height="13" rx="2"/><path d="M5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1"/></svg> Copy</button>
<pre><code></code></pre>
</div>`;
function paintInlinePanel(panel) {
const feature = panel.dataset.feature;
panel.querySelectorAll(".api-tab").forEach(t => t.classList.toggle("active", t.dataset.lang === currentApiLang));
panel.querySelector(".code-block code").textContent = API_SNIPPETS[feature][currentApiLang];
}
window.togglePageApi = function(feature, btn) {
const header = btn.closest(".page-header");
let panel = header.nextElementSibling;
if (!panel || !panel.classList.contains("page-api-panel")) {
panel = document.createElement("div");
panel.className = "page-api-panel";
panel.dataset.feature = feature;
panel.innerHTML = API_PANEL_TABS_HTML;
panel.hidden = true;
header.insertAdjacentElement("afterend", panel);
}
const label = btn.querySelector(".page-api-label") || btn;
if (panel.hidden) {
paintInlinePanel(panel);
panel.hidden = false;
btn.classList.add("open");
label.textContent = "Hide API";
} else {
panel.hidden = true;
btn.classList.remove("open");
label.textContent = "View API";
}
};
window.showInlineApiLang = function(lang, btn) {
currentApiLang = lang;
paintInlinePanel(btn.closest(".page-api-panel"));
syncMainApiTabs();
renderApiCode();
};
// ── Shared gradio helpers (for Voice Changer / Cleaner / SFX) ──
const SEED_VC_BASE = "https://plachta-seed-vc.hf.space/gradio_api";
const RESEMBLE_BASE = "https://multimodalart-resemble-enhance-zerogpu.hf.space/gradio_api";
const STABLE_AUDIO_BASE = "https://stabilityai-stable-audio-3.hf.space/gradio_api";
const resultUrls = {};
function showStatusOn(elId, type, msg) {
const el = document.getElementById(elId);
el.className = `status-bar visible ${type}`;
el.innerHTML = `<div class="status-text">${msg}</div>`;
}
async function showStatusCtaOn(elId, errMsg) {
const el = document.getElementById(elId);
el.className = "status-bar visible error";
el.innerHTML = quotaErrorBodyHtml(errMsg);
if (errMsg.includes("GPU quota")) { await refreshQuota(); el.innerHTML = quotaErrorBodyHtml(errMsg); }
}
function wireUploadArea(areaId, inputId, labelId, onFile) {
const area = document.getElementById(areaId);
const inp = document.getElementById(inputId);
area.addEventListener("click", e => { if (e.target.tagName !== "INPUT") inp.click(); });
area.addEventListener("dragover", e => { e.preventDefault(); area.classList.add("dragover"); });
area.addEventListener("dragleave", () => area.classList.remove("dragover"));
area.addEventListener("drop", e => {
e.preventDefault();
area.classList.remove("dragover");
if (e.dataTransfer.files[0]) { onFile(e.dataTransfer.files[0]); document.getElementById(labelId).textContent = e.dataTransfer.files[0].name; area.classList.add("has-file"); }
});
inp.addEventListener("change", () => {
if (inp.files[0]) { onFile(inp.files[0]); document.getElementById(labelId).textContent = inp.files[0].name; area.classList.add("has-file"); }
});
}
// ── Per-input audio recording (mic alternative on every audio upload) ──
// (state vars hoisted to top of module — see top of script)
window.setInputMode = function(prefix, mode, openDialog) {
document.querySelectorAll(`.audio-source-tabs[data-input-prefix="${prefix}"] .audio-source-tab`)
.forEach(t => t.classList.toggle("active", t.dataset.mode === mode));
const upload = document.getElementById(`${prefix}-upload`);
if (upload) upload.style.display = mode === "upload" ? "" : "none";
const recordPane = document.getElementById(`${prefix}-record-pane`);
if (recordPane) recordPane.style.display = mode === "record" ? "" : "none";
const libraryPane = document.getElementById(`${prefix}-library-pane`);
if (libraryPane) {
libraryPane.style.display = mode === "library" ? "" : "none";
if (mode === "library" && prefix === "vc-target") renderVcTargetLibrary();
}
if (mode === "upload" && openDialog) upload?.click(); // open the file picker on tab click
};
async function renderVcTargetLibrary() {
const list = document.getElementById("vc-target-library-list");
if (!list) return;
const voices = await getVoices();
const usedPresetNames = new Set(voices.filter(v => v.isPreset).map(v => v.fileName.replace(/\.wav$/, "")));
const availablePresets = PRESETS.filter(p => !usedPresetNames.has(p.name));
const userHtml = voices.length ? voices.map(v => `
<div class="lib-item" data-id="${v.id}" onclick="pickVcTargetVoice('${v.id}')">
<div class="voice-avatar" style="background:${v.color}">${v.name[0].toUpperCase()}</div>
<div class="lib-item-meta">
<div class="lib-item-name">${v.name}</div>
<div class="lib-item-tag">${v.isPreset ? "Preset" : "Your voice"}</div>
</div>
</div>`).join("") : "";
const presetHtml = availablePresets.map(p => `
<div class="lib-item" data-id="preset_${p.name}" onclick="pickVcTargetPreset('${p.name}')">
<div class="voice-avatar" style="background:#d97706">${p.name[0]}</div>
<div class="lib-item-meta">
<div class="lib-item-name">${p.name.replace("_", " ")}</div>
<div class="lib-item-tag">${p.tag}</div>
</div>
</div>`).join("");
list.innerHTML = userHtml + presetHtml || `<div class="lib-empty">No voices yet — add one in Voice Generation or Voice Design.</div>`;
}
function markVcTargetSelected(id) {
document.querySelectorAll("#vc-target-library-list .lib-item").forEach(el => el.classList.toggle("selected", el.dataset.id === id));
}
window.pickVcTargetVoice = async function(id) {
const voices = await getVoices();
const v = voices.find(x => x.id === id);
if (!v) return;
const blob = new Blob([v.audioData], { type: v.audioType || "audio/wav" });
vcTarget = new File([blob], v.fileName || `${v.name}.wav`, { type: blob.type });
document.getElementById("vc-target-label").textContent = v.name;
document.getElementById("vc-target-upload").classList.add("has-file");
markVcTargetSelected(id);
updateVcBtn();
};
window.pickVcTargetPreset = async function(name) {
const res = await fetch(`samples/${name}.wav`);
const blob = await res.blob();
vcTarget = new File([blob], `${name}.wav`, { type: blob.type || "audio/wav" });
document.getElementById("vc-target-label").textContent = name.replace("_", " ");
document.getElementById("vc-target-upload").classList.add("has-file");
markVcTargetSelected(`preset_${name}`);
updateVcBtn();
};
window.toggleInputRecord = async function(prefix) {
const btn = document.getElementById(`${prefix}-record-btn`);
const hint = document.getElementById(`${prefix}-hint`);
const r = inputRecorders[prefix];
if (r && r.mediaRecorder && r.mediaRecorder.state === "recording") {
r.mediaRecorder.stop();
return;
}
if (!navigator.mediaDevices?.getUserMedia) { hint.textContent = "Recording not supported in this browser"; return; }
let stream;
try { stream = await navigator.mediaDevices.getUserMedia({ audio: true }); }
catch { hint.textContent = "Microphone access denied"; return; }
const mimeType = pickRecorderMimeType();
const mr = mimeType ? new MediaRecorder(stream, { mimeType }) : new MediaRecorder(stream);
const chunks = [];
mr.ondataavailable = e => { if (e.data?.size) chunks.push(e.data); };
const startTime = Date.now();
const timerInterval = setInterval(() => {
const e = Math.floor((Date.now() - startTime) / 1000);
document.getElementById(`${prefix}-timer`).textContent = `${Math.floor(e/60)}:${(e%60).toString().padStart(2,"0")}`;
}, 200);
inputRecorders[prefix] = { mediaRecorder: mr, stream, chunks, timerInterval, startTime };
mr.onstop = async () => {
clearInterval(timerInterval);
btn.classList.remove("recording");
const elapsedSec = (Date.now() - startTime) / 1000;
const type = mr.mimeType || "audio/webm";
const rawBlob = new Blob(chunks, { type });
hint.textContent = "Converting…";
try {
const file = await recordedBlobToWavFile(rawBlob, `recording_${Date.now()}`);
const preview = document.getElementById(`${prefix}-preview-audio`);
preview.src = URL.createObjectURL(file);
preview.style.display = "";
hint.textContent = `Recorded ${elapsedSec.toFixed(1)}s · click mic to re-record`;
inputRecordHandlers[prefix]?.(file);
} catch (err) {
hint.textContent = `Recording failed: ${err.message}`;
} finally {
stream.getTracks().forEach(t => t.stop());
delete inputRecorders[prefix];
}
};
hint.textContent = "Recording… click again to stop";
btn.classList.add("recording");
mr.start();
};
// Attach an Upload/Record toggle around an existing .upload-area
function attachAudioInput(prefix, onFile, opts = {}) {
const uploadId = opts.uploadId || `${prefix}-upload`;
const area = document.getElementById(uploadId);
if (!area) return;
inputRecordHandlers[prefix] = onFile;
const extraTab = opts.includeLibrary ? `
<button class="audio-source-tab" data-mode="library" type="button" onclick="setInputMode('${prefix}', 'library')">
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2"/><circle cx="9" cy="7" r="4"/><path d="M22 21v-2a4 4 0 0 0-3-3.87"/><path d="M16 3.13a4 4 0 0 1 0 7.75"/></svg>
Library
</button>` : "";
area.insertAdjacentHTML("beforebegin", `
<div class="audio-source-tabs" data-input-prefix="${prefix}">
<button class="audio-source-tab active" data-mode="upload" type="button" onclick="setInputMode('${prefix}', 'upload', true)">
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4"/><polyline points="17 8 12 3 7 8"/><line x1="12" y1="3" x2="12" y2="15"/></svg>
Upload
</button>
<button class="audio-source-tab" data-mode="record" type="button" onclick="setInputMode('${prefix}', 'record')">
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><rect x="9" y="2" width="6" height="11" rx="3"/><path d="M5 11a7 7 0 0 0 14 0"/><line x1="12" y1="18" x2="12" y2="22"/></svg>
Record
</button>
${extraTab}
</div>
`);
area.insertAdjacentHTML("afterend", `
<div id="${prefix}-record-pane" style="display:none;margin-bottom:16px">
<div class="record-pane">
<button class="record-mic-btn" id="${prefix}-record-btn" type="button" onclick="toggleInputRecord('${prefix}')">
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><rect x="9" y="2" width="6" height="11" rx="3"/><path d="M5 11a7 7 0 0 0 14 0"/><line x1="12" y1="18" x2="12" y2="22"/></svg>
</button>
<div class="record-meta">
<div class="record-timer" id="${prefix}-timer">0:00</div>
<div class="record-hint" id="${prefix}-hint">Click to record · 5-30s recommended</div>
</div>
</div>
<audio id="${prefix}-preview-audio" controls style="display:none;width:100%;margin-top:10px;border-radius:8px"></audio>
</div>
${opts.includeLibrary ? `<div id="${prefix}-library-pane" style="display:none;margin-bottom:16px"><div class="lib-list" id="${prefix}-library-list"></div></div>` : ""}
`);
}
function setupPlayer(prefix) {
const el = document.getElementById(`${prefix}-audio-player`);
el.addEventListener("play", () => {
document.getElementById(`${prefix}-play-icon`).style.display = "none";
document.getElementById(`${prefix}-pause-icon`).style.display = "block";
});
el.addEventListener("pause", () => {
document.getElementById(`${prefix}-play-icon`).style.display = "block";
document.getElementById(`${prefix}-pause-icon`).style.display = "none";
});
}
window.togglePlayer = function(prefix) {
const el = document.getElementById(`${prefix}-audio-player`);
el.paused ? el.play() : el.pause();
};
window.downloadResult = async function(prefix) {
const url = resultUrls[prefix];
if (!url) return;
const blob = await fetch(url).then(r => r.blob());
const a = document.createElement("a");
a.href = URL.createObjectURL(blob);
a.download = `zerolabs_${prefix}.wav`;
a.click();
URL.revokeObjectURL(a.href);
};
// Upload a file to a Space's /upload, return a FileData ref ready for /queue/join data array
async function uploadFile(base, file) {
const form = new FormData();
form.append("files", file);
const r = await fetch(`${base}/upload`, {
method: "POST",
headers: accessToken ? { Authorization: `Bearer ${accessToken}` } : {},
body: form
});
if (!r.ok) throw new Error(`Upload failed: ${r.status}`);
const [path] = await r.json();
return { path, meta: { _type: "gradio.FileData" }, orig_name: file.name };
}
// Run a queue/join + queue/data SSE call. Returns { output, duration }.
// statusElId/progressFillId are optional and used for UI updates.
async function gradioCall({ base, fnIndex, data, statusElId, progressFillId, processingMsg }) {
const t0 = Date.now();
const session = crypto.randomUUID();
if (statusElId) showStatusOn(statusElId, "info", "Joining queue...");
const joinRes = await fetch(`${base}/queue/join`, {
method: "POST",
headers: {
"Content-Type": "application/json",
...(accessToken ? { Authorization: `Bearer ${accessToken}` } : {})
},
body: JSON.stringify({ data, fn_index: fnIndex, session_hash: session })
});
if (!joinRes.ok) throw new Error(`Queue join failed: ${joinRes.status}`);
const streamRes = await fetch(`${base}/queue/data?session_hash=${session}`, {
headers: accessToken ? { Authorization: `Bearer ${accessToken}` } : {}
});
const reader = streamRes.body.getReader();
const decoder = new TextDecoder();
let buffer = "";
while (true) {
const { done, value } = await reader.read();
if (done) break;
buffer += decoder.decode(value, { stream: true });
const lines = buffer.split("\n\n");
buffer = lines.pop();
for (const line of lines) {
if (!line.startsWith("data: ")) continue;
const evt = JSON.parse(line.slice(6));
if (statusElId) {
if (evt.msg === "estimation") showStatusOn(statusElId, "info", `In queue (position ${evt.rank})...`);
else if (evt.msg === "process_starts") {
showStatusOn(statusElId, "info", processingMsg || "Processing...");
if (progressFillId) document.getElementById(progressFillId).style.width = "75%";
}
else if (evt.msg === "log") showStatusOn(statusElId, "info", evt.log);
else if (evt.msg === "progress" && evt.progress_data?.length) {
const p = evt.progress_data[0];
if (p.length && progressFillId) {
document.getElementById(progressFillId).style.width = `${Math.round((p.index / p.length) * 24) + 75}%`;
showStatusOn(statusElId, "info", p.desc || `Step ${p.index}/${p.length}`);
}
}
}
if (evt.msg === "process_completed") {
if (progressFillId) document.getElementById(progressFillId).style.width = "100%";
if (evt.success) {
const wallClock = (Date.now() - t0) / 1000;
return { output: evt.output, duration: evt.output.duration || wallClock, wallClock };
}
throw new Error(evt.output?.error || "Generation failed");
}
}
}
throw new Error("Stream ended without completion");
}
// Update a player-meta line with the audio's actual duration once it loads.
function setPlayerMeta(prefix, leadingText, trailingText) {
const audioId = prefix ? `${prefix}-audio-player` : "audio-player";
const metaId = prefix ? `${prefix}-player-meta` : "player-meta";
const audio = document.getElementById(audioId);
const meta = document.getElementById(metaId);
if (!audio || !meta) return;
const paint = () => {
const d = isFinite(audio.duration) && audio.duration > 0 ? `${audio.duration.toFixed(1)}s` : "";
meta.textContent = [leadingText, d, trailingText].filter(Boolean).join(" · ");
};
audio.addEventListener("loadedmetadata", paint, { once: true });
paint();
}
// Pull a URL out of a gradio Audio output (object {url} or {path} ref).
function audioUrlFromOutput(out, base) {
if (!out) return null;
if (typeof out === "string") return out;
if (out.url) return out.url;
if (out.path) return `${base}/file=${out.path}`;
return null;
}
// ── Voice Changer (Seed-VC) ──
let vcSource = null, vcTarget = null;
const vcSteps = document.getElementById("vc-steps");
const vcSim = document.getElementById("vc-sim");
vcSteps.addEventListener("input", () => document.getElementById("vc-steps-val").textContent = vcSteps.value);
vcSim.addEventListener("input", () => document.getElementById("vc-sim-val").textContent = (vcSim.value / 100).toFixed(2));
function updateVcBtn() {
document.getElementById("vc-btn").disabled = !(vcSource && vcTarget);
}
wireUploadArea("vc-source-upload", "vc-source-input", "vc-source-label", f => { vcSource = f; updateVcBtn(); });
wireUploadArea("vc-target-upload", "vc-target-input", "vc-target-label", f => { vcTarget = f; updateVcBtn(); });
attachAudioInput("vc-source", f => { vcSource = f; document.getElementById("vc-source-label").textContent = f.name; document.getElementById("vc-source-upload").classList.add("has-file"); updateVcBtn(); });
attachAudioInput("vc-target", f => { vcTarget = f; document.getElementById("vc-target-label").textContent = f.name; document.getElementById("vc-target-upload").classList.add("has-file"); updateVcBtn(); }, { includeLibrary: true });
setupPlayer("vc");
window.voiceChange = async function() {
if (!vcSource || !vcTarget) return;
const btn = document.getElementById("vc-btn");
const progressBar = document.getElementById("vc-progress-bar");
const progressFill = document.getElementById("vc-progress-fill");
const result = document.getElementById("vc-result");
btn.disabled = true; btn.classList.add("loading");
result.classList.remove("visible");
progressBar.classList.add("visible");
progressFill.style.width = "0%";
try {
showStatusOn("vc-status", "info", "Uploading audio...");
const [src, tgt] = await Promise.all([uploadFile(SEED_VC_BASE, vcSource), uploadFile(SEED_VC_BASE, vcTarget)]);
const { output, wallClock } = await gradioCall({
base: SEED_VC_BASE,
fnIndex: 3,
data: [src, tgt, parseInt(vcSteps.value), 1.0, 0.0, vcSim.value / 100, 0.9, 1.0, 1.0, false, false],
statusElId: "vc-status",
progressFillId: "vc-progress-fill",
processingMsg: "Converting voice..."
});
// Seed-VC outputs: [Stream Output (HLS), Full Output (wav)]. Use the full one.
const url = audioUrlFromOutput(output.data[1], SEED_VC_BASE);
if (!url) throw new Error("No audio returned");
resultUrls.vc = url;
document.getElementById("vc-audio-player").src = url;
setPlayerMeta("vc", `${vcSource.name} → ${vcTarget.name}`);
result.classList.add("visible");
showStatusOn("vc-status", "success", `Converted in ${wallClock.toFixed(1)}s`);
refreshQuota();
addToHistory(`${vcSource.name} → ${vcTarget.name}`, "Voice Changer", wallClock, url);
} catch (err) {
showStatusCtaOn("vc-status", err.message);
} finally {
btn.disabled = false; btn.classList.remove("loading");
setTimeout(() => { progressBar.classList.remove("visible"); updateVcBtn(); }, 2000);
}
};
// ── Voice Cleaner (Resemble Enhance) ──
let isoMode = "enhance"; // "enhance" = denoise+enhance, "denoise" = denoise-only
window.setIsoMode = function(mode) {
isoMode = mode;
document.querySelectorAll("#iso-mode-tabs .audio-source-tab").forEach(t => t.classList.toggle("active", t.dataset.isoMode === mode));
};
let isoFile = null;
const isoNfe = document.getElementById("iso-nfe");
const isoTau = document.getElementById("iso-tau");
isoNfe.addEventListener("input", () => document.getElementById("iso-nfe-val").textContent = isoNfe.value);
isoTau.addEventListener("input", () => document.getElementById("iso-tau-val").textContent = (isoTau.value / 100).toFixed(2));
wireUploadArea("iso-upload", "iso-file-input", "iso-upload-label", f => {
isoFile = f;
document.getElementById("iso-btn").disabled = false;
});
attachAudioInput("iso", f => {
isoFile = f;
document.getElementById("iso-upload-label").textContent = f.name;
document.getElementById("iso-upload").classList.add("has-file");
document.getElementById("iso-btn").disabled = false;
});
setupPlayer("iso");
window.voiceIsolate = async function() {
if (!isoFile) return;
const btn = document.getElementById("iso-btn");
const progressBar = document.getElementById("iso-progress-bar");
const progressFill = document.getElementById("iso-progress-fill");
const result = document.getElementById("iso-result");
const denoiseOnly = isoMode === "denoise";
btn.disabled = true; btn.classList.add("loading");
result.classList.remove("visible");
progressBar.classList.add("visible");
progressFill.style.width = "0%";
try {
showStatusOn("iso-status", "info", "Uploading audio...");
const fileRef = await uploadFile(RESEMBLE_BASE, isoFile);
const { output, wallClock } = await gradioCall({
base: RESEMBLE_BASE,
fnIndex: 2,
data: [fileRef, "Midpoint", parseInt(isoNfe.value), isoTau.value / 100, denoiseOnly],
statusElId: "iso-status",
progressFillId: "iso-progress-fill",
processingMsg: "Enhancing audio..."
});
// Outputs: [Denoised, Enhanced]. Pick enhanced normally; denoised if denoise-only.
const idx = denoiseOnly ? 0 : 1;
const url = audioUrlFromOutput(output.data[idx], RESEMBLE_BASE);
if (!url) throw new Error("No audio returned");
resultUrls.iso = url;
document.getElementById("iso-audio-player").src = url;
document.getElementById("iso-player-title").textContent = denoiseOnly ? "Cleaned audio" : "Enhanced audio";
setPlayerMeta("iso", isoFile.name);
result.classList.add("visible");
showStatusOn("iso-status", "success", `Done in ${wallClock.toFixed(1)}s`);
refreshQuota();
addToHistory(isoFile.name, denoiseOnly ? "Voice Cleaner (noise)" : "Voice Cleaner (enhance)", wallClock, url);
} catch (err) {
showStatusCtaOn("iso-status", err.message);
} finally {
btn.disabled = false; btn.classList.remove("loading");
setTimeout(() => { progressBar.classList.remove("visible"); }, 2000);
}
};
// ── Sound Effects (Stable Audio 3) ──
const sfxPrompt = document.getElementById("sfx-prompt");
const sfxDuration = document.getElementById("sfx-duration");
const sfxSteps = document.getElementById("sfx-steps");
sfxPrompt.addEventListener("input", () => {
document.getElementById("sfx-char-count").textContent = sfxPrompt.value.length;
document.getElementById("sfx-btn").disabled = !sfxPrompt.value.trim();
});
sfxDuration.addEventListener("input", () => document.getElementById("sfx-duration-val").textContent = `${sfxDuration.value}s`);
sfxSteps.addEventListener("input", () => document.getElementById("sfx-steps-val").textContent = sfxSteps.value);
setupPlayer("sfx");
window.soundEffect = async function() {
const prompt = sfxPrompt.value.trim();
if (!prompt) return;
const btn = document.getElementById("sfx-btn");
const progressBar = document.getElementById("sfx-progress-bar");
const progressFill = document.getElementById("sfx-progress-fill");
const result = document.getElementById("sfx-result");
btn.disabled = true; btn.classList.add("loading");
result.classList.remove("visible");
progressBar.classList.add("visible");
progressFill.style.width = "0%";
try {
const { output, wallClock } = await gradioCall({
base: STABLE_AUDIO_BASE,
fnIndex: 3,
// /infer params: variant_key, prompt, duration, steps, cfg_scale, sampler_type, seed
data: ["medium", prompt, parseInt(sfxDuration.value), parseInt(sfxSteps.value), 1.0, "pingpong", 0],
statusElId: "sfx-status",
progressFillId: "sfx-progress-fill",
processingMsg: "Generating sound..."
});
const url = audioUrlFromOutput(output.data[0], STABLE_AUDIO_BASE);
if (!url) throw new Error("No audio returned");
resultUrls.sfx = url;
document.getElementById("sfx-audio-player").src = url;
document.getElementById("sfx-player-title").textContent = prompt.slice(0, 60) + (prompt.length > 60 ? "..." : "");
setPlayerMeta("sfx", `Prompt: "${prompt.slice(0,40)}${prompt.length>40?"...":""}"`);
result.classList.add("visible");
showStatusOn("sfx-status", "success", `Generated in ${wallClock.toFixed(1)}s`);
refreshQuota();
addToHistory(prompt, "Sound Effects", wallClock, url);
} catch (err) {
showStatusCtaOn("sfx-status", err.message);
} finally {
btn.disabled = false; btn.classList.remove("loading");
setTimeout(() => { progressBar.classList.remove("visible"); }, 2000);
}
};
// ── Text ──
// The synthesis editor is the adaptive rich-document below (abSegments / renderAbRows).
function updateGenerateBtn() { abUpdateGenerateBtn(); }
// ── Settings ──
const stepsSlider = document.getElementById("setting-steps");
const speedSlider = document.getElementById("setting-speed");
stepsSlider.addEventListener("input", () => document.getElementById("steps-val").textContent = stepsSlider.value);
speedSlider.addEventListener("input", () => document.getElementById("speed-val").textContent = (speedSlider.value / 100).toFixed(1) + "x");
// ── Generate ──
window.generate = async function() {
const todo = abSegments.map((s, i) => ({ s, i })).filter(x => x.s.text.trim());
if (!todo.length || !selectedVoice) return;
if (todo.length === 1) return generateSingle(todo[0].i);
return generateCombined();
};
async function generateSingle(idx) {
const text = abSegments[idx].text.trim();
const lang = document.getElementById("lang-select").value;
const steps = parseInt(stepsSlider.value);
const speed = speedSlider.value / 100;
genResultBlob = null;
const btn = document.getElementById("generate-btn");
const progressBar = document.getElementById("progress-bar");
const progressFill = document.getElementById("progress-fill");
const result = document.getElementById("result");
btn.disabled = true;
btn.classList.add("loading");
result.classList.remove("visible");
showStatus("info", "Uploading voice...");
progressBar.classList.add("visible");
progressFill.style.width = "0%";
const t0 = Date.now();
try {
const blob = new Blob([selectedVoice.audioData], { type: selectedVoice.audioType || "audio/mpeg" });
const form = new FormData();
form.append("files", blob, selectedVoice.fileName);
const uploadRes = await fetch(`${OMNIVOICE_BASE}/upload`, {
method: "POST",
headers: accessToken ? { Authorization: `Bearer ${accessToken}` } : {},
body: form
});
const [uploadPath] = await uploadRes.json();
showStatus("info", "Joining queue...");
const sessionHash = crypto.randomUUID();
const joinRes = await fetch(`${OMNIVOICE_BASE}/queue/join`, {
method: "POST",
headers: {
"Content-Type": "application/json",
...(accessToken ? { Authorization: `Bearer ${accessToken}` } : {})
},
body: JSON.stringify({
data: [text, lang,
{ path: uploadPath, meta: { _type: "gradio.FileData" }, orig_name: selectedVoice.fileName },
"", "", steps, 2.0, true, speed, 0, true, true],
fn_index: 0, session_hash: sessionHash
})
});
if (!joinRes.ok) throw new Error(`Queue join failed: ${joinRes.status}`);
const streamRes = await fetch(
`${OMNIVOICE_BASE}/queue/data?session_hash=${sessionHash}`,
{ headers: accessToken ? { Authorization: `Bearer ${accessToken}` } : {} }
);
const reader = streamRes.body.getReader();
const decoder = new TextDecoder();
let buffer = "";
while (true) {
const { done, value } = await reader.read();
if (done) break;
buffer += decoder.decode(value, { stream: true });
const lines = buffer.split("\n\n");
buffer = lines.pop();
for (const line of lines) {
if (!line.startsWith("data: ")) continue;
const data = JSON.parse(line.slice(6));
if (data.msg === "estimation") showStatus("info", `In queue (position ${data.rank})...`);
else if (data.msg === "process_starts") { showStatus("info", "Processing..."); progressFill.style.width = "75%"; }
else if (data.msg === "log") showStatus("info", data.log);
else if (data.msg === "progress" && data.progress_data?.length) {
const p = data.progress_data[0];
if (p.length) {
progressFill.style.width = `${Math.round((p.index / p.length) * 90) + 10}%`;
showStatus("info", p.desc || `Step ${p.index}/${p.length}`);
}
} else if (data.msg === "process_completed") {
progressFill.style.width = "100%";
if (data.success) {
const wallSec = (Date.now() - t0) / 1000;
resultAudioUrl = data.output.data[0].url;
abSegments[idx].url = resultAudioUrl; abSegments[idx].status = "done"; abSetRowStatus(idx, "done");
document.getElementById("audio-player").src = resultAudioUrl;
document.getElementById("player-title").textContent = text.slice(0, 60) + (text.length > 60 ? "..." : "");
setPlayerMeta("", selectedVoice.name, `${text.length} chars`); // prefix="" → uses bare "audio-player"/"player-meta" ids
result.classList.add("visible");
showStatus("success", `Generated in ${wallSec.toFixed(1)}s`);
addToHistory(text, selectedVoice.name, wallSec, resultAudioUrl);
refreshQuota();
} else {
const errMsg = data.output?.error || "Generation failed";
showStatusWithCTA(errMsg);
}
}
}
}
} catch (err) {
showStatusWithCTA(err.message);
} finally {
btn.disabled = false;
btn.classList.remove("loading");
setTimeout(() => { progressBar.classList.remove("visible"); updateGenerateBtn(); }, 2000);
}
};
// ── Adaptive synthesis document ──
// One continuous document: 1 segment = simple text field; 2+ segments morph into
// per-line chips + controls and combine into a single audio file.
let abSegments = []; // [{ text, voiceId, status, url }] voiceId "" = inherit default voice
let abVoiceOptions = []; // [{ id, label, color, initial }]
let genResultBlob = null; // combined-MP3 blob, when multi-segment
let genResultUrl = null;
let abMenuIndex = -1;
const WORD_LIMIT = 150; // single paragraph beyond this → suggest breaking it down
async function synthVoiceOptions() {
const voices = await getVoices();
const usedPresetNames = new Set(voices.filter(v => v.isPreset).map(v => v.fileName.replace(/\.wav$/, "")));
const opts = voices.map(v => ({ id: v.id, label: v.name, color: v.color, initial: (v.name[0] || "?") }));
PRESETS.filter(p => !usedPresetNames.has(p.name)).forEach(p =>
opts.push({ id: `preset:${p.name}`, label: `${p.name.replace("_", " ")}`, color: "#d97706", initial: p.name[0] }));
return opts;
}
async function initSynthDoc() {
abVoiceOptions = await synthVoiceOptions();
if (!abSegments.length) abSegments = [{ text: "", voiceId: "", status: "idle", url: null }];
renderAbRows();
abUpdateGenerateBtn();
}
function abUpdateGenerateBtn() {
const hasText = abSegments.some(s => s.text.trim());
const btn = document.getElementById("generate-btn");
if (btn) btn.disabled = !hasText || !selectedVoice;
}
function wordCount(t) { return (t.trim().match(/\S+/g) || []).length; }
function abUpdateCounts() {
const chars = abSegments.reduce((n, s) => n + s.text.length, 0);
const segs = abSegments.filter(s => s.text.trim()).length;
document.getElementById("char-count").textContent = chars;
document.getElementById("seg-count").textContent = segs;
document.getElementById("seg-stat").classList.toggle("visible", abSegments.length > 1);
document.getElementById("gen-doc").classList.toggle("simple", abSegments.length <= 1);
// suggest a break-down when it's still one very long paragraph
const single = abSegments.length === 1;
const longPara = single && wordCount(abSegments[0].text) >= WORD_LIMIT;
document.getElementById("gen-suggest").classList.toggle("visible", longPara);
abUpdateGenerateBtn();
}
function abEffectiveVoice(voiceId) {
if (!voiceId) {
if (!selectedVoice) return { color: "var(--surface3)", initial: "?", label: "No voice" };
return { color: selectedVoice.color, initial: (selectedVoice.name[0] || "?").toUpperCase(), label: selectedVoice.name };
}
const o = abVoiceOptions.find(x => x.id === voiceId);
if (!o) return { color: "var(--surface3)", initial: "?", label: "—" };
return { color: o.color, initial: (o.initial || "?").toUpperCase(), label: o.label };
}
// ── Caret helpers for the contenteditable lines ──
function abCaretOffset(el) {
const sel = window.getSelection();
if (!sel.rangeCount) return 0;
const r = sel.getRangeAt(0).cloneRange();
const pre = document.createRange();
pre.selectNodeContents(el);
pre.setEnd(r.endContainer, r.endOffset);
return pre.toString().length;
}
function abFocusRow(i, offset) {
const para = document.querySelector(`.ab-para[data-i="${i}"]`);
if (!para) return;
para.focus();
const sel = window.getSelection();
const range = document.createRange();
const len = (para.textContent || "").length;
const off = Math.max(0, Math.min(offset, len));
if (para.firstChild && para.firstChild.nodeType === 3) range.setStart(para.firstChild, off);
else range.setStart(para, 0);
range.collapse(true);
sel.removeAllRanges();
sel.addRange(range);
}
function renderAbRows() {
const doc = document.getElementById("gen-doc");
doc.innerHTML = "";
const multi = abSegments.length > 1;
abSegments.forEach((s, i) => {
const row = document.createElement("div");
row.className = "ab-row"; row.dataset.i = i;
const chip = document.createElement("button");
chip.type = "button";
chip.className = "ab-chip" + (s.voiceId ? " overridden" : "");
const eff = abEffectiveVoice(s.voiceId);
const av = document.createElement("span");
av.className = "ab-chip-av";
av.style.background = eff.color;
av.innerHTML = `<span>${eff.initial}</span><svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="3"><polyline points="6 9 12 15 18 9"/></svg>`;
const nm = document.createElement("span");
nm.className = "ab-chip-name";
nm.textContent = eff.label;
chip.appendChild(av); chip.appendChild(nm);
chip.title = `Voice: ${eff.label}${s.voiceId ? " (override)" : " (default)"} — click to change`;
chip.onmousedown = (e) => e.preventDefault();
chip.onclick = (e) => abOpenVoiceMenu(e, i);
const para = document.createElement("div");
para.className = "ab-para"; para.contentEditable = "true"; para.dataset.i = i;
para.textContent = s.text;
para.addEventListener("input", () => {
s.text = para.textContent;
if (s.status !== "idle") { s.status = "idle"; s.url = null; abSetRowStatus(i, "idle"); }
abUpdateCounts();
});
para.addEventListener("keydown", (e) => abParaKeydown(e, i));
para.addEventListener("paste", (e) => abParaPaste(e, i));
row.appendChild(chip); row.appendChild(para); row.appendChild(buildRowSide(s, i));
// "join with next" affordance between adjacent segments
if (multi && i < abSegments.length - 1) {
const join = document.createElement("button");
join.type = "button"; join.className = "ab-join"; join.title = "Join with the segment below";
join.innerHTML = '<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.5"><path d="M8 7l4 4 4-4"/><path d="M8 13l4 4 4-4"/></svg>';
join.onmousedown = (e) => e.preventDefault();
join.onclick = (e) => { e.stopPropagation(); abJoinNext(i); };
row.appendChild(join);
}
doc.appendChild(row);
});
abUpdateCounts();
}
const ICON_PLAY = '<svg viewBox="0 0 24 24" fill="currentColor"><polygon points="5 3 19 12 5 21 5 3"/></svg>';
const ICON_DL = '<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><path d="M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4"/><polyline points="7 10 12 15 17 10"/><line x1="12" y1="15" x2="12" y2="3"/></svg>';
function mkRowBtn(cls, title, html, onclick) {
const b = document.createElement("button");
b.type = "button"; b.className = cls; b.title = title; b.innerHTML = html;
b.onclick = onclick;
return b;
}
function buildRowSide(s, i) {
const side = document.createElement("div"); side.className = "ab-row-side";
const done = s.status === "done" && s.url;
// Play always works; it generates on the first run, then plays the cached audio.
const play = mkRowBtn("ab-play-one" + (done ? " ready" : ""), done ? "Play this segment" : "Generate & play this segment", ICON_PLAY, () => abGenOne(i));
if (s.status === "active") play.classList.add("busy");
// Download is only meaningful once the segment exists.
const dl = mkRowBtn("ab-dl-one", done ? "Download this segment" : "Generate this segment first to download", ICON_DL, () => abDownloadOne(i));
if (!done) dl.disabled = true;
side.appendChild(play); side.appendChild(dl);
const st = document.createElement("span");
st.className = "ab-row-status " + (s.status === "idle" ? "" : s.status);
st.textContent = s.status === "error" ? "✕" : s.status === "active" ? "…" : "";
side.appendChild(st);
side.appendChild(mkRowBtn("ab-row-del", "Remove segment", "", () => abRemoveRow(i)));
side.lastChild.textContent = "✕";
return side;
}
function abSetRowStatus(i, status) {
const row = document.querySelector(`.ab-row[data-i="${i}"]`);
if (!row || !abSegments[i]) return;
abSegments[i].status = status;
const oldSide = row.querySelector(".ab-row-side");
if (oldSide) row.replaceChild(buildRowSide(abSegments[i], i), oldSide);
}
function abParaKeydown(e, i) {
if (e.key === "Enter" && !e.shiftKey) {
e.preventDefault();
const off = abCaretOffset(e.target);
const cur = abSegments[i].text;
abSegments[i].text = cur.slice(0, off);
abSegments[i].status = "idle"; abSegments[i].url = null;
abSegments.splice(i + 1, 0, { text: cur.slice(off), voiceId: abSegments[i].voiceId, status: "idle", url: null });
renderAbRows();
abFocusRow(i + 1, 0);
} else if (e.key === "Backspace") {
const sel = window.getSelection();
if (sel.isCollapsed && abCaretOffset(e.target) === 0 && i > 0) {
e.preventDefault();
const prevLen = abSegments[i - 1].text.length;
abSegments[i - 1].text += abSegments[i].text;
abSegments[i - 1].status = "idle"; abSegments[i - 1].url = null;
abSegments.splice(i, 1);
renderAbRows();
abFocusRow(i - 1, prevLen);
}
}
}
function abParaPaste(e, i) {
e.preventDefault();
const text = (e.clipboardData || window.clipboardData).getData("text");
if (!text) return;
const off = abCaretOffset(e.target);
const cur = abSegments[i].text;
const before = cur.slice(0, off), after = cur.slice(off);
const parts = text.split(/\r?\n\s*\r?\n/).map(p => p.replace(/\s*\r?\n\s*/g, " ").trim());
abSegments[i].status = "idle"; abSegments[i].url = null;
if (parts.length <= 1) {
const ins = parts[0] || "";
abSegments[i].text = before + ins + after;
renderAbRows();
abFocusRow(i, (before + ins).length);
} else {
const vid = abSegments[i].voiceId;
abSegments[i].text = before + parts[0];
const tail = [];
for (let k = 1; k < parts.length; k++) {
const t = k === parts.length - 1 ? parts[k] + after : parts[k];
tail.push({ text: t, voiceId: vid, status: "idle", url: null });
}
abSegments.splice(i + 1, 0, ...tail);
renderAbRows();
abFocusRow(i + tail.length, parts[parts.length - 1].length);
}
}
window.abRemoveRow = function(i) {
if (abSegments.length <= 1) {
abSegments = [{ text: "", voiceId: "", status: "idle", url: null }];
renderAbRows();
abFocusRow(0, 0);
return;
}
abSegments.splice(i, 1);
renderAbRows();
abFocusRow(Math.max(0, i - 1), abSegments[Math.max(0, i - 1)].text.length);
};
window.abClearDoc = function() {
abSegments = [{ text: "", voiceId: "", status: "idle", url: null }];
renderAbRows();
abFocusRow(0, 0);
};
// Join a segment with the one below it into a single segment.
window.abJoinNext = function(i) {
if (i < 0 || i >= abSegments.length - 1) return;
const a = abSegments[i], b = abSegments[i + 1];
const sep = a.text.trim() && b.text.trim() ? " " : "";
a.text = a.text + sep + b.text;
a.status = "idle"; a.url = null;
abSegments.splice(i + 1, 1);
renderAbRows();
abFocusRow(i, a.text.length);
};
// Break one long paragraph into ~50-60 word segments, splitting only on sentence periods.
window.abBreakDown = function() {
const text = (abSegments[0]?.text || "").trim();
if (!text) return;
const sentences = text.split(/(?<=\.)\s+/).map(p => p.trim()).filter(Boolean);
const chunks = [];
let cur = "", curWords = 0;
for (const sen of sentences) {
const w = wordCount(sen);
if (curWords && curWords + w > 60) { chunks.push(cur.trim()); cur = ""; curWords = 0; }
cur += (cur ? " " : "") + sen;
curWords += w;
}
if (cur.trim()) chunks.push(cur.trim());
if (chunks.length <= 1) return;
abSegments = chunks.map(t => ({ text: t, voiceId: "", status: "idle", url: null }));
renderAbRows();
abFocusRow(0, 0);
};
// ── Per-segment voice override menu ──
window.abOpenVoiceMenu = function(e, i) {
e.stopPropagation();
const menu = document.getElementById("gen-voice-menu");
abMenuIndex = i;
const defLabel = abEffectiveVoice("").label;
const item = (id, label, color, initial, checked) =>
`<button onclick="abPickVoice(event, '${id}')">
<span class="ab-mav" style="background:${color}">${(initial || "?").toUpperCase()}</span>
<span>${label}${checked ? " ✓" : ""}</span>
</button>`;
let html = item("", `Default (${defLabel})`, "var(--surface3)", "↺", !abSegments[i].voiceId);
html += abVoiceOptions.map(o => item(o.id, o.label, o.color, o.initial, abSegments[i].voiceId === o.id)).join("");
menu.innerHTML = html;
const page = document.getElementById("page-synthesis");
const pr = page.getBoundingClientRect();
const cr = e.currentTarget.getBoundingClientRect();
menu.style.left = (cr.left - pr.left) + "px";
menu.style.top = (cr.bottom - pr.top + 4) + "px";
menu.classList.add("visible");
};
window.abPickVoice = function(e, id) {
e.stopPropagation();
if (abMenuIndex >= 0 && abSegments[abMenuIndex]) {
abSegments[abMenuIndex].voiceId = id;
renderAbRows();
}
document.getElementById("gen-voice-menu").classList.remove("visible");
abMenuIndex = -1;
};
document.addEventListener("click", () => {
document.getElementById("gen-voice-menu")?.classList.remove("visible");
});
// Generate a single segment (without playing) — caches the URL for reuse in the full run.
async function abEnsureGen(i) {
const s = abSegments[i];
if (!s || !s.text.trim()) return null;
if (s.status === "done" && s.url) return s.url;
if (!s.voiceId && !selectedVoice) throw new Error("Select a default voice first");
const lang = document.getElementById("lang-select").value;
const steps = parseInt(document.getElementById("setting-steps").value);
const speed = document.getElementById("setting-speed").value / 100;
s.status = "active"; abSetRowStatus(i, "active");
const voice = await resolveAbVoice(s.voiceId || selectedVoice.id);
const url = await omniClone(s.text, voice, lang, steps, speed);
s.url = url; s.status = "done"; abSetRowStatus(i, "done");
refreshQuota();
return url;
}
function genShowError(i, err) {
abSegments[i].status = "error"; abSetRowStatus(i, "error");
const statusEl = document.getElementById("status");
statusEl.className = "status-bar visible error";
statusEl.innerHTML = `<div class="status-text">Segment ${i + 1}: ${err.message}</div>`;
if (err.message.includes("GPU quota")) { refreshQuota(); statusEl.innerHTML = quotaErrorBodyHtml(err.message); }
}
// Generate a single segment and play it inline — verify a voice/segment before the full run.
window.abGenOne = async function(i) {
const s = abSegments[i];
if (!s || !s.text.trim()) return;
const row = document.querySelector(`.ab-row[data-i="${i}"]`);
const play = row?.querySelector(".ab-play-one");
play?.classList.add("busy");
try {
const url = await abEnsureGen(i);
if (url) new Audio(url).play();
} catch (err) {
genShowError(i, err);
} finally {
play?.classList.remove("busy");
}
};
// Download a single segment's audio, generating it first if needed.
window.abDownloadOne = async function(i) {
const s = abSegments[i];
if (!s || !s.text.trim()) return;
const row = document.querySelector(`.ab-row[data-i="${i}"]`);
const dl = row?.querySelector(".ab-dl-one");
dl?.classList.add("busy");
try {
const url = await abEnsureGen(i);
if (!url) return;
const blob = await fetch(url).then(r => r.blob());
const a = document.createElement("a");
a.href = URL.createObjectURL(blob);
a.download = `segment_${i + 1}.wav`;
a.click();
URL.revokeObjectURL(a.href);
} catch (err) {
genShowError(i, err);
} finally {
dl?.classList.remove("busy");
}
};
async function resolveAbVoice(voiceId) {
if (voiceId && voiceId.startsWith("preset:")) {
const name = voiceId.slice(7);
const data = await fetch(`samples/${name}.wav`).then(r => r.arrayBuffer());
return { audioData: data, audioType: "audio/wav", fileName: `${name}.wav`, name: name.replace("_", " ") };
}
const voices = await getVoices();
const v = voices.find(x => x.id === voiceId);
if (!v) throw new Error("Voice not found");
return v;
}
// Run one OmniVoice clone request, resolve to the generated audio URL.
async function omniClone(text, voice, lang, steps, speed) {
const blob = new Blob([voice.audioData], { type: voice.audioType || "audio/mpeg" });
const form = new FormData();
form.append("files", blob, voice.fileName);
const uploadRes = await fetch(`${OMNIVOICE_BASE}/upload`, {
method: "POST",
headers: accessToken ? { Authorization: `Bearer ${accessToken}` } : {},
body: form
});
const [uploadPath] = await uploadRes.json();
const sessionHash = crypto.randomUUID();
const joinRes = await fetch(`${OMNIVOICE_BASE}/queue/join`, {
method: "POST",
headers: { "Content-Type": "application/json", ...(accessToken ? { Authorization: `Bearer ${accessToken}` } : {}) },
body: JSON.stringify({
data: [text, lang,
{ path: uploadPath, meta: { _type: "gradio.FileData" }, orig_name: voice.fileName },
"", "", steps, 2.0, true, speed, 0, true, true],
fn_index: 0, session_hash: sessionHash
})
});
if (!joinRes.ok) throw new Error(`Queue join failed: ${joinRes.status}`);
const streamRes = await fetch(`${OMNIVOICE_BASE}/queue/data?session_hash=${sessionHash}`,
{ headers: accessToken ? { Authorization: `Bearer ${accessToken}` } : {} });
const reader = streamRes.body.getReader();
const decoder = new TextDecoder();
let buffer = "";
while (true) {
const { done, value } = await reader.read();
if (done) break;
buffer += decoder.decode(value, { stream: true });
const lines = buffer.split("\n\n");
buffer = lines.pop();
for (const line of lines) {
if (!line.startsWith("data: ")) continue;
const data = JSON.parse(line.slice(6));
if (data.msg === "process_completed") {
if (data.success) return data.output.data[0].url;
throw new Error(data.output?.error || "Generation failed");
}
}
}
throw new Error("Stream ended without result");
}
// Combine remote audio URLs into a single mono MP3 blob.
async function combineToMp3(urls, gapSec = 0.4) {
const ctx = new (window.AudioContext || window.webkitAudioContext)();
try {
const buffers = [];
for (const url of urls) {
const ab = await fetch(url).then(r => r.arrayBuffer());
buffers.push(await ctx.decodeAudioData(ab));
}
const sr = ctx.sampleRate;
const gap = Math.round(gapSec * sr);
let total = 0;
buffers.forEach((b, i) => { total += b.length + (i < buffers.length - 1 ? gap : 0); });
const mono = new Float32Array(total);
let off = 0;
buffers.forEach((b, i) => {
const ch0 = b.getChannelData(0);
if (b.numberOfChannels > 1) {
const ch1 = b.getChannelData(1);
for (let j = 0; j < b.length; j++) mono[off + j] = (ch0[j] + ch1[j]) / 2;
} else {
mono.set(ch0, off);
}
off += b.length + (i < buffers.length - 1 ? gap : 0);
});
const int16 = new Int16Array(mono.length);
for (let i = 0; i < mono.length; i++) {
const s = Math.max(-1, Math.min(1, mono[i]));
int16[i] = s < 0 ? s * 32768 : s * 32767;
}
const lamejs = await import("https://esm.sh/@breezystack/lamejs@1.2.7");
const enc = new lamejs.Mp3Encoder(1, sr, 128);
const block = 1152;
const parts = [];
for (let i = 0; i < int16.length; i += block) {
const mp3 = enc.encodeBuffer(int16.subarray(i, i + block));
if (mp3.length > 0) parts.push(new Uint8Array(mp3));
}
const end = enc.flush();
if (end.length > 0) parts.push(new Uint8Array(end));
const durSec = total / sr;
return { blob: new Blob(parts, { type: "audio/mpeg" }), durSec };
} finally {
ctx.close();
}
}
// Multi-segment run: generate each segment, then stitch into one MP3.
async function generateCombined() {
if (!selectedVoice) return;
const lang = document.getElementById("lang-select").value;
const btn = document.getElementById("generate-btn");
const progressBar = document.getElementById("progress-bar");
const progressFill = document.getElementById("progress-fill");
const result = document.getElementById("result");
const statusEl = document.getElementById("status");
btn.disabled = true;
btn.classList.add("loading");
result.classList.remove("visible");
progressBar.classList.add("visible");
progressFill.style.width = "0%";
const abShowStatus = (type, msg) => { statusEl.className = `status-bar visible ${type}`; statusEl.innerHTML = `<div class="status-text">${msg}</div>`; };
const t0 = Date.now();
try {
const todo = abSegments.map((s, i) => ({ s, i })).filter(x => x.s.text.trim());
const urls = [];
for (let n = 0; n < todo.length; n++) {
const { s: seg, i } = todo[n];
// reuse a segment already verified with ▷ to save quota
if (seg.status === "done" && seg.url) { urls.push(seg.url); progressFill.style.width = `${Math.round(((n + 1) / todo.length) * 85)}%`; continue; }
abShowStatus("info", `Generating segment ${n + 1} of ${todo.length}…`);
try {
const url = await abEnsureGen(i);
urls.push(url);
} catch (err) {
genShowError(i, err);
return;
}
progressFill.style.width = `${Math.round(((n + 1) / todo.length) * 85)}%`;
}
if (!urls.length) { abShowStatus("error", "Nothing to generate — add some text first."); return; }
abShowStatus("info", "Combining segments into one MP3…");
progressFill.style.width = "92%";
const { blob, durSec } = await combineToMp3(urls);
genResultBlob = blob;
if (genResultUrl) URL.revokeObjectURL(genResultUrl);
genResultUrl = URL.createObjectURL(blob);
resultAudioUrl = genResultUrl;
progressFill.style.width = "100%";
document.getElementById("audio-player").src = genResultUrl;
document.getElementById("player-title").textContent = `${urls.length} segments combined`;
setPlayerMeta("", `${Math.round(durSec)}s`, `${(blob.size / 1048576).toFixed(1)} MB MP3`);
result.classList.add("visible");
abShowStatus("success", `Audio ready in ${((Date.now() - t0) / 1000).toFixed(1)}s`);
addToHistory(todo.map(x => x.s.text).join(" "), selectedVoice.name, (Date.now() - t0) / 1000, genResultUrl);
} catch (err) {
abShowStatus("error", err.message);
} finally {
btn.disabled = false;
btn.classList.remove("loading");
setTimeout(() => { progressBar.classList.remove("visible"); }, 2000);
}
};
// ── Player ──
const audioEl = document.getElementById("audio-player");
window.togglePlay = function() { audioEl.paused ? audioEl.play() : audioEl.pause(); };
audioEl.addEventListener("play", () => { document.getElementById("play-icon").style.display = "none"; document.getElementById("pause-icon").style.display = "block"; });
audioEl.addEventListener("pause", () => { document.getElementById("play-icon").style.display = "block"; document.getElementById("pause-icon").style.display = "none"; });
window.downloadAudio = async function() {
if (genResultBlob && genResultUrl) { // combined multi-segment MP3
const a = document.createElement("a");
a.href = genResultUrl;
a.download = "zerolabs_speech.mp3";
a.click();
return;
}
if (!resultAudioUrl) return;
const blob = await fetch(resultAudioUrl).then(r => r.blob());
const a = document.createElement("a");
a.href = URL.createObjectURL(blob);
a.download = "zerolabs_output.wav";
a.click();
URL.revokeObjectURL(a.href);
};
// ── History ──
function addToHistory(text, voiceName, duration, url) {
history.unshift({ text, voiceName, duration, url, timestamp: Date.now() });
if (history.length > 50) history.pop();
localStorage.setItem("zl_history", JSON.stringify(history));
renderHistory();
}
function renderHistory() {
const c = document.getElementById("history-container");
if (!history.length) { c.innerHTML = '<div class="empty-state"><div class="empty-state-icon">🕐</div><div>No generations yet</div></div>'; return; }
c.innerHTML = '<div class="history-list">' + history.map((h, i) => {
const t = new Date(h.timestamp).toLocaleTimeString([], { hour: "2-digit", minute: "2-digit" });
const safeText = (h.text || "").replace(/</g, "<");
const playOrIcon = h.url
? `<button class="history-play" onclick="playHistory(${i})"><svg viewBox="0 0 24 24" fill="currentColor"><polygon points="5 3 19 12 5 21 5 3"/></svg></button>`
: `<div class="history-play" style="opacity:0.4;cursor:default"><svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><path d="M4 7V4h16v3"/><path d="M9 20h6"/><path d="M12 4v16"/></svg></div>`;
const action = h.url
? `<button class="history-download" onclick="downloadHistoryItem(${i})">Download</button>`
: `<button class="history-download" onclick="copyHistoryText(${i})">Copy</button>`;
return `<div class="history-item">
${playOrIcon}
<div class="history-info"><div class="history-text">${safeText}</div><div class="history-sub">${h.voiceName} · ${h.duration?.toFixed(1)}s · ${t}</div></div>
${action}
</div>`;
}).join("") + '</div>';
}
window.copyHistoryText = function(i) {
const h = history[i];
if (h?.text) navigator.clipboard.writeText(h.text);
};
window.playHistory = function(i) { const h = history[i]; if (h.url) { audioEl.src = h.url; audioEl.play(); } };
window.downloadHistoryItem = async function(i) {
const h = history[i]; if (!h.url) return;
try { const b = await fetch(h.url).then(r=>r.blob()); const a=document.createElement("a"); a.href=URL.createObjectURL(b); a.download=`zerolabs_${i}.wav`; a.click(); URL.revokeObjectURL(a.href); } catch {}
};
// ── Global keybindings ──
document.addEventListener("keydown", e => {
if (e.key === "Escape" && document.querySelector(".modal-overlay.visible")) {
e.preventDefault();
closeModal();
return;
}
if ((e.metaKey || e.ctrlKey) && e.key === "Enter") {
const activePage = document.querySelector(".page.active");
if (!activePage) return;
const btn = activePage.querySelector(".btn-generate");
if (btn && !btn.disabled) {
e.preventDefault();
btn.click();
}
}
});
// ── Init ──
initOAuth();
</script>
</body>
</html>
|