WebSpeechRecognition
1.0.0
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 儲存庫上提出問題或拉取請求。
想要幫助改進語音辨識嗎?方法如下:
git checkout -b feature-branch
)。git commit -m 'Add feature'
)。git push origin feature-branch
)。該專案使用 MIT 許可證。有關詳細信息,請參閱LICENSE
文件。
有疑問或建議嗎?聯絡我們: