Welcome! You have been invited by anhmaihong to join our community. Please click here to register.
1 người đang xem
1970 137
Những thứ cần chuẩn bị để thực hiện:

Cài đặt python và vscode hoặc pycharm

Nhấn nút cửa sổ trên bàn phím nhập cmd và ghi:

Pip install pyttsx3

Pip install datetime

Pip install speech_recognition

Vào trang web này và tải bản audio phù hợp với version của bạn PyAudio: PortAudio v19 Python Bindings rồi vào cmd nhập: Pip install rồi nhập tên version bạn vừa mới tải về sau chữ install


Code:

Import pyttsx3

Import datetime

Import speech_recognition as sr

Import webbrowser as wb

Import os

Friday = pyttsx3. Init ()

Voice=Friday. GetProperty ('voices')

Friday. SetProperty ('voice', voice[1] . Id)

Def speak (audio) :

Print ('F. R. I. D. A. Y' + audio)

Friday. Say (audio)

Friday. RunAndWait ()

Speak ('Hello Boss')

Def time () :

Time=datetime. Datetime. Now (). Strftime ('%I: %M: %p')

Speak (Time)

Time ()

Def welcome () :

Hour=datetime. Datetime. Now (). Hour

If hour >= 6 and hour<12:

Speak ('Goodmorning boss')

Elif hour >= 12 and hour<18:

Speak ('Good afternoon boss')

Elif hour >=18 and hour<24:

Speak ( "Good Night boss")

Speak ('How can I help you?')

Def command () :

C=sr. Recognizer ()

With sr. Microphone () as source:

C. Pause_theshold=0.1

Audio=c. Listen (source)

Try:

Query=c. Recognize_google (audio, language='vi')

Print ( "Tuan Minh:" + query)

Except sr. UnknownValueError:

Print ( "Please repeat or typing the command")

Query=str (input ('Your order is: '))

Return query

If __name__ == '__main__':

Welcome ()

While True:

Query = command (). Lower ()

If "google" in query:

Speak ( "What should I search boss?")

Search=command (). Lower ()

Url=f "Google {search}"

Wb. Get (). Open (url)

Speak (f "Here is your {search} on google")

If "youtube" in query:

Speak ( "What should I search boss?")

Search=command (). Lower ()

Url=f "Link {search}"

Wb. Get (). Open (url)

Speak (f "Here is your {search} on youtube")

Elif "open" in query:

Tkb=r "C: \Users\Admin\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Microsoft Teams"

Os. Startfile (tkb)

Elif "time" in query:

Time ()

Elif "thoát" in query:

Speak ( "Friday is off. Goodbye boss")

Quit ()
 

Những người đang xem chủ đề này

Nội dung nổi bật

Xu hướng nội dung

Back