snackshell commited on
Commit
9f383ea
Β·
verified Β·
1 Parent(s): 4172041

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +13 -5
app.py CHANGED
@@ -11,6 +11,10 @@ language_dict = {
11
  "English": {
12
  "Ryan": "en-GB-RyanNeural",
13
  "Clara": "en-CA-ClaraNeural"
 
 
 
 
14
  }
15
  }
16
 
@@ -27,10 +31,14 @@ async def text_to_speech_edge(text, language, speaker):
27
  return tmp_path
28
 
29
  except asyncio.TimeoutError:
30
- error_msg = "αˆ΅αˆ…α‰°α‰΅: αŒŠα‹œ αŠ αˆα‰‹αˆα’ αŠ₯α‰£αŠ­α‹Ž αŠ₯αŠ•α‹°αŒˆαŠ“ α‹­αˆžαŠ­αˆ©α’ (Timeout)" if language == "Amharic" else "Error: Timeout. Please try again."
 
 
31
  raise gr.Error(error_msg)
32
  except Exception as e:
33
- error_msg = f"αˆ΅αˆ…α‰°α‰΅: α‹΅αˆα… መፍጠር αŠ αˆα‰°α‰»αˆˆαˆα’\nError: {str(e)}" if language == "Amharic" else f"Error: Failed to generate audio.\nDetails: {str(e)}"
 
 
34
  raise gr.Error(error_msg)
35
 
36
  def update_speakers(language):
@@ -38,7 +46,7 @@ def update_speakers(language):
38
  # Use gr.update to update the dropdown's choices and default value.
39
  return gr.update(choices=speakers, value=speakers[0])
40
 
41
- with gr.Blocks(title="Amharic & English TTS") as demo:
42
  gr.HTML("""
43
  <style>
44
  h1 {
@@ -56,13 +64,13 @@ with gr.Blocks(title="Amharic & English TTS") as demo:
56
  border-color: #2E86C1 !important;
57
  }
58
  </style>
59
- <center><h1>Amharic & English Text-to-Speech</h1></center>
60
  """)
61
 
62
  with gr.Row():
63
  with gr.Column():
64
  language = gr.Dropdown(
65
- choices=["Amharic", "English"],
66
  value="Amharic",
67
  label="Select Language / α‰‹αŠ•α‰‹ α‹­αˆαˆ¨αŒ‘"
68
  )
 
11
  "English": {
12
  "Ryan": "en-GB-RyanNeural",
13
  "Clara": "en-CA-ClaraNeural"
14
+ },
15
+ "Tigrinya": {
16
+ "Ameha": "ti-ET-AmehaNeural", # Adjust if a different Tigrinya voice is available
17
+ "Mekdes": "ti-ET-MekdesNeural" # Adjust if needed
18
  }
19
  }
20
 
 
31
  return tmp_path
32
 
33
  except asyncio.TimeoutError:
34
+ error_msg = ("αˆ΅αˆ…α‰°α‰΅: αŒŠα‹œ αŠ αˆα‰‹αˆα’ αŠ₯α‰£αŠ­α‹Ž αŠ₯αŠ•α‹°αŒˆαŠ“ α‹­αˆžαŠ­αˆ©α’ (Timeout)"
35
+ if language == "Amharic" or language == "Tigrinya"
36
+ else "Error: Timeout. Please try again.")
37
  raise gr.Error(error_msg)
38
  except Exception as e:
39
+ error_msg = (f"αˆ΅αˆ…α‰°α‰΅: α‹΅αˆα… መፍጠር αŠ αˆα‰°α‰»αˆˆαˆα’\nError: {str(e)}"
40
+ if language == "Amharic" or language == "Tigrinya"
41
+ else f"Error: Failed to generate audio.\nDetails: {str(e)}")
42
  raise gr.Error(error_msg)
43
 
44
  def update_speakers(language):
 
46
  # Use gr.update to update the dropdown's choices and default value.
47
  return gr.update(choices=speakers, value=speakers[0])
48
 
49
+ with gr.Blocks(title="Amharic, English & Tigrinya TTS") as demo:
50
  gr.HTML("""
51
  <style>
52
  h1 {
 
64
  border-color: #2E86C1 !important;
65
  }
66
  </style>
67
+ <center><h1>Amharic, English & Tigrinya Text-to-Speech</h1></center>
68
  """)
69
 
70
  with gr.Row():
71
  with gr.Column():
72
  language = gr.Dropdown(
73
+ choices=["Amharic", "English", "Tigrinya"],
74
  value="Amharic",
75
  label="Select Language / α‰‹αŠ•α‰‹ α‹­αˆαˆ¨αŒ‘"
76
  )