Audio.svelte 20 KB

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