Skip to content

Commit

Permalink
telugu
Browse files Browse the repository at this point in the history
  • Loading branch information
shubhattin committed Oct 28, 2024
1 parent 7ddefd5 commit 260ed16
Show file tree
Hide file tree
Showing 14 changed files with 59 additions and 31 deletions.
27 changes: 23 additions & 4 deletions src/app.scss
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
--theme-font-family-heading: 'Roboto', 'Nirmala UI', sans-serif;
}

$fonts: (
$fonts_multi: (
'Nirmala': (
'Nirmala UI',
'ttf'
Expand All @@ -30,7 +30,7 @@ $fonts: (
)
);

@each $file, $font in $fonts {
@each $file, $font in $fonts_multi {
@font-face {
font-family: nth($font, 1);
src:
Expand All @@ -51,9 +51,28 @@ $fonts: (
}
}

$fonts_variable: (
'NotoSerifTelugu': (
'Noto Serif Telugu',
'ttf'
)
);

@each $file, $font in $fonts_variable {
@font-face {
font-family: nth($font, 1);
src:
url('./fonts/variable/woff2/#{$file}.woff2') format('woff2'),
url('./fonts/variable/#{$file}.#{nth($font, 2)}');
// font-weight: normal;
font-style: normal;
font-display: swap;
}
}

.indic-font {
font-family: map-get($fonts, 'Nirmala');
font-family: map-get($fonts_multi, 'Nirmala');
}
.normal-font {
font-family: map-get($fonts, 'AdobeDevanagari');
font-family: map-get($fonts_multi, 'AdobeDevanagari');
}
27 changes: 15 additions & 12 deletions src/components/pages/main_page/ai/AIImageGenerator.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import Icon from '~/tools/Icon.svelte';
import { TiArrowBackOutline, TiArrowForwardOutline } from 'svelte-icons-pack/ti';
import { writable } from 'svelte/store';
import base_prompts from './base_prompt.yaml';
import ai_text_prompts from './ai_text_prompts.yaml';
import { SlideToggle } from '@skeletonlabs/skeleton';
import { client_q, type client } from '~/api/client';
import { lipi_parivartak_async } from '~/tools/converter';
Expand All @@ -22,6 +22,12 @@
import { OiCopy16 } from 'svelte-icons-pack/oi';
import { BsClipboard2Check } from 'svelte-icons-pack/bs';
let base_prompts = ai_text_prompts as {
main_prompt: {
role: 'user' | 'assistant';
content: string;
}[];
};
let kANDa_info = $derived(rAmAyaNam_map[$kANDa_selected - 1]);
let sarga_info = $derived(kANDa_info.sarga_data[$sarga_selected - 1]);
let shloka_count = $derived(sarga_info.shloka_count_extracted);
Expand All @@ -39,7 +45,7 @@
}
});
let shloka_numb = writable(1);
let base_user_prompt = writable<string>(base_prompts[0].content);
let base_user_prompt = writable<string>(base_prompts.main_prompt[0].content);
let auto_gen_image = writable(false);
let additional_prompt_info = writable('');
let shloka_text_prompt = writable('');
Expand All @@ -63,9 +69,6 @@
`This Shloka is from Chapter ${sarga_info.index} named ${sarga_info.name_normal}, which is from Book ${kANDa_info.index} ` +
`named ${kANDa_info.name_normal} from Ramayan, the ancient Indian Epic.`;
});
$effect(() => {
base_prompts[0].content = $base_user_prompt + $additional_prompt_info;
});
$effect(() => {
!$trans_en_data.isFetching &&
Expand All @@ -76,7 +79,6 @@
const shloka_text = $sarga_data.data![$shloka_numb];
const shloka_text_normal = await lipi_parivartak_async(shloka_text, BASE_SCRIPT, 'Normal');
let prompt = shloka_text + '\n' + shloka_text_normal;
const trans_en_all = $trans_en_data.data!;
if (trans_en_all.has($shloka_numb)) prompt += '\n\n' + trans_en_all.get($shloka_numb);
$shloka_text_prompt = prompt;
Expand All @@ -86,14 +88,15 @@
const generate_image_prompt = async () => {
await $image_prompt_mut.mutateAsync({
messages: [
...(base_prompts as {
role: 'user' | 'assistant';
content: string;
}[]),
{
role: 'user',
content: $shloka_text_prompt
}
content: base_prompts.main_prompt[0].content + $additional_prompt_info
},
{
role: 'assistant',
content: base_prompts.main_prompt[1].content
},
{ role: 'user', content: $shloka_text_prompt }
],
use_sample_data: load_ai_sample_data
});
Expand Down
9 changes: 9 additions & 0 deletions src/components/pages/main_page/ai/ai_text_prompts.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
main_prompt:
- role: user
content: >
I will be giving you a Sanskrit shloka along with its English translation from Valmiki Ramayanam. Generate a text prompt which can be used to generate consistent looking images that encapsulate the essence of the translation. Make the subjects, and the backgrounds realistic. If the description is abstract, maintain a sense of fantasy while portraying those abstract concepts. Set the scene in the appropriate location as the situation happens in the story of Ramayan across the landscapes of Ancient Bharat, and Sri Lanka. Keep People's faces and clothes in Ancient Indian Context. Make appropriate adjustments for any policy violations that might be generated from the resultant prompt.
- role: assistant
content: >
To create consistent image prompts that encapsulate the essence of the translations from Valmiki Ramayanam, I will aim to generate a detailed, descriptive prompt based on the meaning and context of each shloka. These prompts will focus on the visual elements of the scene described in the translation, while keeping the artistic and cultural essence intact.
Feel free to provide the shloka and translation when you're ready, and I'll start generating a suitable image prompt for it.
8 changes: 0 additions & 8 deletions src/components/pages/main_page/ai/base_prompt.yaml

This file was deleted.

2 changes: 1 addition & 1 deletion src/components/pages/main_page/image_tool/settings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ export const SHLOKA_FONT_CONFIG = {
text_for_min_line_height: 'qypgj'
},
Telugu: {
font: 'ADOBE_TELUGU',
font: 'NOTO_SERIF_TELUGU',
size: 1.0,
space_between_main_and_normal: 6,
text_for_min_line_height: 'వై'
Expand Down
2 changes: 1 addition & 1 deletion src/db/scripts/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import dotenv from 'dotenv';
import * as schema from '~/db/schema';
import { drizzle } from 'drizzle-orm/postgres-js';
import postgres from 'postgres';
import { dbMode } from '~/tools/kry_server';
import { dbMode } from '~/tools/kry.server';

dotenv.config({ path: '../../../.env.local' });

Expand Down
2 changes: 1 addition & 1 deletion src/db/scripts/export_data.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { dbClient_ext as db, queryClient } from './client';
import { readFile } from 'fs/promises';
import { dbMode, take_input } from '~/tools/kry_server';
import { dbMode, take_input } from '~/tools/kry.server';
import { translations, user_verification_requests, users } from '~/db/schema';
import {
UsersSchemaZod,
Expand Down
2 changes: 1 addition & 1 deletion src/db/scripts/import_data.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { dbClient_ext as db, queryClient } from './client';
import { writeFile } from 'fs/promises';
import { dbMode, make_dir, take_input } from '~/tools/kry_server';
import { dbMode, make_dir, take_input } from '~/tools/kry.server';

const main = async () => {
if (!(await confirm_environemnt())) return;
Expand Down
Binary file added src/fonts/bold/NotoSerifTeluguB.ttf
Binary file not shown.
Binary file added src/fonts/regular/NotoSerifTelugu.ttf
Binary file not shown.
Binary file added src/fonts/variable/NotoSerifTelugu.ttf
Binary file not shown.
Binary file added src/fonts/variable/woff2/NotoSerifTelugu.woff2
Binary file not shown.
11 changes: 8 additions & 3 deletions src/tools/font_tools.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@ export const FONT_FAMILY_NAME = {
NIRMALA_UI: 'Nirmala UI',
ADOBE_DEVANAGARI: 'Adobe Devanagari',
ROBOTO: 'Roboto',
ADOBE_TELUGU: 'Adobe Telugu'
ADOBE_TELUGU: 'Adobe Telugu',
NOTO_SERIF_TELUGU: 'Noto Serif Telugu'
};

type fonts_type = keyof typeof FONT_FAMILY_NAME;
Expand Down Expand Up @@ -56,6 +57,10 @@ const FONT_FILE_INFO: Record<
ADOBE_TELUGU: {
file_name: 'AdobeTelugu',
file_type: 'otf'
},
NOTO_SERIF_TELUGU: {
file_name: 'NotoSerifTelugu',
file_type: 'ttf'
}
};

Expand Down Expand Up @@ -93,8 +98,8 @@ const MAIN_FONT_CONFIG = {
size: 1.45
},
Telugu: {
font: 'ADOBE_TELUGU',
size: 1.3
font: 'NOTO_SERIF_TELUGU',
size: 1.25
},
English: {
font: 'ROBOTO'
Expand Down
File renamed without changes.

0 comments on commit 260ed16

Please sign in to comment.