Skip to content

Commit

Permalink
fix: create text to speech [WTEL-4063]
Browse files Browse the repository at this point in the history
  • Loading branch information
lizacoma committed Dec 7, 2023
1 parent 43f389a commit d2b23c6
Showing 1 changed file with 15 additions and 11 deletions.
Original file line number Diff line number Diff line change
@@ -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);
Expand Down

0 comments on commit d2b23c6

Please sign in to comment.