A Python project that enables two devices to exchange text messages using sound waves. Perfect for hackathons, demos, and exploring digital signal processing!
# Create virtual environment
python -m venv sound-chat-env
# Activate virtual environment
sound-chat-env\Scripts\Activate.ps1
# If you get execution policy errors, run this first:
Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope CurrentUser# Install all required packages
pip install -r requirements.txtOn Device 1 (Sender):
# Send "HELLO" message
python sender.py "HELLO"On Device 2 (Receiver):
# Start listening for messages
python receiver.pysound-chat/
├── sender.py # Transmits text as sound waves
├── receiver.py # Receives and decodes sound waves
├── requirements.txt # Python dependencies
└── README.md # This file
- Bit '0': 1000 Hz tone
- Bit '1': 2000 Hz tone
- Start Signal: 500 Hz tone
- End Signal: 3000 Hz tone
- Sender: Text → Binary → Audio frequencies → Sound waves
- Receiver: Sound waves → Frequency analysis → Binary → Text
# Basic usage
python sender.py "YOUR MESSAGE"
# Custom parameters
python sender.py "HELLO WORLD" --sample-rate 44100 --bit-duration 0.1Parameters:
message: Text to send (required)--sample-rate: Audio sample rate (default: 44100 Hz)--bit-duration: Duration per bit in seconds (default: 0.1s)
# Basic usage
python receiver.py
# Custom parameters
python receiver.py --timeout 60 --sample-rate 44100 --bit-duration 0.1Parameters:
--timeout: Recording timeout in seconds (default: 30s)--sample-rate: Audio sample rate (default: 44100 Hz)--bit-duration: Duration per bit in seconds (default: 0.1s)
- Use different audio devices (if available)
- Use headphones + microphone to prevent feedback
- Adjust volume to medium level
- Position devices close (1-3 feet apart)
- Use external speakers for better transmission
- Minimize background noise
PermissionError: [Errno 13] Permission denied
Solution:
Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope CurrentUserOSError: No Default Input Device Available
Solutions:
- Check Windows audio settings
- Grant microphone permissions to Python
- Test with
python -c "import sounddevice; print(sounddevice.query_devices())"
ERROR: Microsoft Visual C++ 14.0 is required
Solutions:
# Option 1: Install pre-compiled wheel
pip install pipwin
pipwin install pyaudio
# Option 2: Use conda instead
conda install pyaudioCheck:
- Volume levels (not too low/high)
- Background noise
- Distance between devices
- Both devices using same parameters
Solutions:
- Increase bit duration:
--bit-duration 0.2 - Reduce background noise
- Move devices closer
- Check audio device quality
# Test audio devices
python -c "import sounddevice as sd; print(sd.query_devices()); sd.check_input_settings()"
# Test microphone
python -c "import sounddevice as sd; import numpy as np; print('Recording...'); data = sd.rec(2*44100, samplerate=44100, channels=1); sd.wait(); print(f'Max level: {np.max(np.abs(data))}')"-
Test everything beforehand
# Quick test sequence python sender.py "TEST" & timeout 5 python receiver.py --timeout 10
-
Prepare backup messages
# Create test script echo 'python sender.py "HELLO HACKATHON"' > test.bat
-
Use reliable hardware
- External USB microphone/speakers
- Wired connections when possible
-
Have multiple test messages ready
python sender.py "DEMO" python sender.py "HELLO WORLD" python sender.py "SOUND CHAT WORKS"
# Faster transmission (shorter messages)
python sender.py "HI" --bit-duration 0.05
# More reliable transmission (longer messages)
python sender.py "HELLO" --bit-duration 0.2Modify the frequency constants in both files:
# In sender.py and receiver.py
self.freq_0 = 1000 # Frequency for bit '0'
self.freq_1 = 2000 # Frequency for bit '1'
self.freq_start = 500 # Start signal
self.freq_end = 3000 # End signal# Device 1 → Device 2
python sender.py "MSG1"
# Device 2 → Device 1
python sender.py "MSG2"
# Device 3 listening
python receiver.py- Frequency Range: 500-3000 Hz
- Data Rate: ~80 bits/second (default settings)
- Character Encoding: ASCII (8 bits per character)
- Sample Rate: 44.1 kHz
- Transmission Range: 1-10 meters (depending on environment)
- Noise Sensitivity: Background noise can interfere
- Range Limited: Works best within a few meters
- ASCII Only: Non-ASCII characters may not transmit correctly
- One-Way: No built-in acknowledgment system
- Error Correction: Add checksums or parity bits
- Compression: Implement text compression
- GUI Interface: Create a user-friendly interface
- File Transfer: Extend to send small files
- Two-Way Chat: Implement full duplex communication
- Check this README for common solutions
- Test each component separately:
python -c "import numpy, scipy, sounddevice; print('All imports work!')"
- Verify audio hardware:
python -c "import sounddevice as sd; sd.default.device = [0, 1]; print(sd.query_devices())"
For hackathon support or questions, check the project repository or ask your mentors!
Happy Hacking! 🎉
Built for hackathons with ❤️ - Ready to demo in minutes!