argodinho commited on
Commit
2e8f85a
·
verified ·
1 Parent(s): 62e10c5

updated app.py

Browse files
Files changed (1) hide show
  1. app.py +13 -13
app.py CHANGED
@@ -31,21 +31,21 @@ def hinglish_to_devnagri(text):
31
 
32
  response = gemini.generate_content(
33
  f"""
34
- Analyze this mixed-language text containing English and a regional language:
35
- "{text}"
36
-
37
- Perform:
38
- 1. Detect the regional language (e.g. Hindi, Tamil, Bengali) if you don't find regional language, convert to Hindi (pure devanagari script).
39
- 2. Convert to pure regional language script (Devanagari/Tamil/Bangla)
40
- 3. Preserve complex words (technical/medical terms) in their original form
41
- 4. Maintain natural flow and meaning
42
- 5. Remove the code if you find them in backticks ```.
43
 
44
  Rules:
45
- - Keep proper nouns unchanged
46
- - Use colloquial spellings (e.g. "कॉलेज" not "विद्यालय" for "college")
 
 
 
 
 
 
 
 
47
 
48
- Output ONLY the converted text in the detected script.
49
  """
50
  )
51
 
@@ -67,7 +67,7 @@ def generate_speech(text):
67
  print("\n🔊 Generating audio...")
68
  start_audio = time.time()
69
 
70
- desc = "एक महिला वक्ता स्पष्ट हिंदी में बोल रही हैं"
71
  desc_inputs = desc_tokenizer(desc, return_tensors="pt").to(device)
72
  text_inputs = tts_tokenizer(hindi_text, return_tensors="pt").to(device)
73
 
 
31
 
32
  response = gemini.generate_content(
33
  f"""
34
+ Convert the following English sentence to Hindi.
 
 
 
 
 
 
 
 
35
 
36
  Rules:
37
+ - The translation must be in Devanagari script.
38
+ - It should sound like what a normal Hindi speaker would say in daily life.
39
+ - Avoid formal or highly Sanskritized words.
40
+ - Keep proper nouns and technical/educational terms in English if commonly used that way (like 'if condition', 'laptop', etc.)
41
+ - Focus on fluency and ease of understanding.
42
+ - Remove the code if you find them in backticks ```.
43
+
44
+
45
+ Sentence:
46
+ "{text}"
47
 
48
+ Output ONLY the Hindi translation in Devanagari script.
49
  """
50
  )
51
 
 
67
  print("\n🔊 Generating audio...")
68
  start_audio = time.time()
69
 
70
+ desc = "एक महिला वक्ता हिंदी में बोल रही हैं"
71
  desc_inputs = desc_tokenizer(desc, return_tensors="pt").to(device)
72
  text_inputs = tts_tokenizer(hindi_text, return_tensors="pt").to(device)
73