[Python] I made an app to practice the subtle voice distinction of English words.

Synopsis

Previously, while traveling abroad, a story was made when a local person holding a kitten spoke in English.

Foreigner "How to say" kitchen "in Japanese?" Myself "(?? Why do you suddenly hear such a thing ...) DAIDOKORO" Foreigner "?? ...? What?" Myself "DAIDOKORO!" Foreigner "... Oh, DAIDOKORO! OK! DAIDOKORO!"

At a later date

I said, "There was something like this. I wonder why I heard that." Friend "That's what you said kitten, not kitchen? You had a kitten, right? " I said, "Oh, kitten! That's a kitten! I made a mistake because the pronunciation is similar to kitchen! hahaha "

My friend "..."

I "Let's study English ..."

What you want to make

Display two words with similar pronunciation on the screen, Play either audio file at random. Select the word that the user determines to have been pronounced, Display the correct or incorrect answer on the screen.

Also, various word pairs with similar phonetic symbols Collect by phonetic symbol and distinguish which phonetic symbol Challenge or allow the user to choose.

For example, the difference between'r'and'l' that many people including me are worried about Suppose you want to learn.

When you start the game, for example, either light or right audio Randomly played, select the one you think was played.

Then, the correct answer or the incorrect answer is displayed.

By the way, as shown below, the words light and right are the first They are exactly the same except that the phonetic symbols are l and r.

word Phonetic symbols
light lάɪt
right rάɪt

Development environment

Also, download the audio file of English words used in this tool from weblio. However, it is very troublesome to download many English word files one by one. It takes.

Therefore, I made a tool to automatically download English words by web scraping. ↓ https://qiita.com/Fuminori_Souma/private/60ce627e66209763d4f2

With this tool, you can easily download the audio file you want. However, the audio file of the word described in the json file of this tool is published on Google drive (described later).

What I actually made

The screen immediately after execution looks like this. 1.png

Today, I will try to distinguish between's'and'th', which Japanese people are not good at. 2.png

When you press the "Start Game" button, the screen changes to the game screen. Is there a total of 14 questions? 3.png

When I pressed the "Play Audio" button, the audio file was played and I had two options. I wonder which one was pronounced. .. Press the "Play Again" button and listen again. Okay, the tense on the left! Click on the "tense" text to answer. 4.png

Excellent answer! You did it. Click "tense" and "tenth" to play and each Let's check the difference in voice. When you're done, press the "Start Next Problem" button. 5.png

This time "mouse" and "mouth"? Okay, mouth! 6.png

... isn't it? damn it! 7.png

... it's all over. 7 out of 14 correct answers? Well, it's ok (sweat) Press the "Return to title" button. 8.png

Next, let's try to distinguish between'b'and'v'. 1.png

I use it like this.

source file

English_study.py


import sys
import tkinter
from tkinter import messagebox
from mutagen.mp3 import MP3 as mp3
from tkinter import *
import pygame
import time
import json
import random
from PIL import Image, ImageTk


def ques_start_next(event): #Start the problem/Play audio again/Start the next problem

    if bttn_repnxt['text'] == 'Play audio':

        global word1
        global word2
        global rep_word #Words actually pronounced
        global id

        text_res["text"] = '' #Reset the answer to the previous question

        group = ps
        words = random.choice(list(wordlist['Wordlist'][group]))

        id = 'id' + str(quorder[qunum - renum])

        word1 = (wordlist['Wordlist'][group][id]['word1'])
        word2 = (wordlist['Wordlist'][group][id]['word2'])
        rep_word = wordlist['Wordlist'][group][id][random.choice(list(wordlist['Wordlist'][group][words]))]

        rep_mp3(rep_word)  #Play audio file

        #Change object state
        text_w1["text"] = word1
        text_w2["text"] = word2
        text_ques1["text"] = 'It was pronounced ...'
        text_ques2["text"] = 'Which one?'
        bttn_repnxt['text'] = 'Play again'
        text_adc.place_forget()

    elif bttn_repnxt['text'] == 'Play again':

        rep_mp3(rep_word)  #Play audio file

    else:  # 'Start the next problem'

        #Change object state
        bttn_repnxt['text'] = 'Play audio'
        text_res.place_forget()

        #Start the next problem (play audio file)
        ques_start_next(event)


def rep_mp3(tgt_word):  #Play audio

    filename = 'C:/Users/fumin/OneDrive/desktop/English_words/' + tgt_word + '.mp3'  #The mp3 file you want to play
    pygame.mixer.init()
    pygame.mixer.music.load(filename)  #Load the sound source
    mp3_length = mp3(filename).info.length  #Get the length of the sound source
    pygame.mixer.music.play(1)  #Playback starts. Play n times if part 1 is changed(In that case, also xn the number of seconds on the next line.)
    time.sleep(mp3_length + 0.25)  #After starting playback, wait for the length of the sound source(0.25 Waiting for error elimination)
    pygame.mixer.music.stop()  #Playback stops after waiting for the length of the sound source


