audio streaming using python (pyaudio) and a web interface - python

So excited for My first post in Stackoverflow! :)
Q: I'm recording and processing sounds using python (pyaudio + scipy). now one important thing that I need, is the ability to streaming this processed audio(that's in form of python Variables),Over wifi (or bluetooth). User clients that connecting to my server, should can play that sound for Live. But really I haven't any background about web/net based application in python.
I'm thinking this way :
Maybe linux should establish a server(become a Access point) and give access to users for playing streamed audio using a simple html page! This webpage maybe need just a play button that when client click on that,and live streaming audio will be played!
Can anybody guide me in right way?

Related

How to create notification on a webpage

This question is related to backend development. I am an intermediate-knowledge university student working in this field.
For my project, I am developing a website that alerts the user if something's missing from its place. For example, a valuable thing is placed under the scrutiny of CCTV. Then I detect the object using Image processing and as the thing is gone, I want to raise an alert.
I have done Image processing and am able to detect the presence/absence of the object on my local machine. I want to deploy such a thing on the server for end-consumer usage.
But then how to do this on the server because then two things need to be done at once, the video needs to be continuously processed, and when there is an alert, a notification should be kept in the notification feed (just like any social media platform), while also continuously monitoring the video.
I am familiar with Django.
In a nutshell, I want to understand how social media websites, also sometimes show notifications while we are scrolling the feed. How two things are managed at one time?
Thank you for the help.
Regards.

How Call a Python Websocket from a NFC Scanned on the phone(straight from the phone like with a URL)

Ok, no code here, more trying to get some directions.
I'm working on my home automation using tuya objects. Till now I was able to create a websocket (using python websockets and asyncio) that gets a message and turn on my devices. I created a flask website to configure passwords, keys etc. Now what I'm trying to achieve is using a NFC tag(scanned by my phone) call the websocket sending a message. I bought some NFC tags, got a an android app called NFC Tools to record data into the NFC tag.
Problem is NFC tools doesnt give me too many options I can add text, and URLs but I dont know how to call my websocket from there. Can I call it using its URL like ws://something.go? Can I make the phone not open a browser when I scam the tag? Should I create a page on flask for that and put the page address?
Anyway, I'm kind of lost. Can you guys point me in the right direction?
The right direction is to write your own NFC app for your phone.
In OS has a basic limited (fallback) idea of how to process the different type of Ndef record types, but it mostly relies on App's registering that they are capable for processing a certain record type.
So the OS can process various URL formats and open a web browser BUT ws: is not a standard URI as defined by the Ndef specs.
Thus the OS has nothing to processes it with.
To solve this you would best to make up your own mimeType string and create an App that registers that it can process this mimeType (Android docs on this, iOS has something similar). Then when you scan your custom Tag and the OS know what App can process this Tag, you app then reads the data and processes it accordingly and open the websocket request itself.
End up creating a get route on flask and using NFC Tools Pro with http get to access it. The route just send a message to my websocket and turn on or off my devices. Thx Andrew for the tip I will have that in mind if this goes anywhere far from a personal project.

creating a web interface that displays live data from hardware

I am trying to create a web interface to display some data that is being extracted live from a piece of hardware.
I have already written a program using pyQt that extracts data every second. I was wondering if it is possible to simultaneously push this data to a web interface with Python.
I want the webpage to not continuously refresh as data is coming in every second. Charts are essential, I have to have the ability to plot the data that is being pushed.
Can anyone suggest me how I would go about doing this?
Probably the most conventional way to go about this would be to write some server-side code to communicate with the device, and save responses (all of them? the most recent n?) to a database. You'd expose this to a REST API, which you'd then call at a specified interval using AJAX from the browser.

uPnP pushing video to Smart TV/Samsung TV on OSX/Mac

I would like to make a simple script to push a movie to a Smart TV.
I have already install miniupnp or ushare, but I don't want to go in a folder by the TV Smart Apps, i want to push the movie to the TV, to win time and in future why not make the same directly from a NAS.
Can anyone have an idea how to do this ? This application SofaPlay make it great but only from my mac.
Thanks you
You will still need a DLNA server to host your videos on. Via UPnP you only hand the URL to the TV, not the video directly. Once you have it hosted on a DLNA server, you can find out the URL to a video by playing it in Windows Media Player (which has DLNA-support) or by using UPnP Inspector (which I recommend anyways, if you are going to be working with UPnP). You can then push this URL to the TV, which will download and play the video, if its format is supported.
I do not know my way around python, but you since UPnP is HTTP based, you will need to send an HTTP request with appropriate UPnP-headers (see wikipedia or test it yourself with UPnP Inspector) and the proper XML-formatted body for the function you are trying to use.
The UPnP-function I worked with to push a link to the TV is "SetAVTransportURI", but it might differ from your TV. Use UPnP Inspector to find the correct one, including its parameters.
In summary: Get a DLNA-Server to host you videos on. Find out the links to those videos using UPnP Inspector or other DLNA-clients. Find out the UPnP-function that sends a URL to your TV (again, I recomment UPnP Inspector, you can explore and call all functions with it). Implement a call to that function in your script.

Python application communicating with a web server? Ideas?

I'm looking for a bit of web development advice. I'm fairly new to the area but I'm sure there are some gurus out there willing to part with some wisdom.
Objective: I'm interested in controlling a Python application on my computer from my personal web hosted site. I know, this question has been asked several times before but in each case the requirements were a bit different from my own. To reduce the length of this post I'll summarize my objective in a few bullet points:
Personal site is hosted by a web hosting company
Site uses HTML, PHP, MySQL, Python and JavaScript, the majority of everything is coded by me from the ground up
An application that is coded in Python will run on a PC within my home and will communicate with an Arduino board
The app will receive commands from the internet to control actuation via the Arduino, and will transmit sensor data back to the site (such as temperature)
Looking for the communication to be bi-directional, fast and secure
Securing the connection between site and Python app would be most ideal
I'm not looking to connect to the Python application directly, the web server must serve as the 'middle man'
So far I've considered HTTP Post and HTML forms, using sockets (Python app would run as a web server), an IRC bot and reading/writing to a text file stored on the web server.
I was also hoping to have a way to communicate with the Python app without needing to refresh the webpage, perhaps using AJAX or JavaScipt? Maybe with Flash?
Is there something I'm not considering? I feel like I'm missing something. Thanks in advance for the advice!
Just thinking out loud for how I would start out with this. First, regarding the website itself, you can just use what's easiest to you, or to the environment you're in. For example, a basic PHP page will do just fine, but if you can get a site running in Python as well, I'd prefer using the same language all over.
That said, I'm not sure why you would need to use a hosted website? Given that you're already forced to have a externally accessible PC at home for the communication, why not run a webserver on that directly (Apache, Nginx, or even something like CherryPy should do)? That webserver can then communicate with the python process that is running to control your Arduino (by using e.g. Python's xmlrpclib). If you would run things via the hosting company, you would still need some process that can handle external requests securely... something a webserver is quite good at. Just running it yourself gives you all the freedom you want, and simplifies things by lessening the number of components in your solution.
The updates on your site I'd keep quite basic: commands you want to run can be handled in the request handlers of the webserver by just calling the relevant (xmlrpclib) calls. Dynamically updating the page is best done by some AJAX calls I reckon. Based on your story, these updates are easily put in a JSON object, suitable for periodically updating only the relevant segments of your page.

Categories

Resources