Your Web News in One Place

Help Webnuz

Referal links:

Sign up for GreenGeeks web hosting
January 7, 2021 03:04 pm GMT

Why I let strangers control my lights and why you should too

The title photo features the website I built to let strangers annoy me. The website includes text to speech, YouTube audio playing, and even control of my lights. But why did I make it?

Why did I make it?

Well like many projects, this one was started over pure boredom from being on a break from school.

Id had the idea for a while to try and replicate the tts setup twitch streamers use sometimes, but I wanted something unique, so I also added light controls.

Ok, thats great and all, but how does it work?

The project actually has two parts, the tts part and the light control part.

first, how do the lights work?

The light controls are incredibly simple, I use LIFX http api to toggle the lights.

Below is a simple fetch api request to toggle some lights using default parameters, just replace YOUR-APP-TOKEN with the token lifx gives you.

So how does the text to speech work?

This is where the project gets considerably more complex. Fist up, discord webhooks.

When I was building the project I needed a way to store messages in a log, so I could read them if Id been away from my loudspeaker or if it had turned off for some reason. The best one I can come up with is a discord webhook, its great because it acts as an intermediary between the site and my servers, as well as being completely free.

So how do you connect with it?

Below is the actual code I use for handling discord messages, including my webhook url

I opted to use xmlhttprequest here, since Im more familiar with it, but you could use fetch as well.

The basic concept is this, it takes in text from a textbox element when the function sendMessage is called, then it sends that test as a request to whatever webhook url you specify.

Next up on the train, discord bots!

For handling the text to speech I use a python discord bot and the pyttsx3 library

I wont show the code for this since its ugly and I dont want people replicating it, but basically it watches for new messages in a discord channel, and then plays their contents through the pyttsx3 library using default parameters. I also run all requests through the googletrans python library to ensure that I hear all messages in my native tongue.

So why should you make it yourself?

Well Ive been asked a fair bit by the people on my subreddit r/theannoyingmachine why I would build this, all I can say is that its more fun than it seems like!

If youre interest in learning about apis, webdevelopment, and python all in one project, you should do this one!

Thanks for reading my post!

The website featured in the post is https://sixty502.me/annoy


Original Link: https://dev.to/nobody5050/why-i-let-strangers-control-my-lights-and-why-you-should-too-3kg0

Share this article:    Share on Facebook
View Full Article

Dev To

An online community for sharing and discovering great ideas, having debates, and making friends

More About this Source Visit Dev To