def enlarge_word(event):  #Larger word with mouse pointer

    if str(event.widget["text"]) == word1:
        text_w1["font"] = ("", 12)   #Larger characters
        text_w1["cursor"] = "hand2"  #Change mouse pointer to index finger type
    else:
        text_w2["font"] = ("", 12)   #Larger characters
        text_w2["cursor"] = "hand2"  #Change mouse pointer to index finger type


def undo_word(event):  #Restores a word that is out of the mouse pointer to its original size

    if str(event.widget["text"]) == word1:
        text_w1["font"] = ("", 10)  #Display characters in initial size
    else:
        text_w2["font"] = ("", 10)  #Display characters in initial size


def choose_word(event):  #Determine if the word selected by the user is correct

    global oknum
    global renum

    if bttn_repnxt['text'] == 'Play again':

        #Display correct answers and notes
        text_res.place(x=175, y=130)
        text_adc.place(x=130, y=160)

        if str(event.widget["text"]) == word1:  #If you select the word on the left

            if rep_word == word1:
                text_res["text"] = 'Correct answer!!'
            else:
                text_res["text"] = 'Incorrect answer…'

        else:  #If you select the word on the right

            if rep_word == word2:
                text_res["text"] = 'Correct answer!!'
            else:
                text_res["text"] = 'Incorrect answer…'

        if text_res["text"] == 'Correct answer!!':

            oknum = oknum + 1  #Add the number of correct answers
            text_res["foreground"] = 'blue'
        else:
            text_res["foreground"] = 'red'

        renum -= 1  #Subtract the number of remaining questions

        #Change object state
        text_scr['text'] = 'Score:' + str(oknum) + '/' + str(qunum)
        text_rest['text'] = 'remaining:' + str(renum)
        text_ques1["text"] = ''
        text_ques2["text"] = ''
        bttn_repnxt["text"] = 'Start the next problem'

        if renum == 0:  #When all problems are over
            bttn_repnxt.place_forget()
            text_end.place(x=110, y=320)

    elif bttn_repnxt['text'] == 'Start the next problem':  #Play the audio of the following problem

        if str(event.widget["text"]) == word1:

            rep_mp3(wordlist['Wordlist'][ps][id]['word1'])
        else:
            rep_mp3(wordlist['Wordlist'][ps][id]['word2'])


def create_radioboutton(row, column, pdx, num, value):  #Generate a radio button on the title screen

    rdbtn[num] = tkinter.Radiobutton(frame, value=value, command=rb_clicked, variable=var, text=u'')
    rdbtn[num].grid(row=row, column=column, padx=0, ipadx=pdx, pady=yinvl)


def create_picture(row='df', column='df', pdx='df', num='df'):  #Phonetic symbols on the title screen(image)Generate a

    if row == 'df' and column == 'df'and pdx == 'df'and num == 'df':  #For title screen

        cv[rbnum] = Canvas(width=70, height=20)
        cv[rbnum].create_image(1, 1, image=pngfile[rbnum], anchor=NW)
        cv[rbnum].place(x=195, y=25)

    else:  #In the case of the game start screen
        cv[num] = Canvas(frame, width=70, height=20)
        cv[num].create_image(1, 1, image=pngfile[num], anchor=NW)
        cv[num].grid(row=row, column=column, ipadx=pdx, pady=yinvl)


def rb_clicked():  #Select phonetic symbols to study

    global rbnum
    global ps

    rbnum = int(var.get())  #Selected radio button(=Phonetic symbols)Store the number of
    ps = list(wordlist['Wordlist'])[rbnum]  #Select the selected phonetic symbol


