apolinario commited on
Commit
c6bc456
·
1 Parent(s): e4c1bcb

Rename voices, unique designed voice filenames, hide presets from Your Voices

Browse files
Files changed (1) hide show
  1. index.html +18 -3
index.html CHANGED
@@ -1284,15 +1284,17 @@ async function renderSidebarVoices() {
1284
  async function renderVoicesPage() {
1285
  const voices = await getVoices();
1286
  const grid = document.getElementById("voices-grid");
1287
- grid.innerHTML = voices.map(v => {
1288
  const date = new Date(v.createdAt).toLocaleDateString();
 
1289
  return `<div class="voice-tile">
1290
  <div class="voice-tile-date">${date}</div>
1291
  <div class="voice-tile-avatar" style="background:${v.color}">${v.name[0].toUpperCase()}</div>
1292
- <div class="voice-tile-name">${v.name}</div>
1293
  <div class="voice-tile-file">${v.fileName}</div>
1294
  <div class="voice-tile-actions">
1295
  <button class="voice-tile-btn use" onclick="selectVoiceAndGo('${v.id}')">Use Voice</button>
 
1296
  <button class="voice-tile-btn del" onclick="deleteVoiceFromPage('${v.id}')">Remove</button>
1297
  </div>
1298
  </div>`;
@@ -1326,6 +1328,19 @@ window.deleteVoice = async function(id) {
1326
 
1327
  window.deleteVoiceFromPage = window.deleteVoice;
1328
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1329
  function updateVoiceSelector() {
1330
  const avatar = document.getElementById("sel-voice-avatar");
1331
  const name = document.getElementById("sel-voice-name");
@@ -1730,7 +1745,7 @@ window.saveDesignVoice = async function() {
1730
  const voice = {
1731
  id: crypto.randomUUID(),
1732
  name,
1733
- fileName: "designed_voice.wav",
1734
  audioData: data,
1735
  audioType: "audio/wav",
1736
  color: COLORS[Math.floor(Math.random() * COLORS.length)],
 
1284
  async function renderVoicesPage() {
1285
  const voices = await getVoices();
1286
  const grid = document.getElementById("voices-grid");
1287
+ grid.innerHTML = voices.filter(v => !v.isPreset).map(v => {
1288
  const date = new Date(v.createdAt).toLocaleDateString();
1289
+ const escaped = v.name.replace(/'/g, "\\'").replace(/"/g, "&quot;");
1290
  return `<div class="voice-tile">
1291
  <div class="voice-tile-date">${date}</div>
1292
  <div class="voice-tile-avatar" style="background:${v.color}">${v.name[0].toUpperCase()}</div>
1293
+ <div class="voice-tile-name" id="vname-${v.id}">${v.name}</div>
1294
  <div class="voice-tile-file">${v.fileName}</div>
1295
  <div class="voice-tile-actions">
1296
  <button class="voice-tile-btn use" onclick="selectVoiceAndGo('${v.id}')">Use Voice</button>
1297
+ <button class="voice-tile-btn del" style="background:transparent;color:var(--text-muted);border:1px solid var(--border)" onclick="renameVoice('${v.id}','${escaped}')">Rename</button>
1298
  <button class="voice-tile-btn del" onclick="deleteVoiceFromPage('${v.id}')">Remove</button>
1299
  </div>
1300
  </div>`;
 
1328
 
1329
  window.deleteVoiceFromPage = window.deleteVoice;
1330
 
1331
+ window.renameVoice = async function(id, currentName) {
1332
+ const newName = prompt("Rename voice:", currentName);
1333
+ if (!newName || newName.trim() === "" || newName.trim() === currentName) return;
1334
+ const voices = await getVoices();
1335
+ const voice = voices.find(v => v.id === id);
1336
+ if (!voice) return;
1337
+ voice.name = newName.trim();
1338
+ await putVoice(voice);
1339
+ if (selectedVoice?.id === id) { selectedVoice = voice; updateVoiceSelector(); }
1340
+ renderSidebarVoices();
1341
+ renderVoicesPage();
1342
+ };
1343
+
1344
  function updateVoiceSelector() {
1345
  const avatar = document.getElementById("sel-voice-avatar");
1346
  const name = document.getElementById("sel-voice-name");
 
1745
  const voice = {
1746
  id: crypto.randomUUID(),
1747
  name,
1748
+ fileName: `designed_voice_${Date.now()}.wav`,
1749
  audioData: data,
1750
  audioType: "audio/wav",
1751
  color: COLORS[Math.floor(Math.random() * COLORS.length)],