Spaces:
Running on Zero
Running on Zero
File size: 41,445 Bytes
c2a69f5 2c6404d c2a69f5 db8cff9 c2a69f5 db8cff9 2c6404d db8cff9 c2a69f5 0d0185f c2a69f5 db8cff9 c2a69f5 0d0185f db8cff9 c2a69f5 f108f27 db8cff9 0d0185f 27faf0f 0d0185f 7b05c4f db8cff9 c2a69f5 0d0185f 7b05c4f db8cff9 0d0185f db8cff9 7b05c4f db8cff9 7b05c4f db8cff9 7b05c4f 27faf0f 7b05c4f db8cff9 7b05c4f db8cff9 7b05c4f db8cff9 7b05c4f db8cff9 7b05c4f db8cff9 7b05c4f db8cff9 7b05c4f db8cff9 7b05c4f db8cff9 27faf0f db8cff9 27faf0f db8cff9 27faf0f db8cff9 7b05c4f db8cff9 27faf0f db8cff9 7b05c4f db8cff9 27faf0f db8cff9 7b05c4f db8cff9 7b05c4f db8cff9 7b05c4f db8cff9 7b05c4f db8cff9 7b05c4f db8cff9 7b05c4f db8cff9 7b05c4f db8cff9 7b05c4f db8cff9 c2a69f5 db8cff9 7b05c4f db8cff9 7b05c4f db8cff9 0d0185f db8cff9 2c6404d db8cff9 2c6404d db8cff9 2c6404d c2a69f5 db8cff9 2c6404d db8cff9 c2a69f5 db8cff9 c2a69f5 db8cff9 27faf0f db8cff9 27faf0f db8cff9 0d0185f db8cff9 c2a69f5 db8cff9 c2a69f5 db8cff9 c2a69f5 f12cb60 db8cff9 fedd281 db8cff9 fedd281 db8cff9 27faf0f db8cff9 27faf0f fedd281 db8cff9 fedd281 db8cff9 fedd281 db8cff9 fedd281 db8cff9 fedd281 db8cff9 fedd281 db8cff9 fedd281 db8cff9 27faf0f db8cff9 2c6404d 27faf0f f12cb60 2c6404d db8cff9 2c6404d fedd281 db8cff9 c2a69f5 db8cff9 c2a69f5 9652c03 c2a69f5 0d0185f db8cff9 7b05c4f db8cff9 7b05c4f 0d0185f db8cff9 0d0185f c2a69f5 7b05c4f db8cff9 7b05c4f db8cff9 7b05c4f db8cff9 7b05c4f 27faf0f 7b05c4f f12cb60 7b05c4f db8cff9 7b05c4f db8cff9 7b05c4f db8cff9 2c6404d db8cff9 0d0185f 2c6404d db8cff9 f12cb60 db8cff9 27faf0f db8cff9 c2a69f5 0d0185f 2c6404d db8cff9 27faf0f c2a69f5 db8cff9 7b05c4f db8cff9 0d0185f db8cff9 2c6404d f12cb60 fedd281 db8cff9 f12cb60 c2a69f5 0d0185f fedd281 2c6404d 7b05c4f 2c6404d db8cff9 0d0185f db8cff9 0d0185f c2a69f5 db8cff9 2c6404d db8cff9 c2a69f5 2c6404d c2a69f5 db8cff9 c2a69f5 fedd281 2c6404d c2a69f5 f12cb60 c2a69f5 2c6404d d7a4755 2c6404d db8cff9 c2a69f5 f12cb60 db8cff9 0d0185f db8cff9 2c6404d db8cff9 2c6404d db8cff9 2c6404d db8cff9 d7a4755 2c6404d d7a4755 fedd281 db8cff9 2c6404d db8cff9 fedd281 2c6404d f12cb60 2c6404d f12cb60 2c6404d db8cff9 2c6404d db8cff9 2c6404d 27faf0f 7b05c4f fedd281 2c6404d db8cff9 7b05c4f db8cff9 7b05c4f db8cff9 c2a69f5 2c6404d db8cff9 7b05c4f 2c6404d 27faf0f db8cff9 27faf0f db8cff9 2c6404d c2a69f5 db8cff9 c2a69f5 f12cb60 c2a69f5 2c6404d c2a69f5 d7a4755 f12cb60 db8cff9 fedd281 2c6404d f12cb60 fedd281 c2a69f5 f12cb60 d7a4755 db8cff9 c2a69f5 2c6404d db8cff9 0d0185f 2c6404d 0d0185f 2c6404d db8cff9 c2a69f5 0d0185f f108f27 0d0185f d7a4755 27faf0f 0d0185f c2a69f5 2c6404d db8cff9 c2a69f5 f108f27 c2a69f5 db8cff9 c2a69f5 d7a4755 2c6404d 0d0185f c2a69f5 27faf0f f12cb60 c2a69f5 | 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 | <!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<title>GEPARD STUDIO</title>
<link rel="preconnect" href="https://fonts.googleapis.com" />
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin />
<link href="https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&family=JetBrains+Mono:wght@400;500&display=swap" rel="stylesheet" />
<style>
:root {
--bg: #fafafa;
--bg-elev: #ffffff;
--bg-elev-2: #f5f5f7;
--bg-input: #ffffff;
--bg-viewport: #ffffff;
--line: #e5e5ea;
--line-strong: #d1d1d6;
--line-hairline: #ececef;
--text: #1d1d1f;
--text-dim: #6e6e73;
--text-faint: #a1a1a6;
--text-label: #3a3a3c;
--accent: #f97316;
--accent-hover: #ea580c;
--accent-soft: rgba(249, 115, 22, 0.08);
--accent-text: #c2410c;
--red: #dc2626;
--green: #16a34e;
--hl-bg: rgba(249, 115, 22, 0.16);
--hl-text: #c2410c;
--radius-sm: 6px;
--radius: 10px;
--radius-lg: 16px;
--radius-pill: 999px;
--shadow-sm: 0 1px 2px rgba(0,0,0,0.04);
--shadow: 0 1px 3px rgba(0,0,0,0.06), 0 8px 24px rgba(0,0,0,0.04);
--shadow-lg: 0 4px 12px rgba(0,0,0,0.08), 0 24px 48px rgba(0,0,0,0.06);
}
* { box-sizing: border-box; }
html, body {
margin: 0; padding: 0;
background: var(--bg);
color: var(--text);
font-family: "Inter", -apple-system, BlinkMacSystemFont, "SF Pro Display", "SF Pro Text", ui-sans-serif, system-ui, sans-serif;
font-size: 14px;
line-height: 1.5;
min-height: 100vh;
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
letter-spacing: -0.005em;
}
body { display: flex; flex-direction: column; min-height: 100vh; }
.mono { font-family: "JetBrains Mono", ui-monospace, "SF Mono", Menlo, monospace; font-variant-numeric: tabular-nums; }
/* ===== Top bar ===== */
.topbar {
display: flex; align-items: center; justify-content: space-between;
height: 52px; padding: 0 20px;
background: rgba(255, 255, 255, 0.8);
backdrop-filter: saturate(180%) blur(20px);
-webkit-backdrop-filter: saturate(180%) blur(20px);
border-bottom: 1px solid var(--line-hairline);
position: sticky; top: 0; z-index: 10;
}
.brand { display: flex; align-items: center; gap: 10px; }
.brand .logo {
width: 26px; height: 26px;
background: linear-gradient(135deg, #fbbf24, #f97316, #dc2626);
border-radius: 7px;
display: inline-flex; align-items: center; justify-content: center;
font-size: 13px; color: #fff; font-weight: 700;
box-shadow: 0 1px 2px rgba(0,0,0,0.1);
}
.brand .name { font-size: 15px; font-weight: 600; letter-spacing: -0.01em; }
.brand .name .accent {
background: linear-gradient(90deg, #f97316, #dc2626);
-webkit-background-clip: text; background-clip: text; color: transparent;
}
.project-info {
display: flex; align-items: center; gap: 12px; margin-left: 18px;
padding-left: 18px; border-left: 1px solid var(--line-hairline);
}
.project-info .name { font-size: 13px; font-weight: 500; color: var(--text-dim); }
.stage-pill {
display: inline-flex; align-items: center; gap: 6px;
padding: 4px 10px;
background: var(--bg-elev-2);
border-radius: var(--radius-pill);
font-size: 11px; font-weight: 500;
color: var(--text-dim);
}
.stage-pill .dot {
width: 6px; height: 6px; border-radius: 50%;
background: var(--text-faint);
}
.stage-pill .dot.live { background: var(--accent); box-shadow: 0 0 6px rgba(249,115,22,0.5); }
.stage-pill .dot.playing { background: var(--green); box-shadow: 0 0 6px rgba(22,163,74,0.5); animation: pulse 1.4s ease-in-out infinite; }
@keyframes pulse { 0%,100%{opacity:1} 50%{opacity:0.4} }
/* ===== Viewport ===== */
.viewport {
margin: 16px 16px 0;
background: var(--bg-viewport);
border: 1px solid var(--line-hairline);
border-radius: var(--radius-lg);
box-shadow: var(--shadow);
overflow: hidden;
display: flex; flex-direction: column;
}
.viewport-head {
display: flex; align-items: center; justify-content: space-between;
padding: 12px 18px;
border-bottom: 1px solid var(--line-hairline);
}
.viewport-head .left, .viewport-head .right { display: flex; align-items: center; gap: 12px; }
.viewport-head .label {
font-size: 11px; font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase; color: var(--text-dim);
}
/* Lyrics + input combined */
.stage {
min-height: 280px;
background: var(--bg-viewport);
position: relative;
}
.stage .progress {
position: absolute; top: 0; left: 0; right: 0; height: 2px;
background: var(--line-hairline);
z-index: 2;
}
.stage .progress .fill {
height: 100%; width: 0;
background: linear-gradient(90deg, #fbbf24, #f97316, #dc2626);
transition: width 0.05s linear;
}
.stage .text {
padding: 56px 40px 48px;
font-size: 28px;
font-weight: 400;
line-height: 1.55;
color: var(--text);
letter-spacing: -0.015em;
max-width: 880px;
margin: 0 auto;
text-align: center;
outline: none;
min-height: 280px;
display: flex; align-items: center; justify-content: center;
flex-wrap: wrap;
}
.stage .text:focus { outline: none; }
.stage .text[data-empty="true"]::before {
content: attr(data-placeholder);
color: var(--text-faint);
font-weight: 300;
pointer-events: none;
width: 100%;
}
.stage .text .word {
display: inline-block;
padding: 2px 4px;
margin: 0 1px;
border-radius: 6px;
color: rgba(29, 29, 31, 0.32);
transition: color 0.2s ease, background-color 0.2s ease, transform 0.2s ease;
}
.stage .text .word.past { color: rgba(29, 29, 31, 0.55); }
.stage .text .word.current {
color: var(--hl-text);
background: var(--hl-bg);
transform: scale(1.04);
}
/* Transport (compact) */
.transport {
display: flex; align-items: center; gap: 14px;
padding: 10px 18px;
border-top: 1px solid var(--line-hairline);
}
.transport-btns { display: flex; align-items: center; gap: 6px; }
.transport-btns button {
appearance: none; border: 0;
background: transparent; color: var(--text-dim);
cursor: pointer;
display: flex; align-items: center; justify-content: center;
transition: all 0.15s;
border-radius: var(--radius-sm);
}
.transport-btns button:hover:not(:disabled) { color: var(--text); background: var(--bg-elev-2); }
.transport-btns button:disabled { color: var(--text-faint); cursor: not-allowed; }
.transport-btns .skip { width: 30px; height: 30px; font-size: 11px; }
.transport-btns .play {
width: 36px; height: 36px; font-size: 13px;
background: var(--text); color: var(--bg-viewport);
box-shadow: 0 1px 2px rgba(0,0,0,0.1);
}
.transport-btns .play:hover:not(:disabled) { background: #000; }
.transport-btns .play:disabled { background: var(--line); color: var(--text-faint); box-shadow: none; }
.timecode {
font-family: "JetBrains Mono", ui-monospace, "SF Mono", Menlo, monospace;
font-variant-numeric: tabular-nums;
font-size: 13px; font-weight: 500;
color: var(--text);
letter-spacing: 0.02em;
}
.timecode .sep { color: var(--text-faint); margin: 0 2px; }
.timecode .dur { color: var(--text-dim); }
.transport .spacer { flex: 1; }
.transport .info {
font-size: 12px;
color: var(--text-dim);
}
.transport .info .k { color: var(--text-faint); margin-right: 4px; }
.transport .info .v { color: var(--text); font-weight: 500; }
/* ===== Console (single panel) ===== */
.console {
margin: 14px 16px 16px;
background: var(--bg-elev);
border: 1px solid var(--line-hairline);
border-radius: var(--radius-lg);
box-shadow: var(--shadow);
overflow: hidden;
}
.console-body {
padding: 16px 18px 18px;
display: flex; flex-direction: column; gap: 14px;
}
/* Row 1: Source + voice + advanced */
.row-source {
display: grid;
grid-template-columns: auto 1fr auto;
gap: 10px;
align-items: center;
}
.seg {
display: inline-flex;
background: var(--bg-elev-2);
border-radius: var(--radius-sm);
padding: 2px;
}
.seg button {
appearance: none; border: 0; background: transparent;
color: var(--text-dim);
padding: 6px 12px;
border-radius: 5px;
font: inherit; font-weight: 500; font-size: 13px;
cursor: pointer; transition: all 0.15s;
}
.seg button.active {
background: var(--bg-elev);
color: var(--text);
box-shadow: 0 1px 2px rgba(0,0,0,0.06), 0 0 0 1px var(--line);
}
.seg button:not(.active):hover { color: var(--text); }
select {
width: 100%;
background: var(--bg-elev-2);
border: 1px solid transparent;
border-radius: var(--radius-sm);
color: var(--text);
font: inherit; font-size: 13px;
padding: 7px 12px;
outline: none;
transition: all 0.15s;
appearance: none;
background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%23a1a1a6' stroke-width='2'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
background-repeat: no-repeat;
background-position: right 10px center;
padding-right: 28px;
}
select:focus { border-color: var(--line-strong); background-color: var(--bg-elev); }
.advanced-toggle {
appearance: none; border: 0; background: transparent;
color: var(--text-dim); font: inherit; font-size: 12px;
font-weight: 500;
padding: 6px 10px;
cursor: pointer;
border-radius: var(--radius-sm);
transition: all 0.15s;
display: inline-flex; align-items: center; gap: 6px;
}
.advanced-toggle:hover { color: var(--text); background: var(--bg-elev-2); }
.advanced-toggle .chevron {
width: 10px; height: 10px;
transition: transform 0.2s;
}
.advanced-toggle.open .chevron { transform: rotate(180deg); }
/* Ref uploader (compact inline) */
.ref-inline {
margin-top: 10px;
display: grid;
grid-template-columns: 1fr auto;
gap: 8px;
align-items: center;
}
.file-drop {
border: 1px dashed var(--line-strong);
border-radius: var(--radius-sm);
padding: 8px 12px;
text-align: center;
color: var(--text-dim);
font-size: 12px;
cursor: pointer;
transition: all 0.15s;
}
.file-drop:hover, .file-drop.drag { border-color: var(--accent); color: var(--accent-text); background: var(--accent-soft); }
.file-name { font-size: 11px; color: var(--accent-text); margin-top: 4px; }
/* Reference uploader tabs */
.ref-tabs {
display: inline-flex;
background: var(--bg-elev-2);
border-radius: var(--radius-sm);
padding: 2px;
margin-bottom: 8px;
}
.ref-tab {
appearance: none; border: 0; background: transparent;
color: var(--text-dim);
padding: 5px 12px;
border-radius: 5px;
font: inherit; font-weight: 500; font-size: 12px;
cursor: pointer; transition: all 0.15s;
}
.ref-tab.active {
background: var(--bg-elev);
color: var(--text);
box-shadow: 0 1px 2px rgba(0,0,0,0.06), 0 0 0 1px var(--line);
}
.ref-tab:not(.active):hover { color: var(--text); }
.ref-panel.hidden { display: none; }
/* Mic UI */
.mic-ui {
display: flex; align-items: center; gap: 12px;
padding: 12px;
background: var(--bg-elev-2);
border-radius: var(--radius-sm);
}
.mic-btn {
appearance: none; border: 0;
width: 44px; height: 44px;
border-radius: 50%;
background: var(--bg-elev);
color: var(--text-dim);
cursor: pointer;
display: flex; align-items: center; justify-content: center;
border: 1px solid var(--line);
transition: all 0.15s;
flex-shrink: 0;
}
.mic-btn:hover { color: var(--text); border-color: var(--line-strong); }
.mic-btn.recording {
background: var(--red); color: white; border-color: transparent;
animation: micPulse 1.4s ease-in-out infinite;
}
.mic-btn.recording .mic-icon { color: white; }
.mic-icon { font-size: 14px; color: var(--text-dim); }
@keyframes micPulse {
0%, 100% { box-shadow: 0 0 0 0 rgba(220,38,38,0.4); }
50% { box-shadow: 0 0 0 8px rgba(220,38,38,0); }
}
.mic-info { flex: 1; min-width: 0; }
.mic-state { font-size: 12px; color: var(--text-dim); }
.mic-btn.recording + .mic-info .mic-state { color: var(--red); font-weight: 500; }
.mic-time { font-size: 14px; color: var(--text); font-weight: 500; margin-top: 2px; }
/* Advanced panel (collapsed by default) */
.advanced {
overflow: hidden;
max-height: 0;
transition: max-height 0.25s ease;
}
.advanced.open { max-height: 400px; }
.advanced-inner {
padding-top: 12px;
border-top: 1px solid var(--line-hairline);
margin-top: 4px;
}
.advanced-summary {
display: grid;
grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
gap: 8px 16px;
margin-bottom: 12px;
padding: 10px 14px;
background: var(--bg-elev-2);
border-radius: var(--radius-sm);
}
.advanced-summary .item {
display: flex; align-items: baseline; gap: 8px;
font-size: 12px;
}
.advanced-summary .item .k {
color: var(--text-faint);
text-transform: uppercase;
letter-spacing: 0.06em;
font-size: 10px;
font-weight: 600;
}
.advanced-summary .item .v {
color: var(--text);
font-family: "JetBrains Mono", ui-monospace, monospace;
font-size: 12px;
font-weight: 500;
}
.advanced-sliders {
display: grid;
grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
gap: 4px 20px;
}
.slider {
display: grid; grid-template-columns: 1fr auto; align-items: center; gap: 10px; padding: 4px 0;
}
.slider .name { font-size: 12px; color: var(--text-dim); }
.slider .val {
font-family: "JetBrains Mono", ui-monospace, monospace;
font-size: 12px; color: var(--text);
min-width: 48px; text-align: right;
font-variant-numeric: tabular-nums;
}
input[type="range"] {
-webkit-appearance: none; appearance: none;
width: 100%; height: 16px; background: transparent; cursor: pointer;
}
input[type="range"]::-webkit-slider-runnable-track {
height: 4px; background: var(--line); border-radius: 2px;
}
input[type="range"]::-webkit-slider-thumb {
-webkit-appearance: none; appearance: none;
width: 14px; height: 14px; border-radius: 50%;
background: var(--accent);
margin-top: -5px;
box-shadow: 0 0 0 3px var(--bg-elev), 0 1px 3px rgba(0,0,0,0.15);
cursor: pointer;
}
input[type="range"]::-moz-range-track { height: 4px; background: var(--line); border-radius: 2px; }
input[type="range"]::-moz-range-thumb {
width: 14px; height: 14px; border: 3px solid var(--bg-elev);
border-radius: 50%; background: var(--accent);
box-shadow: 0 1px 3px rgba(0,0,0,0.15);
cursor: pointer;
}
/* Row 2: Examples + Render (compact) */
.row-actions {
display: flex; align-items: center; gap: 14px;
flex-wrap: wrap;
}
.examples {
display: flex; flex-wrap: wrap; gap: 6px;
flex: 1; min-width: 0;
}
.example-chip {
appearance: none;
display: inline-flex; align-items: center; gap: 6px;
padding: 5px 10px;
background: var(--bg-elev-2);
border: 1px solid transparent;
border-radius: var(--radius-pill);
color: var(--text-dim);
font: inherit; font-size: 12px;
cursor: pointer;
transition: all 0.15s;
}
.example-chip:hover { border-color: var(--line); color: var(--text); background: var(--bg-elev); }
.example-chip .tag {
font-weight: 600;
color: var(--accent-text);
}
.example-chip .txt { max-width: 280px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.example-chip .status { font-size: 10px; color: var(--text-faint); margin-left: 2px; }
/* Compact render button */
.render-btn {
appearance: none; border: 0;
display: inline-flex; align-items: center; gap: 8px;
padding: 8px 16px;
border-radius: var(--radius-sm);
background: var(--text);
color: var(--bg-elev);
font: inherit; font-size: 13px; font-weight: 600;
cursor: pointer;
box-shadow: 0 1px 2px rgba(0,0,0,0.1);
transition: all 0.15s;
flex-shrink: 0;
}
.render-btn:hover:not(:disabled) { background: #000; transform: translateY(-1px); box-shadow: 0 4px 12px rgba(0,0,0,0.15); }
.render-btn:active:not(:disabled) { transform: translateY(0); }
.render-btn:disabled { background: var(--line); color: var(--text-faint); cursor: not-allowed; box-shadow: none; }
.render-btn .icon {
width: 14px; height: 14px;
display: inline-flex; align-items: center; justify-content: center;
}
.render-btn .spinner {
width: 12px; height: 12px;
border: 2px solid rgba(255,255,255,0.3);
border-top-color: currentColor;
border-radius: 50%;
animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
/* Toast */
.toast {
padding: 8px 12px;
border-radius: var(--radius-sm);
font-size: 12px;
background: #fef2f2;
border: 1px solid #fecaca;
color: #b91c1c;
}
.toast.hidden { display: none; }
/* ===== Mobile / Tablet ===== */
@media (max-width: 900px) {
.viewport { margin: 12px 12px 0; border-radius: 14px; }
.viewport-head { padding: 10px 14px; }
.console { margin: 12px 12px 12px; border-radius: 14px; }
.advanced-summary { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 600px) {
html, body { font-size: 15px; }
body { padding-bottom: env(safe-area-inset-bottom); }
/* Top bar — drop the project info, keep brand + stage pill */
.topbar { height: 48px; padding: 0 14px; }
.project-info { display: none; }
/* Viewport */
.viewport { margin: 8px 8px 0; border-radius: 12px; }
.viewport-head { padding: 10px 14px; }
.viewport-head .label { font-size: 10px; }
#voice-info { display: none; }
/* Stage — tighter padding, smaller type, more vertical room */
.stage { min-height: 240px; }
.stage .text {
padding: 40px 22px 36px;
font-size: 22px;
line-height: 1.5;
min-height: 240px;
}
/* Transport — full-width layout, info row hidden */
.transport { padding: 10px 14px; gap: 10px; flex-wrap: wrap; }
.transport-btns .skip { width: 36px; height: 36px; font-size: 12px; }
.transport-btns .play { width: 42px; height: 42px; font-size: 14px; }
.transport .spacer { flex: 1; }
.transport .info { display: none; }
.timecode { font-size: 14px; }
.timecode #dur-text { font-size: 12px; }
/* Console */
.console { margin: 10px 8px 12px; border-radius: 12px; }
.console-body { padding: 14px; gap: 12px; }
/* Source row — stack vertically */
.row-source {
grid-template-columns: 1fr;
gap: 8px;
}
.row-source .seg { width: 100%; }
.row-source .seg button { flex: 1; padding: 8px 12px; }
.row-source select { width: 100%; padding: 10px 14px; }
.row-source .advanced-toggle {
width: 100%;
justify-content: center;
padding: 10px 12px;
background: var(--bg-elev-2);
border-radius: var(--radius-sm);
}
/* Reference uploader */
.ref-inline {
grid-template-columns: 1fr;
gap: 6px;
}
.file-drop { padding: 12px; font-size: 13px; }
/* Advanced panel — single column */
.advanced-summary { grid-template-columns: repeat(2, 1fr); gap: 6px 10px; padding: 10px 12px; }
.advanced-summary .item { font-size: 11px; }
.advanced-sliders { grid-template-columns: 1fr; }
/* Actions row — examples wrap above, render full-width */
.row-actions {
flex-direction: column;
align-items: stretch;
gap: 10px;
}
.examples { order: 1; }
.example-chip { padding: 6px 11px; font-size: 12px; }
.render-btn {
order: 2;
width: 100%;
padding: 12px 16px;
font-size: 14px;
justify-content: center;
}
.toast { order: 3; }
/* Toast — slide up from bottom on mobile for visibility */
.toast {
position: fixed;
left: 12px; right: 12px; bottom: 12px;
margin: 0;
padding: 12px 16px;
border-radius: var(--radius);
box-shadow: var(--shadow-lg);
z-index: 20;
}
}
@media (max-width: 380px) {
.stage .text { font-size: 19px; padding: 32px 16px 28px; }
.advanced-summary { grid-template-columns: 1fr; }
}
</style>
</head>
<body>
<div class="topbar">
<div style="display: flex; align-items: center;">
<div class="brand">
<span class="logo">G</span>
<span class="name">GEPARD<span class="accent">.</span></span>
</div>
<div class="project-info">
<span class="name" id="project-name">Session</span>
</div>
</div>
<div class="stage-pill">
<span class="dot" id="stage-dot"></span>
<span id="stage-text">Ready</span>
</div>
</div>
<section class="viewport">
<div class="viewport-head">
<div class="left">
<span class="label">Script · Audio</span>
</div>
<div class="right">
<span class="mono" id="voice-info" style="font-size: 12px; color: var(--text-dim)">—</span>
</div>
</div>
<div class="stage">
<div class="progress"><div class="fill" id="progress-fill"></div></div>
<div class="text" id="text"
contenteditable="true"
spellcheck="false"
data-placeholder="Type or paste your script here, then press Render."
data-empty="true"></div>
</div>
<div class="transport">
<div class="transport-btns">
<button class="skip" id="stop-btn" type="button" title="Return to start" disabled>⏮</button>
<button class="play" id="play-btn" type="button" title="Play / Pause" disabled>▶</button>
<button class="skip" id="download-btn" type="button" title="Download WAV" disabled>↓</button>
</div>
<div class="timecode mono">
<span id="tc-s">00</span><span class="sep">:</span><span id="tc-f">00</span>
<span style="margin-left: 8px; font-size: 11px; color: var(--text-faint)" id="dur-text">0:00</span>
</div>
<div class="spacer"></div>
<div class="info">
<span class="k">Engine</span><span class="v">Gepard · 32 FSQ heads</span>
</div>
</div>
</section>
<section class="console">
<div class="console-body">
<div class="row-source">
<div class="seg" id="mode-seg">
<button id="mode-preset" class="active" type="button">Preset</button>
<button id="mode-clone" type="button">Clone</button>
</div>
<select id="speaker"></select>
<button class="advanced-toggle" id="advanced-toggle" type="button">
<span>Advanced</span>
<svg class="chevron" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.5" stroke-linecap="round" stroke-linejoin="round"><path d="M6 9l6 6 6-6"/></svg>
</button>
</div>
<div class="ref-inline hidden" id="ref-section">
<div class="ref-tabs">
<button class="ref-tab active" data-tab="upload" type="button">Upload</button>
<button class="ref-tab" data-tab="mic" type="button">Record</button>
</div>
<div class="ref-panel" data-panel="upload">
<div class="file-drop" id="drop">Drop clip · or click to upload</div>
<input type="file" id="file-input" accept="audio/*" hidden />
</div>
<div class="ref-panel hidden" data-panel="mic">
<div class="mic-ui" id="mic-ui">
<button class="mic-btn" id="mic-btn" type="button">
<span class="mic-icon" id="mic-icon">●</span>
</button>
<div class="mic-info">
<div class="mic-state" id="mic-state">Tap to record · ≤ 60s</div>
<div class="mic-time mono" id="mic-time">0:00</div>
</div>
</div>
</div>
<div class="file-name" id="file-name"></div>
</div>
<div class="advanced" id="advanced">
<div class="advanced-inner">
<div class="advanced-summary" id="advanced-summary"></div>
<div class="advanced-sliders" id="sliders"></div>
</div>
</div>
<div class="row-actions">
<div class="examples" id="examples"></div>
<button class="render-btn" id="render-btn" type="button">
<span class="icon" id="render-icon">▶</span>
<span id="render-label">Render</span>
</button>
</div>
<div class="toast hidden" id="toast"></div>
</div>
</section>
<script type="module">
import { Client, handle_file } from "https://cdn.jsdelivr.net/npm/@gradio/client/dist/index.min.js";
const $ = (id) => document.getElementById(id);
const els = {
stageDot: $("stage-dot"), stageText: $("stage-text"),
text: $("text"), progressFill: $("progress-fill"),
voiceInfo: $("voice-info"),
playBtn: $("play-btn"), stopBtn: $("stop-btn"),
tcS: $("tc-s"), tcF: $("tc-f"), durText: $("dur-text"),
modePreset: $("mode-preset"), modeClone: $("mode-clone"),
speaker: $("speaker"),
advancedToggle: $("advanced-toggle"), advanced: $("advanced"),
advancedSummary: $("advanced-summary"),
refSection: $("ref-section"),
drop: $("drop"), fileInput: $("file-input"), fileName: $("file-name"),
micBtn: $("mic-btn"), micIcon: $("mic-icon"), micState: $("mic-state"), micTime: $("mic-time"),
sliders: $("sliders"),
examples: $("examples"),
renderBtn: $("render-btn"), renderIcon: $("render-icon"), renderLabel: $("render-label"),
toast: $("toast"),
downloadBtn: $("download-btn"),
};
let cfg = null;
let client = null;
let mode = "preset";
let refFile = null;
let audioEl = new Audio();
let currentSubmission = null;
let wordSpans = [];
let hlRAF = null;
let isPlaying = false;
const sliderSpec = [
{ key: "temperature", label: "Temperature", fmt: v => Number(v).toFixed(2) },
{ key: "top_k", label: "Top-K", fmt: v => String(Math.round(v)) },
{ key: "max_frames", label: "Max Frames", fmt: v => String(Math.round(v)) },
{ key: "repetition_penalty", label: "Rep. Penalty", fmt: v => Number(v).toFixed(2) },
{ key: "repetition_window", label: "Rep. Window", fmt: v => String(Math.round(v)) },
];
const pad = (n, w = 2) => String(Math.floor(n)).padStart(w, "0");
const fmtTime = (s) => { if (!isFinite(s)) return "0:00"; const m = Math.floor(s / 60); const r = Math.floor(s % 60); return `${m}:${pad(s%60)}`; };
const setStage = (state, text) => {
els.stageDot.classList.remove("live", "playing");
if (state) els.stageDot.classList.add(state);
els.stageText.textContent = text;
};
const setBusy = (busy) => {
els.renderBtn.disabled = busy;
if (busy) {
els.renderIcon.innerHTML = '<span class="spinner"></span>';
els.renderLabel.textContent = "Rendering";
} else {
els.renderIcon.textContent = "▶";
els.renderLabel.textContent = "Render";
}
};
const showError = (msg) => { els.toast.textContent = msg; els.toast.classList.remove("hidden"); };
const clearError = () => { els.toast.classList.add("hidden"); els.toast.textContent = ""; };
// ---------- Mode ----------
const setMode = (m) => {
mode = m;
els.modePreset.classList.toggle("active", m === "preset");
els.modeClone.classList.toggle("active", m !== "preset");
els.refSection.classList.toggle("hidden", m !== "clone");
};
els.modePreset.addEventListener("click", () => setMode("preset"));
els.modeClone.addEventListener("click", () => setMode("clone"));
// ---------- Reference: upload tabs ----------
// Tab switching
document.querySelectorAll(".ref-tab").forEach(tab => {
tab.addEventListener("click", () => {
document.querySelectorAll(".ref-tab").forEach(t => t.classList.remove("active"));
tab.classList.add("active");
const target = tab.dataset.tab;
document.querySelectorAll(".ref-panel").forEach(p => {
p.classList.toggle("hidden", p.dataset.panel !== target);
});
});
});
// File drop / upload
els.drop.addEventListener("click", () => els.fileInput.click());
els.fileInput.addEventListener("change", (e) => { const f = e.target.files[0]; if (f) setRefFile(f); });
["dragenter", "dragover"].forEach(ev => els.drop.addEventListener(ev, (e) => { e.preventDefault(); els.drop.classList.add("drag"); }));
["dragleave", "drop"].forEach(ev => els.drop.addEventListener(ev, (e) => { e.preventDefault(); els.drop.classList.remove("drag"); }));
els.drop.addEventListener("drop", (e) => { const f = e.dataTransfer.files[0]; if (f) setRefFile(f); });
const setRefFile = (f) => { refFile = f; els.fileName.textContent = `✓ ${f.name}`; };
// ---------- Microphone recording (MediaRecorder API) ----------
let mediaRecorder = null;
let micStream = null;
let micChunks = [];
let micStartedAt = 0;
let micTimer = null;
const stopMic = () => {
if (mediaRecorder && mediaRecorder.state === "recording") {
mediaRecorder.stop();
}
if (micStream) {
micStream.getTracks().forEach(t => t.stop());
micStream = null;
}
if (micTimer) { clearInterval(micTimer); micTimer = null; }
els.micBtn.classList.remove("recording");
};
const startMic = async () => {
try {
micStream = await navigator.mediaDevices.getUserMedia({ audio: true });
} catch (err) {
showError(`Microphone access denied: ${err.message}`);
return;
}
micChunks = [];
mediaRecorder = new MediaRecorder(micStream);
mediaRecorder.ondataavailable = (e) => { if (e.data.size) micChunks.push(e.data); };
mediaRecorder.onstop = () => {
const blob = new Blob(micChunks, { type: "audio/webm" });
const file = new File([blob], `recording-${Date.now()}.webm`, { type: "audio/webm" });
setRefFile(file);
els.micState.textContent = "Recorded · ready to render";
};
mediaRecorder.start();
micStartedAt = Date.now();
els.micBtn.classList.add("recording");
els.micState.textContent = "Recording · tap to stop";
els.micTime.textContent = "0:00";
micTimer = setInterval(() => {
const elapsed = (Date.now() - micStartedAt) / 1000;
const max = cfg?.max_ref_seconds || 60;
if (elapsed >= max) { stopMic(); return; }
const m = Math.floor(elapsed / 60);
const s = Math.floor(elapsed % 60);
els.micTime.textContent = `${m}:${String(s).padStart(2, "0")}`;
}, 200);
};
els.micBtn.addEventListener("click", () => {
if (els.micBtn.classList.contains("recording")) stopMic();
else startMic();
});
// ---------- Advanced toggle ----------
els.advancedToggle.addEventListener("click", () => {
els.advancedToggle.classList.toggle("open");
els.advanced.classList.toggle("open");
});
// ---------- Script editor (combined input + lyrics) ----------
// Two modes:
// - idle (no audio loaded): editable contenteditable, shows placeholder
// - playing: highlights current word; clicking back into edit clears highlights
const updatePlaceholder = () => {
const txt = els.text.innerText.trim();
els.text.setAttribute("data-empty", txt.length === 0 ? "true" : "false");
};
els.text.addEventListener("input", () => {
updatePlaceholder();
clearHighlight();
});
els.text.addEventListener("focus", () => {
clearHighlight();
isPlaying = false;
});
els.text.addEventListener("blur", () => {
updatePlaceholder();
});
const scriptText = () => {
const t = els.text.innerText.trim();
return t.length === 0 ? "" : t;
};
// Tokenize the current text into word spans for highlighting
const tokenize = (text) => {
els.text.innerHTML = "";
wordSpans = [];
const tokens = text.split(/(\s+)/);
for (const tok of tokens) {
if (/^\s+$/.test(tok)) {
els.text.appendChild(document.createTextNode(tok));
} else if (tok.length) {
const span = document.createElement("span");
span.className = "word";
span.textContent = tok;
els.text.appendChild(span);
wordSpans.push(span);
}
}
updatePlaceholder();
};
const clearHighlight = () => {
wordSpans.forEach(s => s.classList.remove("current", "past"));
};
const setCurrentWord = (idx) => {
for (let i = 0; i < wordSpans.length; i++) {
const s = wordSpans[i];
s.classList.remove("current");
if (i < idx) s.classList.add("past");
else s.classList.remove("past");
}
if (idx >= 0 && idx < wordSpans.length) {
const cur = wordSpans[idx];
cur.classList.add("current");
cur.classList.remove("past");
}
};
// ---------- Sliders + summary ----------
const buildSliders = () => {
els.sliders.innerHTML = "";
els.advancedSummary.innerHTML = "";
sliderSpec.forEach(spec => {
const min = cfg.limits[`min_${spec.key}`];
const max = cfg.limits[`max_${spec.key}`];
const def = cfg.defaults[spec.key];
const step = spec.key === "temperature" || spec.key === "repetition_penalty" ? 0.01 : 1;
// Slider row
const row = document.createElement("div"); row.className = "slider";
row.innerHTML = `<span class="name">${spec.label}</span><span class="val mono" id="sv-${spec.key}">${spec.fmt(def)}</span><input type="range" id="sl-${spec.key}" min="${min}" max="${max}" step="${step}" value="${def}" style="grid-column: 1 / -1" />`;
els.sliders.appendChild(row);
const input = row.querySelector("input"), out = row.querySelector(".val");
input.addEventListener("input", () => {
out.textContent = spec.fmt(input.value);
updateSummary();
});
// Summary chip
const item = document.createElement("div"); item.className = "item";
item.innerHTML = `<span class="k">${spec.label}</span><span class="v" id="sum-${spec.key}">${spec.fmt(def)}</span>`;
els.advancedSummary.appendChild(item);
});
};
const updateSummary = () => {
sliderSpec.forEach(spec => {
const out = $(`sum-${spec.key}`);
if (out) out.textContent = spec.fmt(sliderValue(spec.key));
});
};
const sliderValue = (key) => Number($(`sl-${key}`).value);
// ---------- Player ----------
const loadAudio = (url, script, filename = "gepard.wav") => {
audioEl = new Audio(url);
audioEl.preload = "auto";
audioEl._downloadName = filename;
els.downloadBtn.disabled = false;
els.downloadBtn.onclick = () => {
const a = document.createElement("a");
a.href = url;
a.download = filename;
a.click();
};
audioEl.addEventListener("loadedmetadata", () => {
els.durText.textContent = fmtTime(audioEl.duration);
els.playBtn.disabled = false;
els.stopBtn.disabled = false;
setStage("", "Ready");
tokenize(script);
clearHighlight();
const voiceLabel = els.speaker.options[els.speaker.selectedIndex]?.textContent || "Cloned";
els.voiceInfo.textContent = voiceLabel;
});
audioEl.addEventListener("timeupdate", () => {
const t = audioEl.currentTime;
const d = audioEl.duration;
const fps = 24;
els.tcS.textContent = pad(t);
els.tcF.textContent = pad((t - Math.floor(t)) * fps);
const pct = d ? (t / d) * 100 : 0;
els.progressFill.style.width = `${pct}%`;
});
audioEl.addEventListener("play", () => {
els.playBtn.textContent = "❚❚";
isPlaying = true;
setStage("playing", "Playing");
});
audioEl.addEventListener("pause", () => {
els.playBtn.textContent = "▶";
isPlaying = false;
setStage("", "Paused");
});
audioEl.addEventListener("ended", () => {
els.playBtn.textContent = "▶";
isPlaying = false;
clearHighlight();
setStage("", "Ready");
});
};
els.playBtn.addEventListener("click", () => {
if (!audioEl.src) return;
if (audioEl.paused) audioEl.play();
else audioEl.pause();
});
els.stopBtn.addEventListener("click", () => {
if (!audioEl.src) return;
audioEl.pause();
audioEl.currentTime = 0;
clearHighlight();
});
els.text.addEventListener("click", () => {
// Allow normal editing on click
});
// Highlight loop (runs always, no-ops without audio)
const highlightLoop = () => {
if (isPlaying && audioEl.duration && wordSpans.length) {
const ratio = Math.min(1, audioEl.currentTime / audioEl.duration);
const idx = Math.min(wordSpans.length - 1, Math.floor(ratio * wordSpans.length));
setCurrentWord(idx);
}
hlRAF = requestAnimationFrame(highlightLoop);
};
// ---------- Examples ----------
// Cache: example_label -> { url, blob, script, speaker, filename }
const exampleCache = new Map();
const renderExamples = (items) => {
els.examples.innerHTML = "";
items.forEach(ex => {
const chip = document.createElement("button");
chip.type = "button"; chip.className = "example-chip";
chip.innerHTML = `<span class="tag">${ex.label}</span><span class="txt">${ex.text.slice(0,50)}${ex.text.length > 50 ? "…" : ""}</span><span class="status" data-status="${ex.label}"></span>`;
chip.addEventListener("click", async () => {
// Always pre-fill the script so the user can edit it
tokenize(ex.text);
els.text.focus();
const range = document.createRange();
range.selectNodeContents(els.text);
range.collapse(false);
const sel = window.getSelection();
sel.removeAllRanges(); sel.addRange(range);
setMode("preset");
els.speaker.value = ex.speaker;
const cached = exampleCache.get(ex.label);
if (cached) {
// Play the cached audio
loadAudio(cached.url, cached.script, cached.filename);
audioEl.addEventListener("loadedmetadata", () => audioEl.play(), { once: true });
} else {
// Fallback: synthesize now (slow first time, then becomes cached)
await synthesizeForExample(ex);
}
});
els.examples.appendChild(chip);
});
};
const synthesizeForExample = async (ex) => {
const args = {
mode: cfg.modes.preset,
speaker: ex.speaker,
ref_audio: null,
text: ex.text,
temperature: sliderValue("temperature"),
top_k: sliderValue("top_k"),
max_frames: sliderValue("max_frames"),
repetition_penalty: sliderValue("repetition_penalty"),
repetition_window: sliderValue("repetition_window"),
};
const statusEl = document.querySelector(`[data-status="${ex.label}"]`);
if (statusEl) statusEl.textContent = " · …";
try {
const sub = await client.submit("/synthesize", args);
for await (const event of sub) {
if (event.type === "data") {
const data = event.data?.[0];
if (data?.url) {
const resp = await fetch(data.url); const blob = await resp.blob();
const url = URL.createObjectURL(blob);
const filename = `gepard-${ex.speaker}-${ex.label.toLowerCase().replace(/\s+/g, "-")}.wav`;
exampleCache.set(ex.label, { url, blob, script: ex.text, speaker: ex.speaker, filename });
if (statusEl) statusEl.textContent = " · ✓";
loadAudio(url, ex.text, filename);
audioEl.addEventListener("loadedmetadata", () => audioEl.play(), { once: true });
}
}
}
} catch (err) {
if (statusEl) statusEl.textContent = " · !";
console.error(err);
}
};
// ---------- Submit ----------
els.renderBtn.addEventListener("click", async () => {
clearError();
const text = scriptText();
if (!text) { showError("Add some text to your script first."); els.text.focus(); return; }
if (mode === "preset" && !els.speaker.value) { showError("Choose a voice first."); return; }
if (mode === "clone" && !refFile) { showError("Upload a reference clip first."); return; }
const args = {
mode: mode === "preset" ? cfg.modes.preset : cfg.modes.clone,
speaker: mode === "preset" ? els.speaker.value : "",
ref_audio: mode === "clone" ? handle_file(refFile) : null,
text,
temperature: sliderValue("temperature"),
top_k: sliderValue("top_k"),
max_frames: sliderValue("max_frames"),
repetition_penalty: sliderValue("repetition_penalty"),
repetition_window: sliderValue("repetition_window"),
};
setBusy(true);
setStage("live", "Rendering");
try {
currentSubmission = await client.submit("/synthesize", args);
for await (const event of currentSubmission) {
if (event.type === "data") {
const data = event.data?.[0];
if (data?.url) {
const resp = await fetch(data.url); const blob = await resp.blob();
loadAudio(URL.createObjectURL(blob), text);
// Auto-play once loaded
audioEl.addEventListener("loadedmetadata", () => audioEl.play(), { once: true });
}
}
}
} catch (err) {
console.error(err); showError(err?.message || String(err));
setStage("", "Error");
} finally {
setBusy(false); currentSubmission = null;
}
});
// Enter to render when not editing text
els.text.addEventListener("keydown", (e) => {
if (e.key === "Enter" && (e.metaKey || e.ctrlKey)) {
e.preventDefault();
els.renderBtn.click();
}
});
// ---------- Boot ----------
(async () => {
cfg = await fetch("/config.json").then(r => r.json());
cfg.speakers.forEach(s => { const o = document.createElement("option"); o.value = s.key; o.textContent = s.label; els.speaker.appendChild(o); });
buildSliders();
renderExamples(cfg.examples);
client = await Client.connect(window.location.origin);
highlightLoop();
// Lazy cache: warm the first 3 examples in the background so first
// click is instant. Sequential to avoid GPU contention; failures are
// silent (next click will retry).
(async () => {
for (const ex of cfg.examples.slice(0, 3)) {
try { await synthesizeForExample(ex); } catch (e) { /* skip */ }
}
})();
})();
</script>
</body>
</html> |