def switch_mode(event):  #Start the game/Return to title screen

    global qunum    #Number of total problems
    global oknum    #Number of correct questions
    global renum    #Number of remaining issues
    global quorder  #Order of question questions

    if bttn_swmode['text'] == 'game start':

        #Hide the object that was on the first screen
        frame.place_forget()
        text_title.place_forget()
        text_ques3.place_forget()

        #Show objects for games
        bttn_repnxt.place(x=155, y=70)
        text_scr.place(x=200, y=250)
        text_rest.place(x=130, y=250)
        text_w1.place(x=128, y=190)
        text_w2.place(x=228, y=190)
        text_ps.place(x=135, y=28)
        text_ques1.place(x=160, y=130)
        text_ques2.place(x=175, y=160)
        create_picture()

        #various settings
        oknum = 0
        qunum = len(wordlist['Wordlist'][ps])
        renum = qunum
        text_scr['text'] = 'Score:' + str(oknum) + '/' + str(qunum)
        text_rest['text'] = 'remaining:' + str(renum)
        quorder = random.sample(range(1, qunum + 1), k=qunum)
        bttn_swmode['text'] = 'Return to title'
        text_w1["text"] = ''
        text_w2["text"] = ''
        text_ques1["text"] = ''
        text_ques2["text"] = ''
        bttn_repnxt['text'] = 'Play audio'

    else:  #Return to title screen

        if renum == 0 or (renum != 0 and messagebox.askyesno('Verification', 'There are still problems. Do you want to return to the title screen?')):

            # if messagebox.askyesno('Verification', 'There are still problems. Do you want to return to the title screen?'):

            #Hide the objects that were on the game screen
            bttn_repnxt.place_forget()
            text_scr.place_forget()
            text_rest.place_forget()
            text_w1.place_forget()
            text_w2.place_forget()
            text_ps.place_forget()
            text_ques1.place_forget()
            text_ques2.place_forget()
            text_end.place_forget()
            text_res.place_forget()
            text_adc.place_forget()
            cv[rbnum].place_forget()

            #Display the object for the title screen
            frame.place(x=90, y=90)
            text_title.place(x=110, y=30)
            text_ques3.place(x=90, y=65)
            bttn_swmode['text'] = 'game start'


#Screen display
root = tkinter.Tk()
root.title(u"Pronunciation")
root.geometry("400x420")
root.columnconfigure(0, weight=1)
root.rowconfigure(0, weight=1)

# Frame
frame = tkinter.Frame(root)
frame.place(x=90, y=90)
frame.columnconfigure(0, weight=1)
frame.rowconfigure(0, weight=1)

#Label settings
text_w1 = tkinter.Label(text=u'', font=("", 10))
text_w1.bind("<Enter>", enlarge_word)
text_w1.bind("<Leave>", undo_word)
text_w1.bind("<Button-1>", choose_word)
text_w2 = tkinter.Label(text=u'', font=("", 10))
text_w2.bind("<Enter>", enlarge_word)
text_w2.bind("<Leave>", undo_word)
text_w2.bind("<Button-1>", choose_word)
text_ques1 = tkinter.Label(text=u'')
text_ques2 = tkinter.Label(text=u'')
text_ques3 = tkinter.Label(text=u'Select a phonetic symbol and start the game.')
text_ques3.place(x=90, y=65)
text_ps = tkinter.Label(text=u'Phonetic symbols:')
text_adc = tkinter.Label(text=u'* Click each word to play voice')
text_res = tkinter.Label(text=u'')
text_scr = tkinter.Label(text=u'')
text_rest = tkinter.Label(text=u'')
text_title = tkinter.Label(text=u'Pronunciation(Temporary)', font=(u'MS Mincho', 20))
text_title.place(x=110, y=30)
text_end = tkinter.Label(text=u'The game with this phonetic symbol is over.')
text_end["foreground"] = 'green'

#Push button settings
bttn_repnxt = tkinter.Button(text=u'Play audio', width=11)
bttn_repnxt.bind("<Button-1>", ques_start_next)  # (Button-2 for wheel click, 3 for right click)
bttn_swmode = tkinter.Button(text=u'game start', width=10)
bttn_swmode.bind("<Button-1>", switch_mode)  # (Button-2 for wheel click, 3 for right click)
bttn_swmode.place(x=157, y=380)

#Setting parameters used for radio button placement
xinvl = 30
yinvl = 0
var = StringVar()
var.set('0')  #Set the radio button to "Unchecked"
f = open("C:/Users/fumin/OneDrive/desktop/Wordlist.json", 'r')
wordlist = json.load(f)
oknum = 0
rb_clicked()  #Radio button selected in the initial state

#Initialization of variables that store image information and radio button information
pngfile = [''] * len(wordlist['Wordlist'])
cv = [''] * len(wordlist['Wordlist'])
rdbtn = [''] * len(wordlist['Wordlist'])

#Radio buttons/Phonetic symbol settings
for i in range(int(len(wordlist['Wordlist'])/2)):

    ipadx = 10

    pngfile[i*2] = PhotoImage(file="C:/Users/fumin/OneDrive/image/" + list(wordlist['Wordlist'])[i * 2] + ".PNG")
    pngfile[i*2+1] = PhotoImage(file="C:/Users/fumin/OneDrive/image/" + list(wordlist['Wordlist'])[i * 2 + 1] + ".PNG")

    create_radioboutton(i+1, 1, 0, i*2, i*2)
    create_picture(i+1, 2, ipadx, i*2)
    create_radioboutton(i+1, 3, 0, i*2+1, i*2+1)
    create_picture(i+1, 4, ipadx, i*2+1)

root.mainloop()

English word information storage file

Wordlist.json


