Magic Voice Switch is a project inspired by a popular Instagram video where magic words like "開damn~~" and "關damn~~" are used to control lights. Although the video was proven to involve manual control, this project aims to bring the idea to life by using voice commands to control lights.
The project supports two modes:
- Machine Learning Mode: Uses a model trained with Teachable Machine to recognize specific magic words.
- Speech-to-Text (STT) Mode: Recognizes similar sounding words to classify them into categories.
- 0: Background Noise
- 1: 開damn
- 2: 開燈
- 3: 關damn
- 4: 關燈
- Integrate with Raspberry Pi to control physical LED lights.
- Develop a more visually appealing web interface for cloud deployment.
librosa
numpy
PyAudio
SpeechRecognition
openai
tensorflow
python-dotenv
Mac should brew install portaudio
at first to install PyAudio
.
$ python3 -m venv venv
$ source venv/bin/activate
$ pip install -r requirements.txt
$ deactivate
$ rm -rf venv # remove the venv
$ pip install virtualenv
$ virtualenv venv
$ venv\Scripts\activate
$ pip install -r requirements.txt
$ deactivate
$ rmdir /s venv # remove the venv
Run the following command to start the voice recognition loop:
python main.py
You will be prompted to choose the mode:
- If you choose Model, the system will use the trained model for recognition.
- If you choose STT, you will be prompted to choose between Google or OpenAI for speech-to-text processing.