Giter Site home page Giter Site logo

sspathak / voicechat Goto Github PK

View Code? Open in Web Editor NEW
43.0 3.0 8.0 19.06 MB

a Python voice chat app that uses WebSockets to send encrypted data between a multi-threaded client and server

License: MIT License

Python 100.00%
python websockets voicechat encryption multithreading producer-consumer sounddevice buffer consumer thread

voicechat's Introduction

VoiceChat

An encrypted voice chat app, written in Python, that uses websockets to send data between a multi-threaded client and server

Setup

  • install python-sounddevice python3 -m pip install sounddevice --user
  • install numpy pip install numpy

How do I put the server on the internet?

GCP instructions

  • Create a new compute engine instance - for example N1 Series' F1 Micro - on GCP (*It's free!)
  • In firewall settings, allow access to port 9001 (and any other port that is being used in the Python server code)
  • Install Python 3.7+ and pip3 on the server (link, link)
  • Clone this repository onto the server
  • Install dependencies using pip3 install -r requirements.txt
  • Update PYTHONPATH with export PYTHONPATH=$PYTHONPATH:/path/to/VoiceChat
  • Run the Python server script -- NOTE: you might have to update the SOCK_IP address (line 6, pythonserver.py)

Now, the server should be up and running!

  • Next, clone this repository onto your PC and update the pythonclient.py file with the "External IP adderss" of your compute engine VM
  • You can also change the encryption password
  • Run the client and follow the instrucitons to pick a user ID for the client. Then enter the recipient's ID
  • Repeat the above step for a second client instance and assign it the user ID entered for recipient ID above. The recipient for this client will be the user ID of the client from the previous step. In other words: user ABC wishes to call user XYZ, and user XYZ wishes to call user ABC.
  • The server should print "establishing connection..." after which the clients can engage in conversation. ย 

*NOTE: Only 1 GB of free network traffic is permitted on GCP after which you will have to pay if you wish to use more data.

Client

The client creates two threads - record-transmit and recieve-play. Each thread creates two more threads that simultaneously fill and empty a shared buffer

  • record-transmit: recorder (producer) transmitter (consumer) share one buffer
  • receive-play: receiver (producer) player (consumer) share one buffer

uses sounddevice module to read and write to an audio stream (https://python-sounddevice.readthedocs.io/en/0.4.0/#) uses Python's threading module to manage threads and enable concurrency

Server

Creates a Client object whenever a user connects to the server

  • Each connected client gets its own thread
  • Client specifies its own identifier and recipient

Once both the clients (source) are connected and have each other as recipients (destination), the server enters conversation mode In conversation mode, all data received from one source is directly sent over to the destination.

voicechat's People

Contributors

sspathak avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

voicechat's Issues

Client Error

I ran pythonserver.py and it appears to work no problem, binding to 0.0.0.0:9001. However, when I run pythonclient.py I get this error:

File "C:\Python\VC\VoiceChat\pythonclient.py", line 283, in connect
s.connect((SERVER_IP, SERVER_PORT))
OSError: [WinError 10049] The requested address is not valid in its context

I do not think this is a device error. Do you have any ideas for a fix?

Stuttering audio still persists

Hello. Thank you for the previous fix, but I'm still having stuttering audio when sleep is used. Without it, now it doesn't crash on the CBC but does very weird sounding, like robotic/high pitch sounds. Plus it also stutters a bit. It's barely understandable what is said. I'm thinking that maybe is just happening to me?

Stuttering audio/recording

Barely can't hear anything because the audio is very stuttered. I set the SLEEPTIME to 0 and it fixed for a short amount of time. It raises a CBC padding issue and the socket times out after a few seconds. Do you know what seems to be the problem? I tried all sorts of padding, can't get past the padding issue nor the stuttering one.

This is the padding error:
"(...)
raise ValueError("Data must be padded to %d byte boundary in CBC mode" % self.block_size)
ValueError: Data must be padded to 16 byte boundary in CBC mode
"

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.