King-Afridi commited on
Commit
10ab54d
·
verified ·
1 Parent(s): 3e57f59

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +11 -5
app.py CHANGED
@@ -13,7 +13,7 @@ client = Groq(api_key=api_key)
13
 
14
  # Function to generate "Happy New Year" text in the selected language using Groq API
15
  def generate_happy_new_year(language_code):
16
- # For Urdu and Turkish, return the correct translation directly instead of relying on Groq API.
17
  translations = {
18
  "en": "Happy New Year",
19
  "ur": "نیا سال مبارک ہو",
@@ -26,7 +26,10 @@ def generate_happy_new_year(language_code):
26
  "ar": "سنة جديدة سعيدة",
27
  "zh": "新年快乐",
28
  "th": "สวัสดีปีใหม่",
29
- "tr": "Mutlu Yıllar"
 
 
 
30
  }
31
 
32
  return translations.get(language_code, "Happy New Year")
@@ -42,8 +45,8 @@ def text_to_speech(text, language_code='en'):
42
  st.title("Happy New Year in Multiple Languages")
43
  st.write("Select a language to generate 'Happy New Year' text and hear it!")
44
 
45
- # Language selection - Added Turkish (tr) and Urdu (ur)
46
- language_code = st.selectbox("Choose a Language", ["en", "ur", "hi", "bn", "es", "fr", "de", "it", "ar", "zh", "th", "tr"])
47
 
48
  # Generate and play "Happy New Year" in the selected language
49
  happy_new_year_text = generate_happy_new_year(language_code)
@@ -70,7 +73,10 @@ language_notes = {
70
  "ar": "The text is in Arabic.",
71
  "zh": "The text is in Chinese.",
72
  "th": "The text is in Thai.",
73
- "tr": "The text is in Turkish."
 
 
 
74
  }
75
 
76
  st.write(language_notes.get(language_code, "The text is in the selected language."))
 
13
 
14
  # Function to generate "Happy New Year" text in the selected language using Groq API
15
  def generate_happy_new_year(language_code):
16
+ # For the additional languages, return the correct translation directly
17
  translations = {
18
  "en": "Happy New Year",
19
  "ur": "نیا سال مبارک ہو",
 
26
  "ar": "سنة جديدة سعيدة",
27
  "zh": "新年快乐",
28
  "th": "สวัสดีปีใหม่",
29
+ "tr": "Mutlu Yıllar",
30
+ "pa": "ਨਵਾਂ ਸਾਲ ਮੁਬਾਰਕ ਹੋ",
31
+ "ps": "نوی کال مو مبارک شه",
32
+ "ja": "新年おめでとうございます"
33
  }
34
 
35
  return translations.get(language_code, "Happy New Year")
 
45
  st.title("Happy New Year in Multiple Languages")
46
  st.write("Select a language to generate 'Happy New Year' text and hear it!")
47
 
48
+ # Language selection - Added Punjabi (pa), Pashto (ps), and Japanese (ja)
49
+ language_code = st.selectbox("Choose a Language", ["en", "ur", "hi", "bn", "es", "fr", "de", "it", "ar", "zh", "th", "tr", "pa", "ps", "ja"])
50
 
51
  # Generate and play "Happy New Year" in the selected language
52
  happy_new_year_text = generate_happy_new_year(language_code)
 
73
  "ar": "The text is in Arabic.",
74
  "zh": "The text is in Chinese.",
75
  "th": "The text is in Thai.",
76
+ "tr": "The text is in Turkish.",
77
+ "pa": "The text is in Punjabi.",
78
+ "ps": "The text is in Pashto.",
79
+ "ja": "The text is in Japanese."
80
  }
81
 
82
  st.write(language_notes.get(language_code, "The text is in the selected language."))