WebSpeechRecognition เป็นไลบรารี Python ที่ช่วยเปลี่ยนคำพูดเป็นข้อความแบบเรียลไทม์ ใช้ Selenium WebDriver และ HTML5 Web Speech API เครื่องมือนี้สร้างขึ้นเพื่อทำงานร่วมกับ Chrome WebDriver และใช้งานง่ายสำหรับงานรู้จำเสียง
หากต้องการติดตั้ง WebSpeechRecognition คุณสามารถใช้ pip:
pip install WebSpeechRecognition
หากต้องการเริ่มใช้ WebSpeechRecognition ให้เริ่มต้นคลาส SpeechRecognition
ด้วยเส้นทางไปยังไฟล์ปฏิบัติการ ChromeDriver และรหัสภาษา:
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 WebDriverlanguage
: รหัสภาษาสำหรับการจดจำ (ค่าเริ่มต้น: "en-US")Init()
ตั้งค่า WebDriver ด้วยตัวเลือกสำหรับการรู้จำเสียง
Listen(print_allowed=False)
เริ่มฟังและส่งกลับข้อความที่ได้ยิน
print_allowed
: หากเป็นจริง ให้พิมพ์ข้อความที่รู้จักไปยังคอนโซลQuit()
หยุด WebDriver และปิดทุกอย่าง
เรายินดีต้อนรับการมีส่วนร่วม! หากคุณพบจุดบกพร่องหรือมีแนวคิดเกี่ยวกับฟีเจอร์ใหม่ อย่าลังเลที่จะเปิดปัญหาหรือดึงคำขอบนพื้นที่เก็บข้อมูล GitHub ของเรา
ต้องการช่วยปรับปรุงการรู้จำเสียงหรือไม่ มีวิธีดังนี้:
git checkout -b feature-branch
)git commit -m 'Add feature'
)git push origin feature-branch
) โครงการนี้ใช้ใบอนุญาต MIT ดูไฟล์ LICENSE
สำหรับรายละเอียด
มีคำถามหรือข้อเสนอแนะ? ติดต่อเรา: