如何检查语音的发音?

How can I check pronunciation of speech?

我正在做一个项目,程序将获取语音输入,然后检查其发音是否正确(我将其用于语言学习网站)。 我试图使用 google 翻译器来检查发音,但我认为它没有那个功能。有什么想法吗?

这是我的语音识别脚本:

import speech_recognition
import pyttsx3

recognizer = speech_recognition.Recognizer() 

while True:
    try:
        with speech_recognition.Microphone() as mic:
            recognizer.adjust_for_ambient_noise(mic, duration=0.2)
            audio = recognizer.listen(mic) 

            text = recognizer.recognize_google(audio)
            text = text.lower()
            print(text)

所以我又需要一些可以检查单词发音的东西。

import pyttsx3

import speech_recognition as sr

engine = pyttsx3.init("sapi5")

voices = engine.getProperty("voices")

engine.setProperty("voice", voices[1].id)


def speak(audio):
    
    engine.say(audio)
    
    engine.runAndWait()


def takeCommand():
    
    listener = sr.Recognizer()
    
    with sr.Microphone() as source:
        
        print("Listening.......")
        
        listener.pause_threshold = 1
        
        listener.energy_threshold = 400  # This will listen to the louder voice only, so all you need to do is to speak loudly to give the command.
        
        audio = listener.listen(source, timeout=1, phrase_time_limit=10)  # It will give you ten seconds to give the argument otherwise it will run again
        
        try:
            
            print(" Recognising.....")
            
            query = listener.recognize_google(audio, language="en-in")  # Here you can choose the language of your choice
            
            print(f" User said --> {query} \n")
            
        except Exception as e:
            
            # print(e)
            
            print("Sorry I didn't Recognise. Please say it again.....")
            
            return "None"
        
        return query

if __name__ == '__main__':
    
    speak("Hello boss, How're you?")
    
    while True:
        
        takeCommand()