RaSan147 / VoiceAI-Asuna

If you're familiar with the anime Sword art online, you know it! This project is a virtual Assistant for multiple OS
https://ai-asuna.onrender.com
Apache License 2.0
27 stars 5 forks source link

hope this helps with bot sending video #12

Open s-b-repo opened 1 year ago

s-b-repo commented 1 year ago

You can use various video processing libraries like FFmpeg or GStreamer to manipulate the video files and streaming protocols like HLS or MPEG-DASH to serve them over the internet. You can also use third-party APIs like Cloudinary or Amazon S3 to store and retrieve the video files. However, it's important to note that enabling a chat AI to send videos on a self-hosted website could potentially create legal or ethical issues, especially if the videos are not moderated or monitored for inappropriate content. It's important to carefully consider the implications of such a feature before implementing it.

Sure, here's an example of how you could allow a chat AI to send videos on a self-hosted website using HTML and JavaScript:

First, create an HTML form with an input field for the user to upload a video file:

python

Next, create a JavaScript function to handle the form submission and send the video file to the server using AJAX:

javascript

function uploadVideo() { var file = document.querySelector('input[type="file"]').files[0]; var xhr = new XMLHttpRequest(); xhr.open('POST', 'upload.php', true); xhr.upload.onprogress = function(e) { if (e.lengthComputable) { var percentComplete = (e.loaded / e.total) * 100; console.log(percentComplete + '% uploaded'); } }; xhr.onload = function() { if (this.status === 200) { console.log('Video uploaded!'); } else { console.error('Error uploading video'); } }; var formData = new FormData(); formData.append('video', file); xhr.send(formData); }

Finally, create a PHP script to handle the video upload and store the video file on the server:

php

<?php if ($_FILES['video']['error'] === UPLOAD_ERR_OK) { $tempName = $_FILES['video']['tmp_name']; $fileName = $_FILES['video']['name']; $uploadDir = '/path/to/uploads/directory/'; $targetPath = $uploadDir . $fileName; move_uploaded_file($tempName, $targetPath); echo 'Video uploaded successfully'; } else { echo 'Error uploading video'; } ?>

Note that this code is just an example and would need to be customized to fit your specific website and use case.

Here's an alternative implementation of the same functionality using Node.js and the Express framework:

First, install the necessary dependencies by running the following command in your project directory:

npm install express multer

Next, create a server.js file with the following code:

javascript

const express = require('express'); const multer = require('multer'); const app = express(); const upload = multer({ dest: 'uploads/' });

app.post('/upload', upload.single('video'), (req, res) => { if (!req.file) { return res.status(400).send('No video uploaded'); } res.send('Video uploaded successfully'); });

app.listen(3000, () => { console.log('Server listening on port 3000'); });

Finally, create an HTML form with an input field for the user to upload a video file, and use JavaScript to submit the form to the server:

php

Again, note that this code is just an example and would need to be customized to fit your specific website and

RaSan147 commented 1 year ago

Question: why would a user send video to a chat bot? This ain't telegeam with unlimited storage.

s-b-repo commented 1 year ago

Question: why would a user send video to a chat bot? This ain't telegeam with unlimited storage.

this for ai on your ro do list

s-b-repo commented 1 year ago

Allow bot send video

RaSan147 commented 1 year ago

Not planning to add such thing in distant future. This is a chatbot, at max I'll add sending photo (only from ai, not from user) to keep power usage and complexity low

s-b-repo commented 1 year ago

Not planning to add such thing in distant future. This is a chatbot, at max I'll add sending photo (only from ai, not from user) to keep power usage and complexity low

you could let it send some videos like youtube videos or twitch clips

RaSan147 commented 1 year ago

Yes will do that, but Instead of downloading, will allow embedded code with video playback.

RaSan147 commented 1 year ago

Planning to add YouTube video player API https://developers.google.com/youtube/iframe_api_reference

Also have "plyr" in mind. Demo command: "play something" Player position on side bar, so that one can chat with music on ( by hiding sidebar) Or on top of page (not voting for this one)

Issue on using anything YouTube : on Android playback will stop when user leaves screen (uncontrollable)

s-b-repo commented 1 year ago

try newpipes method

RaSan147 commented 1 year ago

try newpipes method

Interesting app, sadly its an app. Can you find any web alternative with api

s-b-repo commented 1 year ago

invidius

RaSan147 commented 1 year ago

CORS issue on Hotlinking to player

RaSan147 commented 1 year ago

Noted, will add in future updates