Skip to content

Commit 1555b9f

Browse files
authored
Merge pull request #364 from CodeReaper-10/nato-alpha
NATO Phonetic Alphabet
2 parents ab35270 + 06f2fb5 commit 1555b9f

File tree

4 files changed

+93
-1
lines changed

4 files changed

+93
-1
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,5 +101,5 @@ Once you are done working on your script edit this `README.md` file and add the
101101
74| Copy to clipboard | Copies contents form a text file to your clipboard | [Find me Here](https://github.com/GDSC-RCCIIT/General-Purpose-Scripts/tree/main/scripts/Copy%20to%20clipboard) |
102102
75| Video-to-audio Convertor | Extracts audios from videos. | [Find me here](https://github.com/GDSC-RCCIIT/General-Purpose-Scripts/tree/main/scripts/Video-to-audio-convertor) |
103103
76| Audio Recorder | Records audio from system's audio input device for `n` seconds | [Find me Here](https://github.com/GDSC-RCCIIT/General-Purpose-Scripts/tree/main/scripts/Audio%20Recorder) |
104-
104+
77| NATO Phonetic Alphabet | Spells entered word using NATO phonetic alphabets | [Find me Here](https://github.com/GDSC-RCCIIT/General-Purpose-Scripts/tree/main/scripts/NATO%20Phonetic%20Alphabet) |
105105
### Good Luck and don't forget to have fun with Open Source 🚀

scripts/NATO Alphabet/README.md

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
## How to run
2+
1. Clone the repository
3+
```
4+
git clone [email protected]:GDSC-RCCIIT/General-Purpose-Scripts.git
5+
```
6+
2. Install the script requirements
7+
```
8+
pip install -r requirements.txt
9+
```
10+
3. Navigate to `NATO Alphabet` directory
11+
```
12+
cd General-Purpose-Scripts/scripts/NATO Alphabet
13+
```
14+
4. Run the script to spell the entered word using NATO phonetic alphabet
15+
```
16+
python script.py <word>
17+
```
18+
### Note
19+
Replace `<word>` with the word you wish to spell.
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
gTTS==2.2.3
2+
playsound==1.2.2

scripts/NATO Alphabet/script.py

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
import sys
2+
from gtts import gTTS
3+
from playsound import playsound
4+
5+
txt = ""
6+
nato_alphabet = {
7+
"a": "alpha",
8+
"b": "bravo",
9+
"c": "charlie",
10+
"d": "delta",
11+
"e": "echo",
12+
"f": "foxtrot",
13+
"g": "golf",
14+
"h": "hotel",
15+
"i": "india",
16+
"j": "juliet",
17+
"k": "kilo",
18+
"l": "lima",
19+
"m": "mike",
20+
"n": "november",
21+
"o": "oscar",
22+
"p": "papa",
23+
"q": "quebec",
24+
"r": "romeo",
25+
"s": "sierra",
26+
"t": "tango",
27+
"u": "uniform",
28+
"v": "victor",
29+
"w": "whiskey",
30+
"x": "x-ray",
31+
"y": "yankee",
32+
"z": "zulu",
33+
"0": "zero",
34+
"1": "one",
35+
"2": "two",
36+
"3": "three",
37+
"4": "four",
38+
"5": "five",
39+
"6": "six",
40+
"7": "seven",
41+
"8": "eight",
42+
"9": "niner",
43+
".": "decimal",
44+
}
45+
46+
try:
47+
sys.argv[1]
48+
except:
49+
print("Usage: script.py <word>")
50+
exit(1)
51+
52+
for letter in sys.argv[1]:
53+
if letter.lower() not in nato_alphabet:
54+
print(letter)
55+
56+
else:
57+
print(nato_alphabet[letter.lower()])
58+
txt += nato_alphabet[letter.lower()] + " "
59+
60+
# Language to be converted into
61+
language = "en"
62+
63+
# Passing the text and language to the engine, here we have marked slow=False.
64+
# Which tells the module that the converted audio should have a high speed.
65+
myobj = gTTS(text=txt, lang=language, slow=False)
66+
67+
# Saving the converted audio in a mp3 file named nato
68+
myobj.save("nato.mp3")
69+
70+
# Playing the converted file
71+
playsound("nato.mp3")

0 commit comments

Comments
 (0)