{
  "Wordlist": {
        "b_v" : {
      "id1" : {
        "word1": "boat",
        "word2": "vote"
      },
      "id2" : {
        "word1": "bury",
        "word2": "vary"
      },
      "id3" : {
        "word1": "base",
        "word2": "vase"
      },
      "id4" : {
        "word1": "bent",
        "word2": "vent"
      },
      "id5" : {
        "word1": "ban",
        "word2": "van"
      },
      "id6" : {
        "word1": "best",
        "word2": "vest"
      },
      "id7" : {
        "word1": "bat",
        "word2": "vat"
      }
    },
    "l_r" : {
      "id1" : {
        "word1": "light",
        "word2": "right"
      },
      "id2" : {
        "word1": "lice",
        "word2": "rice"
      },
      "id3" : {
        "word1": "long",
        "word2": "wrong"
      },
      "id4" : {
        "word1": "lock",
        "word2": "rock"
      },
      "id5" : {
        "word1": "lane",
        "word2": "rain"
      },
      "id6" : {
        "word1": "lend",
        "word2": "rend"
      },
      "id7" : {
        "word1": "lead",
        "word2": "read"
      },
      "id8" : {
        "word1": "loom",
        "word2": "room"
      },
      "id9" : {
        "word1": "lace",
        "word2": "race"
      },
      "id10" : {
        "word1": "lack",
        "word2": "rack"
      },
      "id11" : {
        "word1": "lake",
        "word2": "rake"
      },
      "id12" : {
        "word1": "lamp",
        "word2": "ramp"
      },
      "id13" : {
        "word1": "lank",
        "word2": "rank"
      },
      "id14" : {
        "word1": "late",
        "word2": "rate"
      },
      "id15" : {
        "word1": "law",
        "word2": "raw"
      },
      "id16" : {
        "word1": "clown",
        "word2": "crown"
      },
      "id17" : {
        "word1": "folk",
        "word2": "fork"
      },
      "id18" : {
        "word1": "glamour",
        "word2": "grammar"
      },
      "id19" : {
        "word1": "flee",
        "word2": "free"
      },
      "id20" : {
        "word1": "allow",
        "word2": "arrow"
      },
      "id21" : {
        "word1": "belly",
        "word2": "berry"
      },
      "id22" : {
        "word1": "blanch",
        "word2": "branch"
      },
      "id23" : {
        "word1": "bland",
        "word2": "brand"
      },
      "id24" : {
        "word1": "bravely",
        "word2": "bravery"
      },
      "id25" : {
        "word1": "bleach",
        "word2": "breach"
      },
      "id26" : {
        "word1": "bleed",
        "word2": "breed"
      },
      "id27" : {
        "word1": "blink",
        "word2": "brink"
      },
      "id28" : {
        "word1": "bully",
        "word2": "burly"
      },
      "id29" : {
        "word1": "collect",
        "word2": "correct"
      },
      "id30" : {
        "word1": "flesh",
        "word2": "fresh"
      }
    },
    "crt_ash" : {
      "id1" : {
        "word1": "bug",
        "word2": "bag"
      },
      "id2" : {
        "word1": "fun",
        "word2": "fam"
      },
      "id3" : {
        "word1": "tusk",
        "word2": "task"
      },
      "id4" : {
        "word1": "much",
        "word2": "match"
      },
      "id5" : {
        "word1": "buck",
        "word2": "back"
      },
      "id6" : {
        "word1": "crush",
        "word2": "crash"
      },
      "id7" : {
        "word1": "suck",
        "word2": "sack"
      },
      "id8" : {
        "word1": "stuff",
        "word2": "staff"
      },
      "id9" : {
        "word1": "mud",
        "word2": "mad"
      },
      "id10" : {
        "word1": "musk",
        "word2": "mask"
      },
      "id11" : {
        "word1": "lump",
        "word2": "lamp"
      },
      "id12" : {
        "word1": "bung",
        "word2": "bang"
      },
      "id13" : {
        "word1": "hut",
        "word2": "hat"
      },
      "id14" : {
        "word1": "rump",
        "word2": "ramp"
      },
      "id15" : {
        "word1": "uncle",
        "word2": "ankle"
      },
      "id16" : {
        "word1": "muster",
        "word2": "master"
      },
      "id17" : {
        "word1": "bund",
        "word2": "band"
      },
      "id18" : {
        "word1": "puppy",
        "word2": "pappy"
      },
      "id19" : {
        "word1": "double",
        "word2": "dabble"
      },
      "id20" : {
        "word1": "hunk",
        "word2": "hank"
      },
      "id21" : {
        "word1": "stunned",
        "word2": "stand"
      }
    },
    "ash_alfa" : {
      "id1" : {
        "word1": "pappy",
        "word2": "poppy"
      },
      "id2" : {
        "word1": "adapt",
        "word2": "adopt"
      },
      "id3" : {
        "word1": "bag",
        "word2": "bog"
      },
      "id4" : {
        "word1": "back",
        "word2": "bock"
      },
      "id5" : {
        "word1": "sack",
        "word2": "sock"
      },
      "id6" : {
        "word1": "mask",
        "word2": "mosque"
      },
      "id7" : {
        "word1": "hat",
        "word2": "hot"
      },
      "id8" : {
        "word1": "ramp",
        "word2": "romp"
      },
      "id9" : {
        "word1": "band",
        "word2": "bond"
      },
      "id10" : {
        "word1": "possible",
        "word2": "passable"
      },
      "id11" : {
        "word1": "sad",
        "word2": "sod"
      },
      "id12" : {
        "word1": "tap",
        "word2": "top"
      },
      "id13" : {
        "word1": "nat",
        "word2": "not"
      },
      "id14" : {
        "word1": "hank",
        "word2": "honk"
      },
      "id15" : {
        "word1": "bax",
        "word2": "box"
      },
      "id16" : {
        "word1": "valley",
        "word2": "volley"
      },
      "id17" : {
        "word1": "sax",
        "word2": "sox"
      }
    },
    "alfa_crt" : {
      "id1" : {
        "word1": "body",
        "word2": "buddy"
      },
      "id2" : {
        "word1": "wander",
        "word2": "wonder"
      },
      "id3" : {
        "word1": "soccer",
        "word2": "sucker"
      },
      "id4" : {
        "word1": "poppy",
        "word2": "puppy"
      },
      "id5" : {
        "word1": "bond",
        "word2": "bund"
      },
      "id6" : {
        "word1": "romp",
        "word2": "rump"
      },
      "id7" : {
        "word1": "hot",
        "word2": "hut"
      },
      "id8" : {
        "word1": "mosque",
        "word2": "musk"
      },
      "id9" : {
        "word1": "sock",
        "word2": "suck"
      },
      "id10" : {
        "word1": "bock",
        "word2": "buck"
      },
      "id11" : {
        "word1": "bog",
        "word2": "bug"
      },
      "id12" : {
        "word1": "collar",
        "word2": "color"
      },
      "id13" : {
        "word1": "rob",
        "word2": "rub"
      },
      "id14" : {
        "word1": "honk",
        "word2": "hunk"
      },
      "id15" : {
        "word1": "calm",
        "word2": "come"
      },
      "id16" : {
        "word1": "coddle",
        "word2": "cuddle"
      }
    },
    "s_th" : {
      "id1" : {
        "word1": "sink",
        "word2": "think"
      },
      "id2" : {
        "word1": "sick",
        "word2": "thick"
      },
      "id3" : {
        "word1": "sing",
        "word2": "thing"
      },
      "id4" : {
        "word1": "sought",
        "word2": "thought"
      },
      "id5" : {
        "word1": "sank",
        "word2": "thank"
      },
      "id6" : {
        "word1": "seam",
        "word2": "theme"
      },
      "id7" : {
        "word1": "sin",
        "word2": "thin"
      },
      "id8" : {
        "word1": "mouse",
        "word2": "mouth"
      },
      "id9" : {
        "word1": "tense",
        "word2": "tenth"
      },
      "id10" : {
        "word1": "force",
        "word2": "forth"
      },
      "id11" : {
        "word1": "worse",
        "word2": "worth"
      },
      "id12" : {
        "word1": "face",
        "word2": "faith"
      },
      "id13" : {
        "word1": "boss",
        "word2": "both"
      },
      "id14" : {
        "word1": "mass",
        "word2": "math"
      }
    },
    "oo-lvc_ou" : {
      "id1" : {
        "word1": "called",
        "word2": "cold"
      },
      "id2" : {
        "word1": "raw",
        "word2": "row"
      },
      "id3" : {
        "word1": "law",
        "word2": "low"
      },
      "id4" : {
        "word1": "call",
        "word2": "coal"
      },
      "id5" : {
        "word1": "hall",
        "word2": "hole"
      },
      "id6" : {
        "word1": "tall",
        "word2": "toll"
      },
      "id7" : {
        "word1": "bawl",
        "word2": "bowl"
      },
      "id8" : {
        "word1": "tall",
        "word2": "tole"
      },
      "id9" : {
        "word1": "lawn",
        "word2": "loan"
      },
      "id10" : {
        "word1": "pawl",
        "word2": "pole"
      },
      "id11" : {
        "word1": "ball",
        "word2": "bole"
      },
      "id12" : {
        "word1": "caught",
        "word2": "coat"
      }
    },
    "alfa-hschwa_hschwa-lvc" : {
      "id1" : {
        "word1": "heart",
        "word2": "hurt"
      },
      "id2" : {
        "word1": "hard",
        "word2": "heard"
      },
      "id3" : {
        "word1": "carve",
        "word2": "curve"
      },
      "id4" : {
        "word1": "lark",
        "word2": "lurk"
      },
      "id5" : {
        "word1": "bard",
        "word2": "bird"
      },
      "id6" : {
        "word1": "far",
        "word2": "fur"
      },
      "id7" : {
        "word1": "park",
        "word2": "perk"
      }
    },
    "ash_e" : {
      "id1" : {
        "word1": "adapt",
        "word2": "adept"
      },
      "id2" : {
        "word1": "parish",
        "word2": "perish"
      },
      "id3" : {
        "word1": "marry",
        "word2": "merry"
      },
      "id4" : {
        "word1": "back",
        "word2": "beck"
      },
      "id5" : {
        "word1": "band",
        "word2": "bend"
      },
      "id6" : {
        "word1": "nat",
        "word2": "net"
      },
      "id7" : {
        "word1": "bag",
        "word2": "beg"
      },
      "id8" : {
        "word1": "hat",
        "word2": "het"
      }
    },
    "ou_oo-hschwa" : {
      "id1" : {
        "word1": "motor",
        "word2": "mortar"
      },
      "id2" : {
        "word1": "load",
        "word2": "lord"
      },
      "id3" : {
        "word1": "bode",
        "word2": "board"
      },
      "id4" : {
        "word1": "coat",
        "word2": "court"
      },
      "id5" : {
        "word1": "boa",
        "word2": "bore"
      },
      "id6" : {
        "word1": "hose",
        "word2": "hoarse"
      },
      "id7" : {
        "word1": "woe",
        "word2": "war"
      }
    },
    "oo-lvc_schwa-u" : {
      "id1" : {
        "word1": "walk",
        "word2": "woke"
      },
      "id2" : {
        "word1": "bought",
        "word2": "boat"
      },
      "id3" : {
        "word1": "cost",
        "word2": "coast"
      },
      "id4" : {
        "word1": "flaw",
        "word2": "flow"
      },
      "id5" : {
        "word1": "hall",
        "word2": "whole"
      },
      "id6" : {
        "word1": "nought",
        "word2": "note"
      }
    },
    "hschwa_lvc" : {
      "id1" : {
        "word1": "fort",
        "word2": "fought"
      },
      "id2" : {
        "word1": "sort",
        "word2": "sought"
      },
      "id3" : {
        "word1": "source",
        "word2": "sauce"
      },
      "id4" : {
        "word1": "lorn",
        "word2": "lawn"
      },
      "id5" : {
        "word1": "there",
        "word2": "their"
      },
      "id6" : {
        "word1": "court",
        "word2": "caught"
      }
    },
    "alfau_oo" : {
      "id1" : {
        "word1": "brown",
        "word2": "brawn"
      },
      "id2" : {
        "word1": "drown",
        "word2": "drawn"
      },
      "id3" : {
        "word1": "down",
        "word2": "dawn"
      },
      "id4" : {
        "word1": "sow",
        "word2": "saw"
      },
      "id5" : {
        "word1": "sough",
        "word2": "saw"
      },
      "id6" : {
        "word1": "tout",
        "word2": "taught"
      }
    },
    "alfa_e" : {
      "id1" : {
        "word1": "not",
        "word2": "net"
      },
      "id2" : {
        "word1": "adopt",
        "word2": "adept"
      },
      "id3" : {
        "word1": "bog",
        "word2": "beg"
      },
      "id4" : {
        "word1": "hot",
        "word2": "het"
      },
      "id5" : {
        "word1": "bock",
        "word2": "beck"
      },
      "id6" : {
        "word1": "bond",
        "word2": "bend"
      }
    },
    "s_esh" : {
      "id1" : {
        "word1": "seat",
        "word2": "sheet"
      },
      "id2" : {
        "word1": "see",
        "word2": "she"
      },
      "id3" : {
        "word1": "seep",
        "word2": "sheep"
      },
      "id4" : {
        "word1": "seer",
        "word2": "sheer"
      },
      "id5" : {
        "word1": "sip",
        "word2": "ship"
      }
    },
    "z_eth" : {
      "id1" : {
        "word1": "wiz",
        "word2": "with"
      },
      "id2" : {
        "word1": "zen",
        "word2": "then"
      },
      "id3" : {
        "word1": "breeze",
        "word2": "breathe"
      },
      "id4" : {
        "word1": "tease",
        "word2": "teethe"
      },
      "id5" : {
        "word1": "closing",
        "word2": "clothing"
      }
    },
    "alfa_a" : {
      "id1" : {
        "word1": "drier",
        "word2": "dryer"
      },
      "id2" : {
        "word1": "find",
        "word2": "fined"
      },
      "id3" : {
        "word1": "guise",
        "word2": "guys"
      },
      "id4" : {
        "word1": "lime",
        "word2": "lyme"
      }
    },
    "e_i" : {
      "id1" : {
        "word1": "wary",
        "word2": "weary"
      },
      "id2" : {
        "word1": "emigrant",
        "word2": "immigrant"
      },
      "id3" : {
        "word1": "desert",
        "word2": "dessert"
      },
      "id4" : {
        "word1": "tear",
        "word2": "tier"
      }
    },
     "schwa-u_oo-hschwa" : {
      "id1" : {
        "word1": "woe",
        "word2": "war"
      },
      "id2" : {
        "word1": "foam",
        "word2": "form"
      },
      "id3" : {
        "word1": "foe",
        "word2": "four"
      }
    },
    "alfa_o" : {
      "id1" : {
        "word1": "dow",
        "word2": "dough"
      },
      "id2" : {
        "word1": "wow",
        "word2": "woe"
      },
      "id3" : {
        "word1": "allow",
        "word2": "alow"
      }
    },
    "alfa_oo" : {
      "id1" : {
        "word1": "noun",
        "word2": "known"
      },
      "id2" : {
        "word1": "farm",
        "word2": "form"
      },
      "id3" : {
        "word1": "what",
        "word2": "wat"
      }
    },
    "oo-hschwa_hschwa-lvc" : {
      "id1" : {
        "word1": "warm",
        "word2": "worm"
      },
      "id2" : {
        "word1": "ward",
        "word2": "word"
      },
      "id3" : {
        "word1": "torn",
        "word2": "turn"
      }
    },
    "other" : {
      "id1" : {
        "word1": "with",
        "word2": "width"
      },
      "id2" : {
        "word1": "breathe",
        "word2": "breadth"
      },
      "id3" : {
        "word1": "father",
        "word2": "further"
      },
      "id4" : {
        "word1": "borrow",
        "word2": "borough"
      },
      "id5" : {
        "word1": "hole",
        "word2": "whole"
      },
      "id6" : {
        "word1": "toe",
        "word2": "tow"
      },
      "id7" : {
        "word1": "bill",
        "word2": "beer"
      },
      "id8" : {
        "word1": "all",
        "word2": "oar"
      },
      "id9" : {
        "word1": "shock",
        "word2": "shook"
      },
      "id10" : {
        "word1": "crock",
        "word2": "crook"
      },
      "id11" : {
        "word1": "aren't",
        "word2": "ant"
      },
      "id12" : {
        "word1": "parse",
        "word2": "pass"
      },
      "id13" : {
        "word1": "some",
        "word2": "sum"
      },
      "id14" : {
        "word1": "discus",
        "word2": "discuss"
      },
      "id15" : {
        "word1": "gall",
        "word2": "girl"
      },
      "id16" : {
        "word1": "walk",
        "word2": "work"
      }
    }
  }
}

