Audio.svelte 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637
  1. <script lang="ts">
  2. import { toast } from 'svelte-sonner';
  3. import { createEventDispatcher, onMount, getContext } from 'svelte';
  4. const dispatch = createEventDispatcher();
  5. import { getBackendConfig } from '$lib/apis';
  6. import {
  7. getAudioConfig,
  8. updateAudioConfig,
  9. getModels as _getModels,
  10. getVoices as _getVoices
  11. } from '$lib/apis/audio';
  12. import { config } from '$lib/stores';
  13. import SensitiveInput from '$lib/components/common/SensitiveInput.svelte';
  14. import { TTS_RESPONSE_SPLIT } from '$lib/types';
  15. import type { Writable } from 'svelte/store';
  16. import type { i18n as i18nType } from 'i18next';
  17. const i18n = getContext<Writable<i18nType>>('i18n');
  18. export let saveHandler: () => void;
  19. // Audio
  20. let TTS_OPENAI_API_BASE_URL = '';
  21. let TTS_OPENAI_API_KEY = '';
  22. let TTS_API_KEY = '';
  23. let TTS_ENGINE = '';
  24. let TTS_MODEL = '';
  25. let TTS_VOICE = '';
  26. let TTS_SPLIT_ON: TTS_RESPONSE_SPLIT = TTS_RESPONSE_SPLIT.PUNCTUATION;
  27. let TTS_AZURE_SPEECH_REGION = '';
  28. let TTS_AZURE_SPEECH_OUTPUT_FORMAT = '';
  29. let STT_OPENAI_API_BASE_URL = '';
  30. let STT_OPENAI_API_KEY = '';
  31. let STT_ENGINE = '';
  32. let STT_MODEL = '';
  33. let STT_WHISPER_MODEL = '';
  34. let STT_DEEPGRAM_API_KEY = '';
  35. let STT_WHISPER_MODEL_LOADING = false;
  36. // eslint-disable-next-line no-undef
  37. let voices: SpeechSynthesisVoice[] = [];
  38. let models: Awaited<ReturnType<typeof _getModels>>['models'] = [];
  39. const getModels = async () => {
  40. if (TTS_ENGINE === '') {
  41. models = [];
  42. } else {
  43. const res = await _getModels(localStorage.token).catch((e) => {
  44. toast.error(`${e}`);
  45. });
  46. if (res) {
  47. console.log(res);
  48. models = res.models;
  49. }
  50. }
  51. };
  52. const getVoices = async () => {
  53. if (TTS_ENGINE === '') {
  54. const getVoicesLoop = setInterval(() => {
  55. voices = speechSynthesis.getVoices();
  56. // do your loop
  57. if (voices.length > 0) {
  58. clearInterval(getVoicesLoop);
  59. voices.sort((a, b) => a.name.localeCompare(b.name, $i18n.resolvedLanguage));
  60. }
  61. }, 100);
  62. } else {
  63. const res = await _getVoices(localStorage.token).catch((e) => {
  64. toast.error(`${e}`);
  65. });
  66. if (res) {
  67. console.log(res);
  68. voices = res.voices;
  69. voices.sort((a, b) => a.name.localeCompare(b.name, $i18n.resolvedLanguage));
  70. }
  71. }
  72. };
  73. const updateConfigHandler = async () => {
  74. const res = await updateAudioConfig(localStorage.token, {
  75. tts: {
  76. OPENAI_API_BASE_URL: TTS_OPENAI_API_BASE_URL,
  77. OPENAI_API_KEY: TTS_OPENAI_API_KEY,
  78. API_KEY: TTS_API_KEY,
  79. ENGINE: TTS_ENGINE,
  80. MODEL: TTS_MODEL,
  81. VOICE: TTS_VOICE,
  82. SPLIT_ON: TTS_SPLIT_ON,
  83. AZURE_SPEECH_REGION: TTS_AZURE_SPEECH_REGION,
  84. AZURE_SPEECH_OUTPUT_FORMAT: TTS_AZURE_SPEECH_OUTPUT_FORMAT
  85. },
  86. stt: {
  87. OPENAI_API_BASE_URL: STT_OPENAI_API_BASE_URL,
  88. OPENAI_API_KEY: STT_OPENAI_API_KEY,
  89. ENGINE: STT_ENGINE,
  90. MODEL: STT_MODEL,
  91. WHISPER_MODEL: STT_WHISPER_MODEL,
  92. DEEPGRAM_API_KEY: STT_DEEPGRAM_API_KEY
  93. }
  94. });
  95. if (res) {
  96. saveHandler();
  97. config.set(await getBackendConfig());
  98. }
  99. };
  100. const sttModelUpdateHandler = async () => {
  101. STT_WHISPER_MODEL_LOADING = true;
  102. await updateConfigHandler();
  103. STT_WHISPER_MODEL_LOADING = false;
  104. };
  105. onMount(async () => {
  106. const res = await getAudioConfig(localStorage.token);
  107. if (res) {
  108. console.log(res);
  109. TTS_OPENAI_API_BASE_URL = res.tts.OPENAI_API_BASE_URL;
  110. TTS_OPENAI_API_KEY = res.tts.OPENAI_API_KEY;
  111. TTS_API_KEY = res.tts.API_KEY;
  112. TTS_ENGINE = res.tts.ENGINE;
  113. TTS_MODEL = res.tts.MODEL;
  114. TTS_VOICE = res.tts.VOICE;
  115. TTS_SPLIT_ON = res.tts.SPLIT_ON || TTS_RESPONSE_SPLIT.PUNCTUATION;
  116. TTS_AZURE_SPEECH_OUTPUT_FORMAT = res.tts.AZURE_SPEECH_OUTPUT_FORMAT;
  117. TTS_AZURE_SPEECH_REGION = res.tts.AZURE_SPEECH_REGION;
  118. STT_OPENAI_API_BASE_URL = res.stt.OPENAI_API_BASE_URL;
  119. STT_OPENAI_API_KEY = res.stt.OPENAI_API_KEY;
  120. STT_ENGINE = res.stt.ENGINE;
  121. STT_MODEL = res.stt.MODEL;
  122. STT_WHISPER_MODEL = res.stt.WHISPER_MODEL;
  123. STT_DEEPGRAM_API_KEY = res.stt.DEEPGRAM_API_KEY;
  124. }
  125. await getVoices();
  126. await getModels();
  127. });
  128. </script>
  129. <form
  130. class="flex flex-col h-full justify-between space-y-3 text-sm"
  131. on:submit|preventDefault={async () => {
  132. await updateConfigHandler();
  133. dispatch('save');
  134. }}
  135. >
  136. <div class=" space-y-3 overflow-y-scroll scrollbar-hidden h-full">
  137. <div class="flex flex-col gap-3">
  138. <div>
  139. <div class=" mb-1 text-sm font-medium">{$i18n.t('STT Settings')}</div>
  140. <div class=" py-0.5 flex w-full justify-between">
  141. <div class=" self-center text-xs font-medium">{$i18n.t('Speech-to-Text Engine')}</div>
  142. <div class="flex items-center relative">
  143. <select
  144. class="dark:bg-gray-900 cursor-pointer w-fit pr-8 rounded px-2 p-1 text-xs bg-transparent outline-none text-right"
  145. bind:value={STT_ENGINE}
  146. placeholder="Select an engine"
  147. >
  148. <option value="">{$i18n.t('Whisper (Local)')}</option>
  149. <option value="openai">OpenAI</option>
  150. <option value="web">{$i18n.t('Web API')}</option>
  151. <option value="deepgram">Deepgram</option>
  152. </select>
  153. </div>
  154. </div>
  155. {#if STT_ENGINE === 'openai'}
  156. <div>
  157. <div class="mt-1 flex gap-2 mb-1">
  158. <input
  159. class="flex-1 w-full bg-transparent outline-none"
  160. placeholder={$i18n.t('API Base URL')}
  161. bind:value={STT_OPENAI_API_BASE_URL}
  162. required
  163. />
  164. <SensitiveInput placeholder={$i18n.t('API Key')} bind:value={STT_OPENAI_API_KEY} />
  165. </div>
  166. </div>
  167. <hr class=" dark:border-gray-850 my-2" />
  168. <div>
  169. <div class=" mb-1.5 text-sm font-medium">{$i18n.t('STT Model')}</div>
  170. <div class="flex w-full">
  171. <div class="flex-1">
  172. <input
  173. list="model-list"
  174. class="w-full rounded-lg py-2 px-4 text-sm bg-gray-50 dark:text-gray-300 dark:bg-gray-850 outline-none"
  175. bind:value={STT_MODEL}
  176. placeholder="Select a model"
  177. />
  178. <datalist id="model-list">
  179. <option value="whisper-1" />
  180. </datalist>
  181. </div>
  182. </div>
  183. </div>
  184. {:else if STT_ENGINE === 'deepgram'}
  185. <div>
  186. <div class="mt-1 flex gap-2 mb-1">
  187. <SensitiveInput placeholder={$i18n.t('API Key')} bind:value={STT_DEEPGRAM_API_KEY} />
  188. </div>
  189. </div>
  190. <hr class=" dark:border-gray-850 my-2" />
  191. <div>
  192. <div class=" mb-1.5 text-sm font-medium">{$i18n.t('STT Model')}</div>
  193. <div class="flex w-full">
  194. <div class="flex-1">
  195. <input
  196. class="w-full rounded-lg py-2 px-4 text-sm bg-gray-50 dark:text-gray-300 dark:bg-gray-850 outline-none"
  197. bind:value={STT_MODEL}
  198. placeholder="Select a model (optional)"
  199. />
  200. </div>
  201. </div>
  202. <div class="mt-2 mb-1 text-xs text-gray-400 dark:text-gray-500">
  203. {$i18n.t('Leave model field empty to use the default model.')}
  204. <a
  205. class=" hover:underline dark:text-gray-200 text-gray-800"
  206. href="https://developers.deepgram.com/docs/models"
  207. target="_blank"
  208. >
  209. {$i18n.t('Click here to see available models.')}
  210. </a>
  211. </div>
  212. </div>
  213. {:else if STT_ENGINE === ''}
  214. <div>
  215. <div class=" mb-1.5 text-sm font-medium">{$i18n.t('STT Model')}</div>
  216. <div class="flex w-full">
  217. <div class="flex-1 mr-2">
  218. <input
  219. class="w-full rounded-lg py-2 px-4 text-sm bg-gray-50 dark:text-gray-300 dark:bg-gray-850 outline-none"
  220. placeholder={$i18n.t('Set whisper model')}
  221. bind:value={STT_WHISPER_MODEL}
  222. />
  223. </div>
  224. <button
  225. class="px-2.5 bg-gray-50 hover:bg-gray-200 text-gray-800 dark:bg-gray-850 dark:hover:bg-gray-800 dark:text-gray-100 rounded-lg transition"
  226. on:click={() => {
  227. sttModelUpdateHandler();
  228. }}
  229. disabled={STT_WHISPER_MODEL_LOADING}
  230. >
  231. {#if STT_WHISPER_MODEL_LOADING}
  232. <div class="self-center">
  233. <svg
  234. class=" w-4 h-4"
  235. viewBox="0 0 24 24"
  236. fill="currentColor"
  237. xmlns="http://www.w3.org/2000/svg"
  238. >
  239. <style>
  240. .spinner_ajPY {
  241. transform-origin: center;
  242. animation: spinner_AtaB 0.75s infinite linear;
  243. }
  244. @keyframes spinner_AtaB {
  245. 100% {
  246. transform: rotate(360deg);
  247. }
  248. }
  249. </style>
  250. <path
  251. d="M12,1A11,11,0,1,0,23,12,11,11,0,0,0,12,1Zm0,19a8,8,0,1,1,8-8A8,8,0,0,1,12,20Z"
  252. opacity=".25"
  253. />
  254. <path
  255. d="M10.14,1.16a11,11,0,0,0-9,8.92A1.59,1.59,0,0,0,2.46,12,1.52,1.52,0,0,0,4.11,10.7a8,8,0,0,1,6.66-6.61A1.42,1.42,0,0,0,12,2.69h0A1.57,1.57,0,0,0,10.14,1.16Z"
  256. class="spinner_ajPY"
  257. />
  258. </svg>
  259. </div>
  260. {:else}
  261. <svg
  262. xmlns="http://www.w3.org/2000/svg"
  263. viewBox="0 0 16 16"
  264. fill="currentColor"
  265. class="w-4 h-4"
  266. >
  267. <path
  268. d="M8.75 2.75a.75.75 0 0 0-1.5 0v5.69L5.03 6.22a.75.75 0 0 0-1.06 1.06l3.5 3.5a.75.75 0 0 0 1.06 0l3.5-3.5a.75.75 0 0 0-1.06-1.06L8.75 8.44V2.75Z"
  269. />
  270. <path
  271. d="M3.5 9.75a.75.75 0 0 0-1.5 0v1.5A2.75 2.75 0 0 0 4.75 14h6.5A2.75 2.75 0 0 0 14 11.25v-1.5a.75.75 0 0 0-1.5 0v1.5c0 .69-.56 1.25-1.25 1.25h-6.5c-.69 0-1.25-.56-1.25-1.25v-1.5Z"
  272. />
  273. </svg>
  274. {/if}
  275. </button>
  276. </div>
  277. <div class="mt-2 mb-1 text-xs text-gray-400 dark:text-gray-500">
  278. {$i18n.t(`Open WebUI uses faster-whisper internally.`)}
  279. <a
  280. class=" hover:underline dark:text-gray-200 text-gray-800"
  281. href="https://github.com/SYSTRAN/faster-whisper"
  282. target="_blank"
  283. >
  284. {$i18n.t(
  285. `Click here to learn more about faster-whisper and see the available models.`
  286. )}
  287. </a>
  288. </div>
  289. </div>
  290. {/if}
  291. </div>
  292. <hr class=" dark:border-gray-800" />
  293. <div>
  294. <div class=" mb-1 text-sm font-medium">{$i18n.t('TTS Settings')}</div>
  295. <div class=" py-0.5 flex w-full justify-between">
  296. <div class=" self-center text-xs font-medium">{$i18n.t('Text-to-Speech Engine')}</div>
  297. <div class="flex items-center relative">
  298. <select
  299. class=" dark:bg-gray-900 w-fit pr-8 cursor-pointer rounded px-2 p-1 text-xs bg-transparent outline-none text-right"
  300. bind:value={TTS_ENGINE}
  301. placeholder="Select a mode"
  302. on:change={async (e) => {
  303. await updateConfigHandler();
  304. await getVoices();
  305. await getModels();
  306. if (e.target?.value === 'openai') {
  307. TTS_VOICE = 'alloy';
  308. TTS_MODEL = 'tts-1';
  309. } else {
  310. TTS_VOICE = '';
  311. TTS_MODEL = '';
  312. }
  313. }}
  314. >
  315. <option value="">{$i18n.t('Web API')}</option>
  316. <option value="transformers">{$i18n.t('Transformers')} ({$i18n.t('Local')})</option>
  317. <option value="openai">{$i18n.t('OpenAI')}</option>
  318. <option value="elevenlabs">{$i18n.t('ElevenLabs')}</option>
  319. <option value="azure">{$i18n.t('Azure AI Speech')}</option>
  320. </select>
  321. </div>
  322. </div>
  323. {#if TTS_ENGINE === 'openai'}
  324. <div>
  325. <div class="mt-1 flex gap-2 mb-1">
  326. <input
  327. class="flex-1 w-full bg-transparent outline-none"
  328. placeholder={$i18n.t('API Base URL')}
  329. bind:value={TTS_OPENAI_API_BASE_URL}
  330. required
  331. />
  332. <SensitiveInput placeholder={$i18n.t('API Key')} bind:value={TTS_OPENAI_API_KEY} />
  333. </div>
  334. </div>
  335. {:else if TTS_ENGINE === 'elevenlabs'}
  336. <div>
  337. <div class="mt-1 flex gap-2 mb-1">
  338. <input
  339. class="flex-1 w-full rounded-lg py-2 pl-4 text-sm bg-gray-50 dark:text-gray-300 dark:bg-gray-850 outline-none"
  340. placeholder={$i18n.t('API Key')}
  341. bind:value={TTS_API_KEY}
  342. required
  343. />
  344. </div>
  345. </div>
  346. {:else if TTS_ENGINE === 'azure'}
  347. <div>
  348. <div class="mt-1 flex gap-2 mb-1">
  349. <input
  350. class="flex-1 w-full rounded-lg py-2 pl-4 text-sm bg-gray-50 dark:text-gray-300 dark:bg-gray-850 outline-none"
  351. placeholder={$i18n.t('API Key')}
  352. bind:value={TTS_API_KEY}
  353. required
  354. />
  355. <input
  356. class="flex-1 w-full rounded-lg py-2 pl-4 text-sm bg-gray-50 dark:text-gray-300 dark:bg-gray-850 outline-none"
  357. placeholder={$i18n.t('Azure Region')}
  358. bind:value={TTS_AZURE_SPEECH_REGION}
  359. required
  360. />
  361. </div>
  362. </div>
  363. {/if}
  364. <hr class=" dark:border-gray-850 my-2" />
  365. {#if TTS_ENGINE === ''}
  366. <div>
  367. <div class=" mb-1.5 text-sm font-medium">{$i18n.t('TTS Voice')}</div>
  368. <div class="flex w-full">
  369. <div class="flex-1">
  370. <select
  371. class="w-full rounded-lg py-2 px-4 text-sm bg-gray-50 dark:text-gray-300 dark:bg-gray-850 outline-none"
  372. bind:value={TTS_VOICE}
  373. >
  374. <option value="" selected={TTS_VOICE !== ''}>{$i18n.t('Default')}</option>
  375. {#each voices as voice}
  376. <option
  377. value={voice.voiceURI}
  378. class="bg-gray-100 dark:bg-gray-700"
  379. selected={TTS_VOICE === voice.voiceURI}
  380. >{voice.name.replace('+', ', ')}</option
  381. >
  382. {/each}
  383. </select>
  384. </div>
  385. </div>
  386. </div>
  387. {:else if TTS_ENGINE === 'transformers'}
  388. <div>
  389. <div class=" mb-1.5 text-sm font-medium">{$i18n.t('TTS Model')}</div>
  390. <div class="flex w-full">
  391. <div class="flex-1">
  392. <input
  393. list="model-list"
  394. class="w-full rounded-lg py-2 px-4 text-sm bg-gray-50 dark:text-gray-300 dark:bg-gray-850 outline-none"
  395. bind:value={TTS_MODEL}
  396. placeholder="CMU ARCTIC speaker embedding name"
  397. />
  398. <datalist id="model-list">
  399. <option value="tts-1" />
  400. </datalist>
  401. </div>
  402. </div>
  403. <div class="mt-2 mb-1 text-xs text-gray-400 dark:text-gray-500">
  404. {$i18n.t(`Open WebUI uses SpeechT5 and CMU Arctic speaker embeddings.`)}
  405. To learn more about SpeechT5,
  406. <a
  407. class=" hover:underline dark:text-gray-200 text-gray-800"
  408. href="https://github.com/microsoft/SpeechT5"
  409. target="_blank"
  410. >
  411. {$i18n.t(`click here`, {
  412. name: 'SpeechT5'
  413. })}.
  414. </a>
  415. To see the available CMU Arctic speaker embeddings,
  416. <a
  417. class=" hover:underline dark:text-gray-200 text-gray-800"
  418. href="https://huggingface.co/datasets/Matthijs/cmu-arctic-xvectors"
  419. target="_blank"
  420. >
  421. {$i18n.t(`click here`)}.
  422. </a>
  423. </div>
  424. </div>
  425. {:else if TTS_ENGINE === 'openai'}
  426. <div class=" flex gap-2">
  427. <div class="w-full">
  428. <div class=" mb-1.5 text-sm font-medium">{$i18n.t('TTS Voice')}</div>
  429. <div class="flex w-full">
  430. <div class="flex-1">
  431. <input
  432. list="voice-list"
  433. class="w-full rounded-lg py-2 px-4 text-sm bg-gray-50 dark:text-gray-300 dark:bg-gray-850 outline-none"
  434. bind:value={TTS_VOICE}
  435. placeholder="Select a voice"
  436. />
  437. <datalist id="voice-list">
  438. {#each voices as voice}
  439. <option value={voice.id}>{voice.name}</option>
  440. {/each}
  441. </datalist>
  442. </div>
  443. </div>
  444. </div>
  445. <div class="w-full">
  446. <div class=" mb-1.5 text-sm font-medium">{$i18n.t('TTS Model')}</div>
  447. <div class="flex w-full">
  448. <div class="flex-1">
  449. <input
  450. list="tts-model-list"
  451. class="w-full rounded-lg py-2 px-4 text-sm bg-gray-50 dark:text-gray-300 dark:bg-gray-850 outline-none"
  452. bind:value={TTS_MODEL}
  453. placeholder="Select a model"
  454. />
  455. <datalist id="tts-model-list">
  456. {#each models as model}
  457. <option value={model.id} class="bg-gray-50 dark:bg-gray-700" />
  458. {/each}
  459. </datalist>
  460. </div>
  461. </div>
  462. </div>
  463. </div>
  464. {:else if TTS_ENGINE === 'elevenlabs'}
  465. <div class=" flex gap-2">
  466. <div class="w-full">
  467. <div class=" mb-1.5 text-sm font-medium">{$i18n.t('TTS Voice')}</div>
  468. <div class="flex w-full">
  469. <div class="flex-1">
  470. <input
  471. list="voice-list"
  472. class="w-full rounded-lg py-2 px-4 text-sm bg-gray-50 dark:text-gray-300 dark:bg-gray-850 outline-none"
  473. bind:value={TTS_VOICE}
  474. placeholder="Select a voice"
  475. />
  476. <datalist id="voice-list">
  477. {#each voices as voice}
  478. <option value={voice.id}>{voice.name}</option>
  479. {/each}
  480. </datalist>
  481. </div>
  482. </div>
  483. </div>
  484. <div class="w-full">
  485. <div class=" mb-1.5 text-sm font-medium">{$i18n.t('TTS Model')}</div>
  486. <div class="flex w-full">
  487. <div class="flex-1">
  488. <input
  489. list="tts-model-list"
  490. class="w-full rounded-lg py-2 px-4 text-sm bg-gray-50 dark:text-gray-300 dark:bg-gray-850 outline-none"
  491. bind:value={TTS_MODEL}
  492. placeholder="Select a model"
  493. />
  494. <datalist id="tts-model-list">
  495. {#each models as model}
  496. <option value={model.id} class="bg-gray-50 dark:bg-gray-700" />
  497. {/each}
  498. </datalist>
  499. </div>
  500. </div>
  501. </div>
  502. </div>
  503. {:else if TTS_ENGINE === 'azure'}
  504. <div class=" flex gap-2">
  505. <div class="w-full">
  506. <div class=" mb-1.5 text-sm font-medium">{$i18n.t('TTS Voice')}</div>
  507. <div class="flex w-full">
  508. <div class="flex-1">
  509. <input
  510. list="voice-list"
  511. class="w-full rounded-lg py-2 px-4 text-sm bg-gray-50 dark:text-gray-300 dark:bg-gray-850 outline-none"
  512. bind:value={TTS_VOICE}
  513. placeholder="Select a voice"
  514. />
  515. <datalist id="voice-list">
  516. {#each voices as voice}
  517. <option value={voice.id}>{voice.name}</option>
  518. {/each}
  519. </datalist>
  520. </div>
  521. </div>
  522. </div>
  523. <div class="w-full">
  524. <div class=" mb-1.5 text-sm font-medium">
  525. {$i18n.t('Output format')}
  526. <a
  527. href="https://learn.microsoft.com/en-us/azure/ai-services/speech-service/rest-text-to-speech?tabs=streaming#audio-outputs"
  528. target="_blank"
  529. >
  530. <small>{$i18n.t('Available list')}</small>
  531. </a>
  532. </div>
  533. <div class="flex w-full">
  534. <div class="flex-1">
  535. <input
  536. list="tts-model-list"
  537. class="w-full rounded-lg py-2 px-4 text-sm bg-gray-50 dark:text-gray-300 dark:bg-gray-850 outline-none"
  538. bind:value={TTS_AZURE_SPEECH_OUTPUT_FORMAT}
  539. placeholder="Select a output format"
  540. />
  541. </div>
  542. </div>
  543. </div>
  544. </div>
  545. {/if}
  546. <hr class="dark:border-gray-850 my-2" />
  547. <div class="pt-0.5 flex w-full justify-between">
  548. <div class="self-center text-xs font-medium">{$i18n.t('Response splitting')}</div>
  549. <div class="flex items-center relative">
  550. <select
  551. class="dark:bg-gray-900 w-fit pr-8 cursor-pointer rounded px-2 p-1 text-xs bg-transparent outline-none text-right"
  552. aria-label="Select how to split message text for TTS requests"
  553. bind:value={TTS_SPLIT_ON}
  554. >
  555. {#each Object.values(TTS_RESPONSE_SPLIT) as split}
  556. <option value={split}
  557. >{$i18n.t(split.charAt(0).toUpperCase() + split.slice(1))}</option
  558. >
  559. {/each}
  560. </select>
  561. </div>
  562. </div>
  563. <div class="mt-2 mb-1 text-xs text-gray-400 dark:text-gray-500">
  564. {$i18n.t(
  565. "Control how message text is split for TTS requests. 'Punctuation' splits into sentences, 'paragraphs' splits into paragraphs, and 'none' keeps the message as a single string."
  566. )}
  567. </div>
  568. </div>
  569. </div>
  570. </div>
  571. <div class="flex justify-end text-sm font-medium">
  572. <button
  573. class="px-3.5 py-1.5 text-sm font-medium bg-black hover:bg-gray-900 text-white dark:bg-white dark:text-black dark:hover:bg-gray-100 transition rounded-full"
  574. type="submit"
  575. >
  576. {$i18n.t('Save')}
  577. </button>
  578. </div>
  579. </form>