Skip to content

Commit

Permalink
Merge pull request #96 from AI4Bharat/dev
Browse files Browse the repository at this point in the history
Added New XLIT API
  • Loading branch information
Shanks0465 authored Dec 20, 2024
2 parents 245f8d1 + d077119 commit e418147
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 6 deletions.
15 changes: 13 additions & 2 deletions frontend/components/TryOut/NMT.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
"use client";
import { API_URL, LANGUAGE_CODE_NAMES } from "@/app/config";
import { IndicTransliterate } from "@ai4bharat/indic-transliterate";
import {
IndicTransliterate,
IndicTransliterateProps,
} from "@ai4bharat/indic-transliterate";
import {
Button,
Card,
Expand Down Expand Up @@ -52,6 +55,13 @@ interface LanguageCodeNames {
[key: string]: string;
}

interface CustomIndicTransliterateProps extends IndicTransliterateProps {
customApiURL?: string;
}

const CustomIndicTransliterate =
IndicTransliterate as React.ComponentType<CustomIndicTransliterateProps>;

export default function NMT({ services }: { services: any }) {
const [service, setService] = useState(Object.keys(services)[0]);
const [sourceLanguage, setSourceLanguage] = useState(
Expand Down Expand Up @@ -156,7 +166,8 @@ export default function NMT({ services }: { services: any }) {
</VStack>
</VStack>
<VStack w={"full"}>
<IndicTransliterate
<CustomIndicTransliterate
customApiURL={"https://xlit-api1.ai4bharat.org/tl/"}
enabled={sourceLanguage !== "en" && transliteration}
renderComponent={(props) => <Textarea {...props} />}
value={inputText}
Expand Down
15 changes: 13 additions & 2 deletions frontend/components/TryOut/TTS.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,10 @@ import {
import { LANGUAGE_CODE_NAMES } from "@/app/config";
import axios from "axios";
import { API_URL } from "@/app/config";
import { IndicTransliterate } from "@ai4bharat/indic-transliterate";
import {
IndicTransliterate,
IndicTransliterateProps,
} from "@ai4bharat/indic-transliterate";
import { useToast } from "@chakra-ui/react";
import Feedback from "../Feedback";

Expand Down Expand Up @@ -58,6 +61,13 @@ interface LanguageCodeNames {
[key: string]: string;
}

interface CustomIndicTransliterateProps extends IndicTransliterateProps {
customApiURL?: string;
}

const CustomIndicTransliterate =
IndicTransliterate as React.ComponentType<CustomIndicTransliterateProps>;

export default function TTS({ services }: { services: any }) {
const [service, setService] = useState(Object.keys(services)[0]);
const [sourceLanguage, setSourceLanguage] = useState(
Expand Down Expand Up @@ -171,7 +181,8 @@ export default function TTS({ services }: { services: any }) {
</VStack>
</VStack>
<VStack w={"full"}>
<IndicTransliterate
<CustomIndicTransliterate
customApiURL={"https://xlit-api1.ai4bharat.org/tl/"}
enabled={sourceLanguage !== "en" && transliteration}
renderComponent={(props) => <Textarea w={344} {...props} />}
value={inputText}
Expand Down
15 changes: 13 additions & 2 deletions frontend/components/TryOut/XLIT.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,24 @@ import {
useToast,
} from "@chakra-ui/react";
import { LANGUAGE_CODE_NAMES } from "@/app/config";
import { IndicTransliterate } from "@ai4bharat/indic-transliterate";
import {
IndicTransliterate,
IndicTransliterateProps,
} from "@ai4bharat/indic-transliterate";
import axios from "axios";
import { API_URL } from "@/app/config";

interface LanguageCodeNames {
[key: string]: string;
}

interface CustomIndicTransliterateProps extends IndicTransliterateProps {
customApiURL?: string;
}

const CustomIndicTransliterate =
IndicTransliterate as React.ComponentType<CustomIndicTransliterateProps>;

const fetchTransliteration = async ({
sourceLanguage,
targetLanguage,
Expand Down Expand Up @@ -127,7 +137,8 @@ export default function XLIT({ services }: { services: any }) {
</Select> */}
</VStack>
<VStack w={"full"}>
<IndicTransliterate
<CustomIndicTransliterate
customApiURL={"https://xlit-api1.ai4bharat.org/tl/"}
enabled={sourceLanguage !== "en"}
renderComponent={(props) => <Textarea {...props} />}
value={inputText}
Expand Down

0 comments on commit e418147

Please sign in to comment.