使用 SpeechRecognition 函式庫
為了不用每次都輸入 speech_recognition,我們會把它以 sr 的別名匯入。
我們也會建立一個 Recognizer 類別的實例,待會要用。
energy_threshold 是介於 0 到 4000 的數值,用來控制 Recognizer 類別在聆聽音訊檔時的靈敏度。
當辨識器類別在聆聽音訊時,energy_threshold 會動態調整。
本練習屬於課程
Python 的口語語言處理
練習說明
- 將
speech_recognition函式庫以sr的別名匯入。 - 建立一個
Recognizer類別的實例,並將它存到recognizer。 - 將
recognizer.energy_threshold設為 300。
動手互動練習
試著完成這個範例程式碼,體驗一下這個練習。
# Importing the speech_recognition library
import ____ as ____
# Create an instance of the Recognizer class
____ = sr.____()
# Set the energy threshold
recognizer.____ = ____