From d2b23c680aad27df7fb2b1ef5016d0a84c8743ae Mon Sep 17 00:00:00 2001 From: lizacoma Date: Thu, 7 Dec 2023 20:46:25 +0200 Subject: [PATCH] fix: create text to speech [WTEL-4063] --- .../text-to-speech/api/TextToSpeechAPI.js | 26 +++++++++++-------- 1 file changed, 15 insertions(+), 11 deletions(-) diff --git a/src/modules/lookups/modules/media/modules/text-to-speech/api/TextToSpeechAPI.js b/src/modules/lookups/modules/media/modules/text-to-speech/api/TextToSpeechAPI.js index a7832045c..762064c51 100644 --- a/src/modules/lookups/modules/media/modules/text-to-speech/api/TextToSpeechAPI.js +++ b/src/modules/lookups/modules/media/modules/text-to-speech/api/TextToSpeechAPI.js @@ -1,24 +1,28 @@ import applyTransform, { notify, - snakeToCamel, + snakeToCamel, camelToSnake, generateUrl, } from '@webitel/ui-sdk/src/api/transformers'; -import { objCamelToSnake } from '@webitel/ui-sdk/src/scripts/caseConverters'; -import qs from 'query-string'; import instance from '../../../../../../../app/api/instance'; +const baseUrl = '/storage/tts/stream'; + const getTtsStreamUrl = (params, apiUrl = false) => { - const baseUrl = '/storage/tts/stream'; - let url = `${baseUrl}?${qs.stringify({ - ...objCamelToSnake(params), - access_token: instance.defaults.headers['X-Webitel-Access'], - })}`; - if (apiUrl) url = `${import.meta.env.VITE_API_URL}${url}`; + let url = applyTransform(params, [ + (params) => ({ + ...params, + access_token: instance.defaults.headers['X-Webitel-Access'],}), + camelToSnake(), + generateUrl(baseUrl), + ]); + + if (apiUrl) url = `${process.env.VUE_APP_API_URL}${url}`; + return url; }; const getTts = async (params) => { - const url = getTtsStreamUrl(params, true); - console.log('url:', url); + +const url = getTtsStreamUrl(params); try { const response = await instance.get(url);