snackshell commited on
Commit
04f3f01
Β·
verified Β·
1 Parent(s): 51fe9d6

Upload 4 files

Browse files
Files changed (4) hide show
  1. LICENSE +21 -0
  2. README.md +115 -14
  3. app.py +57 -0
  4. requirements.txt +5 -0
LICENSE ADDED
@@ -0,0 +1,21 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ MIT License
2
+
3
+ Copyright (c) 2025 Snackshell
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
README.md CHANGED
@@ -1,14 +1,115 @@
1
- ---
2
- title: Amharic Tts
3
- emoji: πŸ¦€
4
- colorFrom: blue
5
- colorTo: blue
6
- sdk: gradio
7
- sdk_version: 5.22.0
8
- app_file: app.py
9
- pinned: false
10
- license: mit
11
- short_description: ' # Amharic Text-to-Speech (TTS) Application'
12
- ---
13
-
14
- Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ```markdown
2
+
3
+ # Amharic Text-to-Speech (TTS) Application
4
+ ```
5
+ <div align="center">
6
+ <img src="./assets/demo.png" alt="Amharic TTS Interface" width="800">
7
+ <br>
8
+ <em>Convert Amharic text to natural-sounding speech directly in your browser</em>
9
+ </div>
10
+
11
+ [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
12
+ ...
13
+
14
+ [![Python 3.8+](https://img.shields.io/badge/python-3.8+-blue.svg)](https://www.python.org/downloads/)
15
+
16
+ A simple web-based Text-to-Speech application focused on Amharic language support, powered by Microsoft Edge TTS.
17
+
18
+ ## Features ✨
19
+ - πŸ—£οΈ Native Amharic voice support (Male & Female)
20
+ - 🌍 Web interface with Amharic localization
21
+ - ⚑ Real-time speech synthesis
22
+ - 🎧 Direct audio playback in browser
23
+ - πŸ› οΈ Error handling with Amharic/English messages
24
+ - ⏱️ 30-second timeout protection
25
+
26
+ ## Supported Voices 🎢
27
+ | Name | Gender | Voice ID |
28
+ |--------|--------|--------------------|
29
+ | Ameha | Male | `am-ET-AmehaNeural`|
30
+ | Mekdes | Female | `am-ET-MekdesNeural`|
31
+
32
+ ## Installation πŸ’»
33
+
34
+ ### Prerequisites
35
+ - Python 3.8+
36
+ - pip package manager
37
+
38
+ ### Steps
39
+ 1. Clone repository:
40
+ ```bash
41
+ git clone https://github.com/snackshell/amharic-tts.git
42
+ cd amharic-tts
43
+ ```
44
+
45
+ 2. Create virtual environment:
46
+ ```bash
47
+ python -m venv venv
48
+ source venv/bin/activate # Linux/Mac
49
+ venv\Scripts\activate # Windows
50
+ ```
51
+
52
+ 3. Install dependencies:
53
+ ```bash
54
+ pip install -r requirements.txt
55
+ ```
56
+
57
+ ## Usage πŸš€
58
+ 1. Start the application:
59
+ ```bash
60
+ python app.py
61
+ ```
62
+
63
+ 2. Access the interface at:
64
+ ```
65
+ http://localhost:7860
66
+ ```
67
+
68
+ 3. Enter Amharic text and select a voice:
69
+ - Type/paste text in the input box
70
+ - Choose between Ameha (Male) or Mekdes (Female)
71
+ - Click "α‹΅αˆα… ፍጠር" (Generate Audio)
72
+
73
+ 4. Play generated audio using the built-in player
74
+
75
+ ## Technical Details πŸ”§
76
+ ### Architecture
77
+ ```mermaid
78
+ graph TD
79
+ A[User Interface] --> B(Gradio Frontend)
80
+ B --> C[Edge TTS Service]
81
+ C --> D[Microsoft Cognitive Services]
82
+ ```
83
+
84
+ ### Key Technologies
85
+ - Python 3.10+
86
+ - Gradio (Web Interface)
87
+ - edge-tts (TTS Engine)
88
+ - asyncio (Async Operations)
89
+ - tempfile (Audio File Handling)
90
+
91
+ ## Contributing 🀝
92
+ Contributions are welcome! Please follow these steps:
93
+ 1. Fork the repository
94
+ 2. Create a feature branch (`git checkout -b feature/your-feature`)
95
+ 3. Commit changes (`git commit -m 'Add some feature'`)
96
+ 4. Push to branch (`git push origin feature/your-feature`)
97
+ 5. Open a Pull Request
98
+
99
+ ## License πŸ“„
100
+ This project is licensed under the MIT License - see [LICENSE](LICENSE) file for details.
101
+
102
+ ## Acknowledgments πŸ™
103
+ - Microsoft Edge TTS services
104
+ - Gradio team for the web interface framework
105
+ - [Bana Codes](https://t.me/banacodes) community for Amharic language support
106
+ ```
107
+
108
+ Create these additional files:
109
+
110
+ 1. **requirements.txt**
111
+ ```text
112
+ gradio==4.13.0
113
+ edge-tts==6.1.3
114
+ python-dotenv==1.0.0
115
+ ```
app.py ADDED
@@ -0,0 +1,57 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import tempfile
2
+ import edge_tts
3
+ import gradio as gr
4
+ import asyncio
5
+
6
+ language_dict = {
7
+ "Amharic": {
8
+ "Ameha": "am-ET-AmehaNeural",
9
+ "Mekdes": "am-ET-MekdesNeural"
10
+ }
11
+ }
12
+
13
+ async def text_to_speech_edge(text, speaker):
14
+ voice = language_dict["Amharic"][speaker]
15
+
16
+ try:
17
+ communicate = edge_tts.Communicate(text, voice)
18
+
19
+ # Create temp file with increased timeout
20
+ with tempfile.NamedTemporaryFile(delete=False, suffix=".mp3") as tmp_file:
21
+ tmp_path = tmp_file.name
22
+ await asyncio.wait_for(communicate.save(tmp_path), timeout=30)
23
+
24
+ return tmp_path
25
+
26
+ except asyncio.TimeoutError:
27
+ error_msg = "αˆ΅αˆ…α‰°α‰΅: αŒŠα‹œ αŠ αˆα‰‹αˆα’ αŠ₯α‰£αŠ­α‹Ž αŠ₯αŠ•α‹°αŒˆαŠ“ α‹­αˆžαŠ­αˆ©α’ (Timeout)"
28
+ raise gr.Error(error_msg)
29
+ except Exception as e:
30
+ error_msg = f"αˆ΅αˆ…α‰°α‰΅: α‹΅αˆα… መፍጠር αŠ αˆα‰°α‰»αˆˆαˆα’\nError: {str(e)}"
31
+ raise gr.Error(error_msg)
32
+
33
+ with gr.Blocks(title="Amharic TTS") as demo:
34
+ gr.HTML("<center><h1>Amharic Text-to-Speech</h1></center>")
35
+
36
+ with gr.Row():
37
+ with gr.Column():
38
+ input_text = gr.Textbox(lines=5, label="α‹¨αŠ αˆ›αˆ­αŠ› αŒ½αˆ‘α",
39
+ placeholder="α‹΅αˆα… ለመፍጠር αŒ½αˆ‘α α‹«αˆ΅αŒˆα‰‘...")
40
+ speaker = gr.Dropdown(
41
+ choices=["Ameha", "Mekdes"],
42
+ value="Ameha",
43
+ label="αŠ αˆ­α‰²αˆ΅α‰΅"
44
+ )
45
+ run_btn = gr.Button(value="α‹΅αˆα… ፍጠር", variant="primary")
46
+
47
+ with gr.Column():
48
+ output_audio = gr.Audio(type="filepath", label="α‹¨α‹΅αˆα… α‹αŒ€α‰΅")
49
+
50
+ run_btn.click(
51
+ text_to_speech_edge,
52
+ inputs=[input_text, speaker],
53
+ outputs=output_audio
54
+ )
55
+
56
+ if __name__ == "__main__":
57
+ demo.launch(server_port=7860, share=False)
requirements.txt ADDED
@@ -0,0 +1,5 @@
 
 
 
 
 
 
1
+ gradio
2
+ edge-tts
3
+ pyarabic
4
+ gradio-client
5
+ transformers