Skip to content

Commit

Permalink
Merge branch 'v1.0' of github.com:AI4Bharat/ai4b-website into v1.0
Browse files Browse the repository at this point in the history
  • Loading branch information
Shanks0465 committed Sep 17, 2024
2 parents 5436703 + 4231cd6 commit b4a43bf
Show file tree
Hide file tree
Showing 14 changed files with 240 additions and 38 deletions.
111 changes: 111 additions & 0 deletions frontend/components/DatasetsPage.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,111 @@
"use client";
import { useState, useEffect } from "react";
import {
Box,
Button,
Container,
Flex,
Heading,
Icon,
Stack,
Text,
useColorModeValue,
} from "@chakra-ui/react";
import { ReactElement } from "react";
import {
FcAbout,
FcAssistant,
FcCollaboration,
FcDonate,
FcManager,
} from "react-icons/fc";

import Link from "next/link";

import { datasets } from "@/app/datasets/config";

import axios from "axios";
import { useQuery } from "react-query";
import { API_URL } from "@/app/config";

const fetchDatasets = async () => {
try {
const response = await axios.get(`${API_URL}/datasets/`, {});
return response.data;
} catch (error) {
console.error("Error fetching datasets:", error);
return [];
}
};

interface CardProps {
heading: string;
href: string;
}

function capitalizeFirstLetter(word: string) {
if (!word) return word;
return word.charAt(0).toUpperCase() + word.slice(1);
}

const Card = ({ heading, href }: CardProps) => {
return (
<Box
maxW={{ base: "full", md: "275px" }}
w={"full"}
borderWidth="1px"
borderRadius="lg"
overflow="hidden"
borderColor={"a4borange"}
p={5}
>
<Stack align={"start"} spacing={2}>
<Box mt={2}>
<Heading size="md">{heading}</Heading>
</Box>
<Link href={href}>
<Button variant={"link"} textColor={"a4borange"} size={"sm"}>
Learn more
</Button>
</Link>
</Stack>
</Box>
);
};

