Spaces:
Runtime error
Runtime error
Add application file
Browse files
app.py
ADDED
@@ -0,0 +1,85 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# Import the required module for text
|
2 |
+
# to speech conversion
|
3 |
+
from gtts import gTTS
|
4 |
+
|
5 |
+
# This module is imported so that we can
|
6 |
+
# play the converted audio
|
7 |
+
import os
|
8 |
+
import re
|
9 |
+
import streamlit as st
|
10 |
+
import numpy as np
|
11 |
+
|
12 |
+
def tts(text):
|
13 |
+
# Language in which you want to convert
|
14 |
+
language = 'en'
|
15 |
+
|
16 |
+
# Passing the text and language to the engine,
|
17 |
+
# here we have marked slow=False. Which tells
|
18 |
+
# the module that the converted audio should
|
19 |
+
# have a high speed
|
20 |
+
speech = gTTS(text=text, lang=language, slow=False)
|
21 |
+
|
22 |
+
# Saving the converted audio in a mp3 file named
|
23 |
+
# welcome
|
24 |
+
speech.save("sample.mp3")
|
25 |
+
|
26 |
+
def get_words():
|
27 |
+
with open("words.txt", 'r') as f:
|
28 |
+
words = f.read()
|
29 |
+
# print(words)
|
30 |
+
words = re.split('\.|/|:| |,|\n',words)
|
31 |
+
|
32 |
+
words = [word.strip().lower() for word in words if word.strip() != ""]
|
33 |
+
# rest = [word for word in words if "." in word]
|
34 |
+
# words = [word for word in words if "." not in word]
|
35 |
+
|
36 |
+
# print(len(words))
|
37 |
+
return words
|
38 |
+
|
39 |
+
def genrate_word(words):
|
40 |
+
word = np.random.choice(words, size=1)[0]
|
41 |
+
print("genrating ", word)
|
42 |
+
with open("word.txt", "w") as f:
|
43 |
+
f.write(word)
|
44 |
+
tts(word)
|
45 |
+
return word
|
46 |
+
|
47 |
+
def update_audio():
|
48 |
+
audio_file = open('sample.mp3', 'rb')
|
49 |
+
audio_bytes = audio_file.read()
|
50 |
+
st.audio(audio_bytes, format='audio/mp3')
|
51 |
+
|
52 |
+
def update_frontend():
|
53 |
+
words = get_words()
|
54 |
+
genrate_word(words)
|
55 |
+
update_audio()
|
56 |
+
|
57 |
+
def get_main_word():
|
58 |
+
with open("word.txt", "r") as f:
|
59 |
+
return f.read()
|
60 |
+
|
61 |
+
st.title("Spelling checker for English learning")
|
62 |
+
|
63 |
+
if st.sidebar.button("Regenerate"):
|
64 |
+
update_frontend()
|
65 |
+
user_word = None
|
66 |
+
|
67 |
+
if st.sidebar.button("Show"):
|
68 |
+
update_audio()
|
69 |
+
|
70 |
+
user_word = st.text_input("word", value="")
|
71 |
+
|
72 |
+
if st.sidebar.button("check spelling") or user_word:
|
73 |
+
main_word = get_main_word()
|
74 |
+
if main_word == user_word.lower():
|
75 |
+
st.balloons()
|
76 |
+
st.success('Correct spelling! Go get 8/100 score', icon="✅")
|
77 |
+
else:
|
78 |
+
st.snow()
|
79 |
+
st.error('Try harder', icon="🚨")
|
80 |
+
|
81 |
+
if st.sidebar.button("Show word"):
|
82 |
+
main_word = get_main_word()
|
83 |
+
st.info('Word is '+main_word, icon="ℹ️")
|
84 |
+
|
85 |
+
st.text(str(len(get_words()))+" words are used in this demo, Good luck!")
|
requirements.txt
ADDED
@@ -0,0 +1,64 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# This file may be used to create an environment using:
|
2 |
+
# $ conda create --name <env> --file <this file>
|
3 |
+
# platform: osx-64
|
4 |
+
altair=4.2.0=pypi_0
|
5 |
+
attrs=22.2.0=pypi_0
|
6 |
+
blinker=1.5=pypi_0
|
7 |
+
ca-certificates=2022.10.11=hecd8cb5_0
|
8 |
+
cachetools=5.2.0=pypi_0
|
9 |
+
certifi=2022.12.7=py39hecd8cb5_0
|
10 |
+
charset-normalizer=2.1.1=pypi_0
|
11 |
+
click=8.1.3=pypi_0
|
12 |
+
commonmark=0.9.1=pypi_0
|
13 |
+
decorator=5.1.1=pypi_0
|
14 |
+
entrypoints=0.4=pypi_0
|
15 |
+
gitdb=4.0.10=pypi_0
|
16 |
+
gitpython=3.1.30=pypi_0
|
17 |
+
gtts=2.3.0=pypi_0
|
18 |
+
idna=3.4=pypi_0
|
19 |
+
importlib-metadata=6.0.0=pypi_0
|
20 |
+
jinja2=3.1.2=pypi_0
|
21 |
+
jsonschema=4.17.3=pypi_0
|
22 |
+
libcxx=14.0.6=h9765a3e_0
|
23 |
+
libffi=3.4.2=hecd8cb5_6
|
24 |
+
markupsafe=2.1.1=pypi_0
|
25 |
+
ncurses=6.3=hca72f7f_3
|
26 |
+
numpy=1.24.1=pypi_0
|
27 |
+
openssl=1.1.1s=hca72f7f_0
|
28 |
+
packaging=22.0=pypi_0
|
29 |
+
pandas=1.5.2=pypi_0
|
30 |
+
pillow=9.3.0=pypi_0
|
31 |
+
pip=22.3.1=py39hecd8cb5_0
|
32 |
+
protobuf=3.20.3=pypi_0
|
33 |
+
pyarrow=10.0.1=pypi_0
|
34 |
+
pydeck=0.8.0=pypi_0
|
35 |
+
pygments=2.14.0=pypi_0
|
36 |
+
pympler=1.0.1=pypi_0
|
37 |
+
pyrsistent=0.19.3=pypi_0
|
38 |
+
python=3.9.15=h218abb5_2
|
39 |
+
python-dateutil=2.8.2=pypi_0
|
40 |
+
pytz=2022.7=pypi_0
|
41 |
+
pytz-deprecation-shim=0.1.0.post0=pypi_0
|
42 |
+
readline=8.2=hca72f7f_0
|
43 |
+
requests=2.28.1=pypi_0
|
44 |
+
rich=13.0.0=pypi_0
|
45 |
+
semver=2.13.0=pypi_0
|
46 |
+
setuptools=65.5.0=py39hecd8cb5_0
|
47 |
+
six=1.16.0=pypi_0
|
48 |
+
smmap=5.0.0=pypi_0
|
49 |
+
sqlite=3.40.0=h880c91c_0
|
50 |
+
streamlit=1.16.0=pypi_0
|
51 |
+
tk=8.6.12=h5d9f67b_0
|
52 |
+
toml=0.10.2=pypi_0
|
53 |
+
toolz=0.12.0=pypi_0
|
54 |
+
tornado=6.2=pypi_0
|
55 |
+
typing-extensions=4.4.0=pypi_0
|
56 |
+
tzdata=2022.7=pypi_0
|
57 |
+
tzlocal=4.2=pypi_0
|
58 |
+
urllib3=1.26.13=pypi_0
|
59 |
+
validators=0.20.0=pypi_0
|
60 |
+
watchdog=2.2.1=pypi_0
|
61 |
+
wheel=0.37.1=pyhd3eb1b0_0
|
62 |
+
xz=5.2.8=h6c40b1e_0
|
63 |
+
zipp=3.11.0=pypi_0
|
64 |
+
zlib=1.2.13=h4dc903c_0
|
word.txt
ADDED
@@ -0,0 +1 @@
|
|
|
|
|
1 |
+
hut
|
words.txt
ADDED
@@ -0,0 +1,36 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
List of Words in Listening Test
|
2 |
+
Days of the week: Monday, Tuesday, Wednesday, Thursday, Friday, Saturday, Sunday, weekdays, weekend
|
3 |
+
Months of the year: January, February, March, April, May, June, July August, September, October, November, December
|
4 |
+
Hobbies: gardening, stamp collection, orienteering, caving, spelunking, scuba diving, snorkeling, skateboarding, bowls, archery, ice skating, darts, golf, billiards, photography, painting, embroidery, climbing, chess, parachute, pottery, woodcarving.
|
5 |
+
Subjects: science, politics, architecture, law, geography, history, biology, archaeology, literature, statistics, mathematics, performing arts, visual arts, logic, physics, psychology, anthropology, economics, philosophy, chemistry, humanities, business management, agriculture.
|
6 |
+
Marketing: catalogue, interview, research method, entertainment industry, TV program, strategies, leadership, management, customer, special offer, collecting data, display, products, questionnaire, survey, mass media, poll, business card, training, trainee, statistic, profit margin, newsletter, competition, merchandise, manufacture, recruitment.
|
7 |
+
Studying at college/university: course outline, group discussion, handout, research, Proofreading, experiment, written work, report writing, experience, reference, textbook, student advisor, teamwork, module, topic, dictionary, laptop, printer, assessment, library, department, computer centre, classroom, attendance, deadline, give a talk, speech, lecture, tutor, main hall, computer laboratory, certificate, diploma, placement test, facilities, college, dining room, specialist, knowledge, international, accommodation, overseas students, full-time, homestay, primary, secondary, intermediate, media room, commencement, dissertation, leaflet, school reunion, feedback, tasks, outcomes, advanced, introductory, extra background, resources room, staff, higher education, guidelines, post-secondary, faculty, pupils, pencil, supervisor, bachelor’s degree, compound, foreign students, schedule, vocabulary, student support services, student retention, publication, registrar’s office, stationery.
|
8 |
+
Works and jobs: designer, occupation, profession, decorator, architect, engineer, waiter, teacher, vacancy, professor, specialist, manager, waitress, psychologist، volunteer, craftsman, work experience, curriculum vitae, freelance, secretary, mail address, receptionist, pilot, lecturer, office assistant, clerk, accountant, guard, flight attendant, cashier, captain
|
9 |
+
Health: yoga, tai-chi, keep-fit, salad bar, vegetarian, outdoor activities, leisure time, disease, meal, protein, balanced diet, food pyramid, vitamin, carbohydrates, rice, pasta, potatoes, pizza, tomatoes, bread, cereals, minerals, zinc, meat, seafood, eggs, beans, milk, cheese, yoghurt, fruit, vegetables, citrus fruits, green pepper, blackcurrant, nuts, egg yolk, liver, medicine، treatment, remedy, nursing care, nursery, regular exercise.
|
10 |
+
Nature: field, footbridge, river, mountain, forest, village, environment, waterfall, coast, reef, lake, valley, peninsula, earthquake, avalanche, tornado, typhoon, hill, cliff, island, desertification, volcano, disaster, landslides, storm, flood, hurricane, pond, catastrophe, erosion, jungle, oasis, dam, canyon
|
11 |
+
The environment: coal, fossil fuels, acid rain, global warming, carbon dioxide, greenhouse effect, burning fossil, exhaust fumes, smog, climate, pollution, temperature, power plants, deforestation, nitrogen oxide, landfill, cattle, wind turbine, renewable, source of energy, reliable, solar panels, solar power, hydroelectric power, environmentally friendly, oxygen, chemical-free, vegetation, sea level, ocean currents, soil conditioner, firewood, desert, degradation, drought, contaminated.
|
12 |
+
Continents: Australia, Africa, South America, North America, Asia, Europe, Antarctica
|
13 |
+
Countries: Switzerland, Turkey, England, Egypt, Mexico, Germany, Greece, Brazil, India, North Korea, the Dominican Republic, France, Indonesia, India, Malaysia, New Zealand, United Kingdom, China, Italy, Nigeria, Pakistan, Singapore, the Philippines, Denmark.
|
14 |
+
Languages: Japanese, German, linguistics, bilingual, trilingual, polyglot, Portuguese, Mandarin, Bengali, Chinese, Hindi, Russian, Punjabi, Thai, Persian, Filipino, French, Italian, Greek, French
|
15 |
+
Architecture and buildings: dome, palace, fort, castle, glasshouse, pyramid, log cabin, lighthouse, hut, skyscraper, sculpture
|
16 |
+
Homes: chimney, bedroom, semi-detached house, duplex, townhouse, row house, bungalow, thatched cottage, mobile home, houseboat, a block of flats, apartment building, condominium, basement, landlord, terraced house, tenant, rent, lease, neighborhood, suburb, dormitory, story, kitchen, refrigerator, microwave, sofa, coffee table, ground floor, oven, hallway, insurance
|
17 |
+
In the city: central station, cities, street, lane, city centre, car park, department store, bridge, temple, hospital, garden, avenue, embassy, road system
|
18 |
+
Transportations: boat, lifeboat, cargo plane, shipment, container ship, ferry, liner, canal boat, narrowboat, dinghy sailing, hovercraft, hydrofoil, sailboat, paddle steamer, cabin cruiser, kayak, canoe, punt, gondola, aircraft, rowing boat, rowboat, helicopter, seaplane, airship, hot-air balloon, airport, platform, hire a car, automobile, crew, passenger.
|
19 |
+
Workplaces: staff selection, clinic, dentist, reception, appointment, colleague, workshop, employer, employment, unemployed, technical cooperation, team leaders, showroom, information desk, stress, ability, vision, employee, internship, confidence.
|
20 |
+
Places: parliament, accommodation, local library, swimming pool, cafeteria, cottage, restaurant, bookshop, sports centre, city council, canteen, cafe, dance studio, park, conversation club, kindergarten
|
21 |
+
Money matters: cash, debit, low-risk investment, credit card, cheque, annual fee, monthly membership, tuition fees, poverty, bank statement, money management, current account, interest rate, deposit, student account, withdraw, mortgage, grace period, in advance, budget deficit, retail voucher, coupon، counterfeit money, debt, interest-free credit, purchase, partial refund, annuity, public money, taxpayers’ money, income, non-refundable, MasterCard, VISA, duty-free store, distribution costs, finance department, family finances.
|
22 |
+
Rating and qualities: expensive, cheap, reasonable, satisfactory, dangerous, poor quality, satisfied, disappointed, efficient, luxurious, safe, strongly recommended, coloured, spotted, striped
|
23 |
+
Touring: souvenir, trip, tourist guided tour, ticket office, guest, reservation, view, culture, single double-bedded room, picnic, tourist attraction, hostel, suite, memorable, aquarium.
|
24 |
+
Adjectives: energetic, social, ancient, necessary, fantastic, exciting, fabulous, dull, comfortable, convenient, suitable, affordable, voluntary، mandatory, compulsory, temporary, permanent, Immense, vast, salty, extinct, vulnerable, pessimistic, optimistic, realistic, practical, knowledgeable, flexible, confident, Western, intensive, tranquil, spectacular, intact, various
|
25 |
+
Verbs: train, develop, collect, supervise, mark, edit, revise, exhibit, donate, surpass, register, support, hunt, persuade, concentrate, discuss, suggest, arrange, borrow, immigrate, review, learn, touch.
|
26 |
+
Sports: jet-skiing, bodyboarding, snowboarding, cricket, baseball, basketball, rugby, hang-gliding, skydiving, soccer, American football, hockey, swimming, tennis, squash, the javelin, badminton, ping-pong, field, court, pitch, stadium, team, the discus, the hammer, the high jump, horse racing, show jumping, polo, cycling, canoeing, refreshment, gymnasium, extreme sports, paragliding, abseiling, athlete, gym, bungee jumping, white-water rafting, surfing, windsurfing, kitesurfing, mountain biking, push-up, judo, recreation, jogging, press-up, snooker, walking, barbell, treadmill, championship.
|
27 |
+
Shapes: Oval, Square, rectangular, triangular, polygon, spherical, circular, curved, cylindrical, three dimensions, Measurement width, length, altitude, imperial system, metric system, spiral, Mass, depth, breadth, height, frequency
|
28 |
+
Weather: humid, hot, sticky, breeze, chilly, cold, cool, dry, dusty, freezing, hot, warm, wet, weather forecast, antenna, moisture,
|
29 |
+
Equipment and tools: helmet, light, musical instrument, cassette, silicon chip, digital monitor, gadget, device, screen, breaks, wheels, mechanical pencil, disk, backpack,
|
30 |
+
The arts and media: Opera, Orchestra, concert, symphony, the press, conductor, vocalist, audience, festival, carnival, exhibition, classical music, theatre, cinemas, art gallery, museum, ballet, television, radio, graphics, newspaper
|
31 |
+
The animal kingdom: lion, penguin, seabirds, poultry and game, birds of prey, mammals, genus, species, cetacean, whale, primates, rodents, reptile, insects, octopus, phylum, fish, amphibian, class, order, family, livestock, creature, plants: mushroom, fungus, stem, roots, cluster, fertilizer, leaves, seed, core, bark, trunk, twig, branch, flower.
|
32 |
+
Vehicles: camper, double-decker bus, single-decker, minibus, forklift truck, school bus, coach, truck, tanker, van, lorry, transporter, tow truck, breakdown truck, pickup, jeep, taxi, cab, tram, underground, subway, caravan, tractor, stream train, freight train, a goods train
|
33 |
+
Expressions and time: midday, three times, three times per week, millennium, a gap year, fulltime, part-time, midnight, century, decade, fortnight.
|
34 |
+
Materials: aluminum, copper, fur, metal, steel, rubber, plastic, ceramics, cement, stone, textile, cotton, fabric, wool, glass, leather, bone, paper, lumber/wood, glue, concrete, wax, paper, wood, silver, composite, fiberglass, gold, feather
|
35 |
+
Colour: blue, white, orange, green, grey, black, red, yellow, purple, brown, pink
|
36 |
+
Other: sufficient, dialogue, passport photo, state, variety, private sector, practice, gender, creativity, government, individual, original inhabitant, indigenous, demonstration, circuit, guarantee, commerce, carriage, narrative, strike, entrance, chocolate, satellite, decision, prototype, attitude, activity, recipient, ultrasound, pedestrian safety, daily routine, personal fulfilment, traffic jams, procedures, creation, senior, opportunity, driving license, prize, junior, process, literary, man-made, republicans, waiting list, sewer systems, liberal democracy, democrats, umbrella, frequently updated, lunar calendar, libertarian, burger, videos, fund-raising event, magnet, dialect, ramification, straight, nature conservation, life expectancy, farewell, welfare, encyclopedia, illiteracy, robot, proficiency, evolution, revolution.
|