About files required to use the app ()

Stored below. https://drive.google.com/open?id=1u4l5wo-6SC00Ys0xBZO_am1v2yPjb_NU

Actually, I think that management is efficient on Github without doing this. .. Since I am studying, I temporarily stored it in Google drive.

Download the file stored in the above drive locally, and change the directory described in .py as shown below according to the local location. (It's troublesome)

Place to put Source changes
Audio file (mp3) Directory on the right side of the variable "filename"
json file Directory on the right side of variable "f"
Image file (png) Directory on the right side of the variable "pngfile"

About English word information storage file (json)

As mentioned above, the json file is a collection of word pairs for each phonetic symbol. Since the phonetic symbols cannot be handled even if they are written as they are, they were written in English as shown below.

Phonetic symbols name How to write in json above
æ Ash ash
ʃ Esh esh
ə Schwa schwa
ɚ With hook(hooked)Schwa hschwa
ɔ Open o oo
α alpha alfa
ː Long vowel colon lvc
ʌ Caret, wedge, hat crt
ð Eze eth
θ Theta th

For example, in the case of a pair of "ɚ" and "ː", it is described as "hschwa_lvc".

By the way, a, r, v, etc. are described as they are.

Remarks

Actually, I have created a similar application with C ++ / CLI which is an extension of C ++ for .NET, referring to the following book instead of python.

https://www.amazon.co.jp/%E3%82%A2%E3%83%97%E3%83%AA%E3%82%92%E4%BD%9C%E3%82%8D%E3%81%86-Visual-%E5%85%A5%E9%96%80-2015%E5%AF%BE%E5%BF%9C/dp/4822298760

However, I struggled in front of the difficult language that the specification of C ++ / CLR is complicated and lacks information, and although I managed to make something similar to this post, it became a difficult thing to handle because it lacked maintainability. I remade it with python and posted it in this article.

Information that was used as a reference

Special thanks to the following. I am very grateful to you for all the useful information.

Contents Link destination
How to play audio files https://qiita.com/kekeho/items/a0b93695d8a8ac6f1028
How to handle json https://qiita.com/kikuchiTakuya/items/53990fca06fb9ba1d8a7
How to randomly access the dictionary type https://teratail.com/questions/108589
Implementation of processing when the mouse pointer is placed on the widget https://tutorialmore.com/questions-716474.htm
Event sequence http://www.rouge.gr.jp/~fuku/tips/python-tkinter/bind.shtml
Change mouse icon https://suzutaka-programming.com/tkinter-cursor/ https://anzeljg.github.io/rin2/book2/2405/docs/tkinter/cursors.html
Displaying objects/Hide https://www.delftstack.com/ja/howto/python-tkinter/how-to-hide-recover-and-delete-tkinter-widgets/
Radio button settings https://pg-chain.com/python-radiobutton
About grid https://python.keicode.com/advanced/tkinter-grid.php
About Text widget https://www.shido.info/py/tkinter12.html
Judgment of only letters https://vatchlog.com/python-alnum/
Handling of global variables in functions https://snowtree-injune.com/2018/07/29/post-734/
Name of each phonetic symbol https://english-columns.weblio.jp/?p=1788 https://ja.wikipedia.org/wiki/%E5%9B%BD%E9%9A%9B%E9%9F%B3%E5%A3%B0%E8%A8%98%E5%8F%B7%E3%81%AE%E6%96%87%E5%AD%97%E4%B8%80%E8%A6%A7 https://eigonokai.jp/phonetics/7-%E6%AF%8D%E9%9F%B3%EF%BC%9A%CA%8C%E3%81%AE%E7%99%BA%E9%9F%B3/

Finally

We would be very grateful if you could give us feedback on GUI and source improvements! !!

Recommended Posts

[Python] I made an app to practice the subtle voice distinction of English words.
I made an appdo command to execute a command in the context of the app
I made an app to find out who the members of the Straw Hat Pirates look like
I made a program to check the size of a file in Python
I made a function to see the movement of a two-dimensional array (Python)
(Python) I made an app from Trello that periodically notifies slack of tasks that are about to expire.
With LINEBot, I made an app that informs me of the "bus time"
I made a script to record the active window using win32gui of Python
[Python] I created an app that automatically downloads the audio file of each word used for the English study app.
I made an action to automatically format python code
I tried to classify the voices of voice actors
I tried to summarize the string operations of Python
Python practice 100 knocks I tried to visualize the decision tree of Chapter 5 using graphviz
I tried to find the entropy of the image with python
I made a function to check the model of DCGAN
[Python] I tried to visualize the follow relationship of Twitter
I want to know the features of Python and pip
I made a function to crop the image of python openCV, so please use it.
I made a program in Python that changes the 1-minute data of FX to an arbitrary time frame (1 hour frame, etc.)
[Python] I made a Line bot that randomly asks English words.
How to know the internal structure of an object in Python
I want to extract an arbitrary URL from the character string of the html source with python
[Introduction to Python] I compared the naming conventions of C # and Python.
I want to output the beginning of the next month with Python
I wrote the code to write the code of Brainf * ck in python
[Python] Simple Japanese ⇒ I tried to make an English translation tool
I tried to improve the efficiency of daily work with Python
I tried to output the rpm list of SSH login destination to an Excel sheet with Python + openpyxl.
I made an npm package to get the ID of the IC card with Raspberry Pi and PaSoRi
[Python] I tried to summarize the set type (set) in an easy-to-understand manner.
Python Note: When you want to know the attributes of an object
(Python Selenium) I want to check the settings of the download destination of WebDriver
I want to batch convert the result of "string" .split () in Python
I want to explain the abstract class (ABCmeta) of Python in detail.
I tried to get the authentication code of Qiita API with Python.
(Python) I tried to analyze 1 million hands ~ I tried to estimate the number of AA ~
I want to color a part of an Excel string in Python
I tried to verify and analyze the acceleration of Python by Cython
I tried to streamline the standard role of new employees with Python
I want to leave an arbitrary command in the command history of Shell
I tried to get the movie information of TMDb API with Python
Python: I want to measure the processing time of a function neatly
[Lambda] I tried to incorporate an external module of python via S3
An example of the answer to the reference question of the study session. In python.
I made Othello to teach Python3 to children (4)
The story of making Python an exe
I made Othello to teach Python3 to children (2)
I made an online frequency analysis app
I didn't know the basics of Python
I made Othello to teach Python3 to children (5)
The Python project template I think of.
Create an English word app with python
I made Othello to teach Python3 to children (3)
I made Othello to teach Python3 to children (1)
I created a script to check if English is entered in the specified position of the JSON file in Python.
Part 1 I wrote an example of the answer to the reference problem of how to write offline in real time in Python
I'm an amateur on the 14th day of python, but I want to try machine learning with scikit-learn
I made a tool to estimate the execution time of cron (+ PyPI debut)
[Python] I want to know the variables in the function when an error occurs!
[Python] I tried to judge the member image of the idol group using Keras
I want to use Python in the environment of pyenv + pipenv on Windows 10