WebSpeechRecognition 은 실시간으로 음성을 텍스트로 변환하는 데 도움이 되는 Python 라이브러리입니다. Selenium WebDriver 및 HTML5 Web Speech API를 사용합니다. 이 도구는 Chrome WebDriver와 함께 작동하도록 제작되었으며 음성 인식 작업에 사용하기 쉽습니다.
WebSpeechRecognition 설치하려면 pip를 사용할 수 있습니다.
pip install WebSpeechRecognition
WebSpeechRecognition 사용을 시작하려면 ChromeDriver 실행 파일의 경로와 언어 코드를 사용하여 SpeechRecognition
클래스를 초기화하세요.
from WebSpeechRecognition import SpeechRecognition
recognizer = SpeechRecognition ( "path/to/chromedriver" , language = "en-US" )
recognizer . Init ()
음성 듣기 및 텍스트 변환을 시작하려면 Listen
메서드를 사용하세요. 이 메소드는 복사된 텍스트를 반환합니다.
text = recognizer . Listen ( print_allowed = True )
print ( f"You said: { text } " )
완료되면 Quit
메소드를 사용하여 ChromeDriver 인스턴스를 닫습니다.
recognizer . Quit ()
완전한 예는 다음과 같습니다.
from WebSpeechRecognition import SpeechRecognition
recognizer = SpeechRecognition ( "path/to/chromedriver" , language = "en-US" )
recognizer . Init ()
while True :
try :
text = recognizer . Listen ( print_allowed = True )
print ( f"You said: { text } " )
except KeyboardInterrupt :
recognizer . Quit ()
break
SpeechRecognition(driver_path, language)
driver_path
: Chrome WebDriver 파일의 경로입니다.language
: 인식을 위한 언어 코드입니다(기본값: "en-US").Init()
음성 인식 옵션을 사용하여 WebDriver를 설정합니다.
Listen(print_allowed=False)
듣기를 시작하고 듣는 텍스트를 반환합니다.
print_allowed
: True인 경우 인식된 텍스트를 콘솔에 인쇄합니다.Quit()
WebDriver를 중지하고 모든 것을 닫습니다.
우리는 기여를 환영합니다! 버그를 발견했거나 새로운 기능에 대한 아이디어가 있는 경우 GitHub 저장소에서 문제를 공개하거나 끌어오기 요청을 보내주세요.
SpeechRecognition 개선에 도움을 주고 싶으신가요? 방법은 다음과 같습니다.
git checkout -b feature-branch
).git commit -m 'Add feature'
).git push origin feature-branch
). 이 프로젝트는 MIT 라이센스를 사용합니다. 자세한 내용은 LICENSE
파일을 참조하세요.
질문이나 제안사항이 있으신가요? 저희에게 연락하세요: