小語 XiaoYu – Local Voice Assistant

XiaoYu is a lightweight Python voice assistant designed to run locally on your device. She can respond in a Taiwanese girl voice, report weather and traffic conditions, and assist with daily commutes such as “送娃” (school run) and heading to work. XiaoYu supports multiple speaking styles and understands casual Mandarin voice commands.


💡 Features

  • 🎤 Speech recognition via Google STT
  • 🗣️ Text-to-Speech (TTS) using Google Cloud TTS (Taiwanese voice)
  • 🌦️ Weather info via OpenWeather API
  • 🚗 Real-time traffic + ETA using Google Maps Distance Matrix
  • 🎭 Style switching: 可愛 (cute), 撒嬌 (spoiled), 自然 (natural), 長沙 (plastic accent)
  • 🏠 Predefined destinations: school, company, “搬磚” (work slang), and school+company for “送娃”

⚙️ Installation

1. Clone project and set up virtual environment

bashCopyEditgit clone https://github.com/yourname/xiaoyu-assistant.git
cd xiaoyu-assistant
python3 -m venv orsiris-env
source orsiris-env/bin/activate

2. Install dependencies

bashCopyEditpip install --upgrade pip
pip install --break-system-packages -r requirements.txt

If pyaudio fails, install portaudio manually:

bashCopyEditsudo apt install portaudio19-dev
pip install --break-system-packages pyaudio

3. Create .env file in the root folder

envCopyEditGOOGLE_CREDENTIALS_JSON=orsiris-key.json
GOOGLE_MAPS_API_KEY=your_google_maps_api_key
OPENWEATHER_API_KEY=your_openweather_api_key
HOME_LOCATION=962 Watercress LN,Walnut, CA

Place your Google Cloud credentials JSON file (TTS/STT access) in the project root and name it accordingly.


▶️ How to Use

Run the assistant:

bashCopyEditpython3 xiaoyu.py

You will hear XiaoYu greet you and ask where you’re going.

🔈 Voice Commands (examples):

  • 「今天要去搬磚」
  • 「請導航去學校」
  • 「送娃」 → triggers school + company route
  • 「今天天氣如何?」
  • 「切換語氣 撒嬌」
  • 「掰掰」 → exits

🎨 Speech Style Switch

You can say:

  • 「語氣可愛」 → Default cheerful style
  • 「語氣撒嬌」 → Spoiled/girly style
  • 「語氣自然」 → Calm tone
  • 「語氣長沙」 → Plastic Mandarin accent (for fun)

🧪 Example Interaction

textCopyEdit[啟動] 小語 XiaoYu 上線囉!
[你] 今天要去學校
[小語] 從這裡到學校,大約 17 分鐘,預計 08:42 到唷~有些塞車~

🧱 Directory Structure

bashCopyEditorsiris-env/
├── xiaoyu.py                  # Main script
├── xiaoyu_speech_style.py     # Speech style helper
├── orsiris-key.json           # Google TTS/STT credentials
├── .env                       # Environment variables
├── output.wav                 # TTS playback file

🛠️ Notes

  • Internet is required for TTS/STT and API calls.
  • Google Cloud billing is needed after free tier is exceeded.
  • HOME_LOCATION can be customized to your real address.