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 9ec171858..730074b9c 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 @@ -2,13 +2,12 @@ import applyTransform, { camelToSnake, generateUrl, notify, - snakeToCamel, } from '@webitel/ui-sdk/src/api/transformers'; -import instance from '../../../../../../../app/api/instance'; -const baseUrl = '/storage/tts/stream'; +import instance from '../../../../../../../app/api/instance'; const getTtsStreamUrl = (params, apiUrl = false) => { + const baseUrl = '/storage/tts/stream'; let url = applyTransform(params, [ (params) => ({ ...params, @@ -17,21 +16,18 @@ const getTtsStreamUrl = (params, apiUrl = false) => { camelToSnake(), generateUrl(baseUrl), ]); - - if (apiUrl) url = `${process.env.VITE_API_URL}${url}`; - + if (apiUrl) url = `${import.meta.env.VITE_API_URL}${url}`; return url; }; const getTts = async (params) => { - const url = getTtsStreamUrl(params); + const url = getTtsStreamUrl(params, true); try { - const response = await instance.get(url); - return applyTransform(response.data, [ - snakeToCamel(), - ]); + const response = await fetch(url); + if (!response.ok) throw new Error(response.status); + return response.blob(); } catch (err) { throw applyTransform(err, [ notify(({ callback }) => callback({