gnilets commited on
Commit
2658fe2
·
verified ·
1 Parent(s): 5bb5045

Update main.ts

Browse files
Files changed (1) hide show
  1. main.ts +13 -11
main.ts CHANGED
@@ -223,7 +223,10 @@ async function handleDemoRequest(req: Request) {
223
  <div id="audioPlayerContainer"></div>
224
  </div>
225
  <details>
226
- <summary>Примеры API</summary>
 
 
 
227
  <pre id="apiExamples"></pre>
228
  </details>
229
  </div>
@@ -294,20 +297,19 @@ async function handleDemoRequest(req: Request) {
294
 
295
  function createApiExamples() {
296
  const apiExamples = document.getElementById('apiExamples');
 
297
  const currentUrl = window.location.origin;
298
-
299
- const examples = \`
300
- получить список голосов:
301
- curl \${currentUrl}/v1/audio/models
302
-
303
- синтезировать голос из текста:
304
- curl 'https://gnilets-tts.hf.space/v1/audio/speech' \\\\\\\\\\
305
- -H 'content-type: application/json' \\\\\\\\\\
306
- --data-raw '{"model":"brian","input":"привет! хрю-хрю!","voice":"rate:0|pitch:0"}' \\\\\\\\\\
307
  -o tts_voice.mp3
308
  \`;
309
 
310
- apiExamples.textContent = examples;
 
 
311
  }
312
  createApiExamples();
313
  </script>
 
223
  <div id="audioPlayerContainer"></div>
224
  </div>
225
  <details>
226
+ <summary>api</summary>
227
+ <p>получить список голосов:</p>
228
+ <pre id="apiVoices"></pre>
229
+ <p>post-запрос для синтеза голоса из текста:</p>
230
  <pre id="apiExamples"></pre>
231
  </details>
232
  </div>
 
297
 
298
  function createApiExamples() {
299
  const apiExamples = document.getElementById('apiExamples');
300
+ const apiVoices = document.getElementById('apiVoices').value;
301
  const currentUrl = window.location.origin;
302
+ const voices_pre = \`curl \${currentUrl}/v1/audio/models\`;
303
+ const examples_pre = \`
304
+ curl 'https://gnilets-tts.hf.space/v1/audio/speech' \\\\\\\\
305
+ -H 'content-type: application/json' \\\\\\\\
306
+ --data-raw '{"model":"brian","input":"привет! хрю-хрю!","voice":"rate:0|pitch:0"}' \\\\\\\\
 
 
 
 
307
  -o tts_voice.mp3
308
  \`;
309
 
310
+ apiVoices.textContent = voices_pre.replace(/\\\\\\\\/g, '\\\\');;
311
+ apiExamples.textContent = examples_pre.replace(/\\\\\\\\/g, '\\\\');;
312
+
313
  }
314
  createApiExamples();
315
  </script>