if โ Use == (two equal signs), NOT =import time before time.sleep())input() always returns a string by defaulttts.say() ๐cloudspeech.recognise() ๐คcloudtranslation.translate() ๐cloudvision.recognise() or take_photo() ๐ธ๐ค Artificial Intelligence (AI) ไบบๅทฅๆบๆ
ง
Machines that simulate human thinking ๐ง , cognitive functions ๐ญ, learning from experience ๐, and decision-making โก.
๐ Real-life Applications (ๆฅๅธธๆ็จ):
๐ Libraries ๅฝๅผๅบซ = Toolbox ๐งฐ containing useful functions ๅฝๆธ (like trigonometric functions).
Example: import tts โ then use tts.say()
โ๏ธ Google Colab
Free online Python editor. Notebooks saved automatically in Google Drive. Cells = Code + Text.
๐ฆ Library: tts
๐ก Basic Code:
import tts
tts.say("Hello World!")
โ๏ธ Advanced Parameters:
tts.say("Hello, how are you?",
pitch=-5, # -20.00 to 20.00
speaking_rate=0.5) # 0.25 to 4.00
๐ Language Support:
"en-uk" ๐ฌ๐ง"yue-HK" ๅปฃๆฑ่ฉฑ ๐ญ๐ฐ"cmn-CN" ๆฎ้่ฉฑ ๐จ๐ณ๐ฏ English Lesson Missions:
๐ Definition: Named containers that store values.
๐ก Assignment:
x = "Hello World"
name = "Apple"
โ ๏ธ Rules for Variable Names (้่ฆ!):
_import, class, if, print, etc.)name โ NAME)โ Examples:
four_dir, apple_pie, lesson, _finalโ Examples:
4dir, apple pie, class, import๐จ๏ธ Printing:
print(name) # prints value
print("name") # prints literal string "name"
print("Hello", name) # mixes string + variable
๐ Reassignment:
district = "Hong Kong"
district = "Kowloon" # old value overwritten
name = input("What is your name? ")
print("Hello", name)
input() returns stringinput() calls๐ฆ Library: cloudtranslation
๐ก Basic:
import cloudtranslation
result = cloudtranslation.translate("Hello")
๐ With Language:
cloudtranslation.translate("Hello", lang="yue-HK")
๐ฏ Interactive Version (Mission):
input() for textinput() for target language code๐ฆ Library: cloudspeech
import cloudspeech
print("Say something...")
text = cloudspeech.recognise()
print("You said:", text)
๐ Speech-to-Text Process:
| Operation ้็ฎ | Operator ้็ฎ็ฌฆ |
|---|---|
| Addition ๅ ๆณ | + |
| Subtraction ๆธๆณ | - |
| Multiplication ไนๆณ | * |
| Division ้คๆณ | / |
๐ฏ Example Missions:
area = len * len ๐perimeter = 2 * PI * r โญprint() quotes & syntaximport time before time.sleep(60)print()๐ฌ Virtual Assistant: AI that responds to natural language commands (weather, calendar, alarms).
๐ค Chatbots:
๐ Key Technologies:
== vs = โ Variable names โ Data types