export default function DatasetsList() {
const [datasets, setDatasets] = useState([]);
const { isLoading, error, data } = useQuery("fetchDatasets", fetchDatasets);

useEffect(() => {
if (error || isLoading) {
setDatasets([]);
} else {
setDatasets(data);
}
}, [error, data, isLoading]);
return (
<Box p={4}>
<Stack spacing={4} as={Container} maxW={"3xl"} textAlign={"center"}>
<Heading fontSize={{ base: "2xl", sm: "4xl" }} fontWeight={"bold"}>
Datasets
</Heading>
<Text color={"gray.600"} fontSize={{ base: "sm", sm: "lg" }}>
Browse through the different datasets that we have built at AI4Bharat
</Text>
</Stack>

<Container maxW={"5xl"} mt={12}>
<Flex flexWrap="wrap" gridGap={6} justify="center">
{datasets.map((dataset: any) => (
<Card
key={dataset.title}
heading={capitalizeFirstLetter(dataset.title)}
href={dataset.website_link || ""}
/>
))}
</Flex>
</Container>
</Box>
);
}
3 changes: 3 additions & 0 deletions frontend/components/Feedback.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ export default function Feedback({
sourceLanguage,
targetLanguage,
domain,
track,
}: {
serviceId: string;
task: string;
Expand All @@ -82,6 +83,7 @@ export default function Feedback({
sourceLanguage: string;
targetLanguage: string;
domain: string;
track: boolean;
}) {
const { isOpen, onOpen, onClose } = useDisclosure();

Expand Down Expand Up @@ -160,6 +162,7 @@ export default function Feedback({
sourceLanguage: sourceLanguage,
targetLanguage: targetLanguage,
domain: domain,
track: track,
});
if (feedbackSubmitted) {
toast({
Expand Down
60 changes: 22 additions & 38 deletions frontend/components/Hero.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import {
useColorModeValue,
Divider,
Wrap,
HStack,
} from "@chakra-ui/react";
import Link from "next/link";
import { imagePrefix } from "@/app/config";
Expand All @@ -35,19 +36,27 @@ export default function Hero() {
direction={{ base: "column", md: "row" }}
>
<Stack flex={1} spacing={{ base: 5, md: 10 }}>
<Heading
lineHeight={1.1}
fontWeight={600}
fontSize={{ base: "3xl", sm: "4xl", lg: "6xl" }}
>
<Text as={"span"} color={"a4borange"} position={"relative"}>
Building AI
</Text>
<br />
<Text as={"span"} color={"a4bred"}>
for India!
</Text>
</Heading>
<HStack>
<Image
height={150}
width={150}
src={"/assets/logos/ai4bclogo.png"}
/>
<Heading
ml={5}
lineHeight={1.1}
fontWeight={600}
fontSize={{ base: "3xl", sm: "4xl", lg: "6xl" }}
>
<Text as={"span"} color={"a4borange"} position={"relative"}>
Building AI
</Text>
<br />
<Text as={"span"} color={"a4bred"}>
for India!
</Text>
</Heading>
</HStack>
<Text color={"black"}>
AI4Bharat, a research lab at IIT Madras, is dedicated to advancing
AI technology for Indian languages through open-source
Expand Down Expand Up @@ -157,28 +166,3 @@ export default function Hero() {
</Container>
);
}

const PlayIcon = createIcon({
displayName: "PlayIcon",
viewBox: "0 0 58 58",
d: "M28.9999 0.562988C13.3196 0.562988 0.562378 13.3202 0.562378 29.0005C0.562378 44.6808 13.3196 57.438 28.9999 57.438C44.6801 57.438 57.4374 44.6808 57.4374 29.0005C57.4374 13.3202 44.6801 0.562988 28.9999 0.562988ZM39.2223 30.272L23.5749 39.7247C23.3506 39.8591 23.0946 39.9314 22.8332 39.9342C22.5717 39.9369 22.3142 39.8701 22.0871 39.7406C21.86 39.611 21.6715 39.4234 21.5408 39.1969C21.4102 38.9705 21.3421 38.7133 21.3436 38.4519V19.5491C21.3421 19.2877 21.4102 19.0305 21.5408 18.8041C21.6715 18.5776 21.86 18.3899 22.0871 18.2604C22.3142 18.1308 22.5717 18.064 22.8332 18.0668C23.0946 18.0696 23.3506 18.1419 23.5749 18.2763L39.2223 27.729C39.4404 27.8619 39.6207 28.0486 39.7458 28.2713C39.8709 28.494 39.9366 28.7451 39.9366 29.0005C39.9366 29.2559 39.8709 29.507 39.7458 29.7297C39.6207 29.9523 39.4404 30.1391 39.2223 30.272Z",
});

const Blob = (props: IconProps) => {
return (
<Icon
width={"100%"}
viewBox="0 0 578 440"
fill="none"
xmlns="http://www.w3.org/2000/svg"
{...props}
>
<path
fillRule="evenodd"
clipRule="evenodd"
d="M239.184 439.443c-55.13-5.419-110.241-21.365-151.074-58.767C42.307 338.722-7.478 282.729.938 221.217c8.433-61.644 78.896-91.048 126.871-130.712 34.337-28.388 70.198-51.348 112.004-66.78C282.34 8.024 325.382-3.369 370.518.904c54.019 5.115 112.774 10.886 150.881 49.482 39.916 40.427 49.421 100.753 53.385 157.402 4.13 59.015 11.255 128.44-30.444 170.44-41.383 41.683-111.6 19.106-169.213 30.663-46.68 9.364-88.56 35.21-135.943 30.551z"
fill="currentColor"
/>
</Icon>
);
};
6 changes: 6 additions & 0 deletions frontend/components/Layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,12 @@ export default function Layout({
}>) {
return (
<html lang="en">
<head>
<meta
name="google-site-verification"
content="b1WctRF2NMXuJMYEFj300y6C86haSpYGcwiq2YXgyMM"
/>
</head>
<body className={inter.className}>
<ChakraProvider theme={theme}>
<QueryClientProvider client={queryClient}>
Expand Down
16 changes: 16 additions & 0 deletions frontend/components/TryOut/ASR.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import {
useToast,
VStack,
CircularProgress,
Switch,
} from "@chakra-ui/react";
import axios from "axios";
import { ChangeEventHandler, useRef, useState } from "react";
Expand Down Expand Up @@ -77,6 +78,7 @@ function FileUploadButton({
ref={inputRef}
onChange={handleFileChange}
display="none"
accept=".wav"
onClick={(event: any) => {
event.target.value = null;
}}
Expand All @@ -103,6 +105,7 @@ export default function ASR({ services }: { services: any }) {

const [success, setSuccess] = useState(false);
const [isLoading, setIsLoading] = useState(false);
const [tracking, setTracking] = useState(false);

const toast = useToast();

Expand Down Expand Up @@ -131,6 +134,7 @@ export default function ASR({ services }: { services: any }) {
samplingRate: samplingRate,
preProcessors: preProcessor,
postProcessors: postProcessor,
track: tracking,
});
setIsLoading(false);
if (response.status === 200) {
Expand Down Expand Up @@ -230,6 +234,7 @@ export default function ASR({ services }: { services: any }) {
samplingRate: samplingRate,
preProcessors: preProcessor,
postProcessors: postProcessor,
track: tracking,
});
setIsLoading(false);
if (response.status === 200) {
Expand Down Expand Up @@ -315,6 +320,7 @@ export default function ASR({ services }: { services: any }) {
)
)}
</Select>

{service !== "ai4bharat/conformer-multilingual-all--gpu-t4" ? (
<>
<FormLabel textColor={"gray.500"}>
Expand Down Expand Up @@ -380,6 +386,14 @@ export default function ASR({ services }: { services: any }) {
<FormHelperText>
Please Choose a domain for your audio. (For evaluation purposes)
</FormHelperText>
<FormLabel textColor={"gray.500"}>
Allow the AI to be improved by usage analysis.
</FormLabel>
<Switch
checked={tracking}
onChange={(e) => setTracking(e.target.checked)}
colorScheme="orange"
/>
</VStack>
<VStack p={5} w={"full"}>
<HStack>
Expand All @@ -391,6 +405,7 @@ export default function ASR({ services }: { services: any }) {
recorderControls={recorderControls}
/>
<FileUploadButton handleFileChange={handleFileChange} />
<FormHelperText>(Upload .wav files)</FormHelperText>
</HStack>
<Textarea value={outputText} isReadOnly></Textarea>
{success ? (
Expand All @@ -402,6 +417,7 @@ export default function ASR({ services }: { services: any }) {
sourceLanguage={sourceLanguage}
targetLanguage={""}
domain={domain}
track={tracking}
/>
) : (
<>
Expand Down
14 changes: 14 additions & 0 deletions frontend/components/TryOut/NMT.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,14 @@ const fetchTranslation = async ({
input,
task,
serviceId,
track,
}: {
sourceLanguage: string;
targetLanguage: string;
input: string;
task: string;
serviceId: string;
track: boolean;
}) => {
try {
const response = await axios.post(`${API_URL}/inference/translate`, {
Expand All @@ -38,6 +40,7 @@ const fetchTranslation = async ({
input: input,
task: task,
serviceId: serviceId,
track: track,
});
return response;
} catch (error: any) {
Expand All @@ -62,6 +65,7 @@ export default function NMT({ services }: { services: any }) {
const [outputText, setOutputText] = useState("");
const [success, setSuccess] = useState(false);
const [isLoading, setIsLoading] = useState(false);
const [tracking, setTracking] = useState(false);

const toast = useToast();

Expand Down Expand Up @@ -141,6 +145,14 @@ export default function NMT({ services }: { services: any }) {
onChange={() => setTransliteration(!transliteration)}
colorScheme={"orange"}
></Switch>
<FormLabel textColor={"gray.500"}>
Allow the AI to be improved by usage analysis.
</FormLabel>
<Switch
checked={tracking}
onChange={(e) => setTracking(e.target.checked)}
colorScheme="orange"
/>
</VStack>
</VStack>
<VStack w={"full"}>
Expand Down Expand Up @@ -176,6 +188,7 @@ export default function NMT({ services }: { services: any }) {
input: inputText,
task: "translation",
serviceId: service,
track: tracking,
});
setIsLoading(false);
if (response.status === 200) {
Expand Down Expand Up @@ -240,6 +253,7 @@ export default function NMT({ services }: { services: any }) {
sourceLanguage={sourceLanguage}
targetLanguage={targetLanguage}
domain="general"
track={tracking}
/>
) : (
<>
Expand Down
Loading

0 comments on commit b4a43bf

Please sign in to comment.