File size: 1,665 Bytes
0b5c6fd adf1923 0b5c6fd adf1923 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 |
import {
imageToText,
genTextToSpeech,
getWavAudio,
uploadImage,
genTextToSpeechLang,
getTranslation, getAnswer,
} from "@/app/services";
import { useMutation} from "@tanstack/react-query";
export const useTextToSpeach = () => {
return useMutation({
mutationKey: ["text-to-speech"],
mutationFn: ({ text }: { text: string }) => genTextToSpeech({ text }),
});
};
export const useTextToSpeachLang = () => {
return useMutation({
mutationKey: ["text-to-speech-lang"],
mutationFn: ({ text, modal }: { text: string; modal: string }) =>
genTextToSpeechLang({ text, modal }),
});
};
export const useGenWav = () => {
return useMutation({
mutationKey: ["gen-wav"],
mutationFn: ({
sampling_rate,
audio,
name,
}: {
sampling_rate: number;
audio: Float32Array;
name: string;
}) => getWavAudio({ sampling_rate, audio, name }),
});
};
export const useImageToText = () => {
return useMutation({
mutationKey: ["image-to-text"],
mutationFn: ({ url }: { url: string }) => imageToText({ url }),
});
};
export const useUploadImage = () => {
return useMutation({
mutationKey: ["upload-image"],
mutationFn: ({ form }: { form: FormData }) => uploadImage({ form }),
});
};
export const useTranslator = () => {
return useMutation({
mutationKey: ["translator"],
mutationFn: ({ text, code }: { text: string; code: string }) =>
getTranslation({ text, code }),
});
};
export const useGetAnswer = () => {
return useMutation({
mutationKey: ["qa__"],
mutationFn: ({ text, key }: { text: string; key: string }) => getAnswer({ key, text})
})
} |