
Recherche avancée
Autres articles (11)
-
Emballe médias : à quoi cela sert ?
4 février 2011, parCe plugin vise à gérer des sites de mise en ligne de documents de tous types.
Il crée des "médias", à savoir : un "média" est un article au sens SPIP créé automatiquement lors du téléversement d’un document qu’il soit audio, vidéo, image ou textuel ; un seul document ne peut être lié à un article dit "média" ; -
Déploiements possibles
31 janvier 2010, parDeux types de déploiements sont envisageable dépendant de deux aspects : La méthode d’installation envisagée (en standalone ou en ferme) ; Le nombre d’encodages journaliers et la fréquentation envisagés ;
L’encodage de vidéos est un processus lourd consommant énormément de ressources système (CPU et RAM), il est nécessaire de prendre tout cela en considération. Ce système n’est donc possible que sur un ou plusieurs serveurs dédiés.
Version mono serveur
La version mono serveur consiste à n’utiliser qu’une (...) -
Gestion des droits de création et d’édition des objets
8 février 2011, parPar défaut, beaucoup de fonctionnalités sont limitées aux administrateurs mais restent configurables indépendamment pour modifier leur statut minimal d’utilisation notamment : la rédaction de contenus sur le site modifiables dans la gestion des templates de formulaires ; l’ajout de notes aux articles ; l’ajout de légendes et d’annotations sur les images ;
Sur d’autres sites (3408)
-
Detect volume via mic, start recording, end on silence, transcribe and sent to endpoint
15 juin 2023, par alphadmonI have been attempting to get this to work in many ways but I can't seem to get it right. Most of the time I get a part of it to work and then when I try to make other parts work, I generally break other things.


I am intercepting the volume coming from the mic and if it is louder than 50, I start a recording. I then keep recording until there is a silence, if the silence is equal to 5 seconds I then stop the recording.


I then send the recording to be transcribed by
whisper
using OpenAI API.

Once that is returned, I then want to send it to the open ai chat end point and get the response.


After that, I would like to start listening again.


Here is what I have that is sort of working so far, but the recording is an empty file always :


// DETECT SPEECH
const recorder = require('node-record-lpcm16');

// TRANSCRIBE
const fs = require("fs");
const ffmpeg = require("fluent-ffmpeg");
const mic = require("mic");
const { Readable } = require("stream");
const ffmpegPath = require("@ffmpeg-installer/ffmpeg").path;
require('dotenv').config();

// CHAT
const { Configuration, OpenAIApi } = require("openai");

// OPEN AI
const configuration = new Configuration({
 organization: process.env.OPENAI_ORG,
 apiKey: process.env.OPENAI_API_KEY,
});
const openai = new OpenAIApi(configuration);

// SETUP
ffmpeg.setFfmpegPath(ffmpegPath);

// VARS
let isRecording = false;
const audioFilename = 'recorded_audio.wav';
const micInstance = mic({
 rate: '16000',
 channels: '1',
 fileType: 'wav',
});

// DETECT SPEECH
const file = fs.createWriteStream('determine_speech.wav', { encoding: 'binary' });
const recording = recorder.record();
recording.stream().pipe(file);


recording.stream().on('data', async (data) => {
 let volume = parseInt(calculateVolume(data));
 if (volume > 50 && !isRecording) {
 console.log('You are talking.');
 await recordAudio(audioFilename);
 } else {
 setTimeout(async () => {
 console.log('You are quiet.');
 micInstance.stop();
 console.log('Finished recording');
 const transcription = await transcribeAudio(audioFilename);
 console.log('Transcription:', transcription);
 setTimeout(async () => {
 await askAI(transcription);
 }, 5000);
 }, 5000);
 }
});

function calculateVolume(data) {
 let sum = 0;

 for (let i = 0; i < data.length; i += 2) {
 const sample = data.readInt16LE(i);
 sum += sample * sample;
 }

 const rms = Math.sqrt(sum / (data.length / 2));

 return rms;
}

// TRANSCRIBE
function recordAudio(filename) {
 const micInputStream = micInstance.getAudioStream();
 const output = fs.createWriteStream(filename);
 const writable = new Readable().wrap(micInputStream);

 console.log('Listening...');

 writable.pipe(output);

 micInstance.start();

 micInputStream.on('error', (err) => {
 console.error(err);
 });
}

// Transcribe audio
async function transcribeAudio(filename) {
 const transcript = await openai.createTranscription(
 fs.createReadStream(filename),
 "whisper-1",
 );
 return transcript.data.text;
}

// CHAT
async function askAI(text) {
 let completion = await openai.createChatCompletion({
 model: "gpt-4",
 temperature: 0.2,
 stream: false,
 messages: [
 { role: "user", content: text },
 { role: "system", content: "Act like you are a rude person." }
 ],
 });

 completion = JSON.stringify(completion.data, null, 2);
 console.log(completion);
}



-
How to save variables at start of script for use later if script needs to be re-run due to errors or bad user input
28 novembre 2023, par slyfox1186I have a script that uses GitHub's API to get the latest version number of the repositories that I am trying to download and then compile.


Due to the fact that without using a specialized token from GitHub you are only allowed 50 API calls a day vs the 5000 a day with the API user token.


I want to be able to parse all of the repositories and grab the version numbers that my script will then import into the code up front so in case someone who accidentally cancels the build in the middle of it (for who knows what reasons) wont have to eat up their 50 day API call allowance.


Essentially, store each repo's version number, if the user then needs to rerun the script and version numbers that have been saved so far will be skipped (thus eliminating an API call) and any numbers that are still needing to be sourced will be called and then stored for used in the script.


I am kinda of lost for a method on how to go about this.


Maybe some sort of external file can be generated ?


So what my script does is it builds FFmpeg from source code and all of the external libraries that you can link to it are also built from their latest source code.


The code calls the function
git_ver_fn
and passes arguments to it which are parsed inside the function and directed to another functionsgit_1_fn or git_2_fn
which passed those parsed arguments that have been passed on to the CURL command which changes the URL based on the arguments passed. It uses thejq
command to capture the GitHubversion number
anddownload link
for thetar.gz
file.

It is the version number I am and trying to figure out the best way to store in case the script fails and has to be rerun, which will eat up all of the 50 APT limit that GitHub imposes without a token. I can't post my token in the script because GitHub deactivates it and thus the users will be SOL if they need to run the script more than once.


curl_timeout='5'

git_1_fn()
{
 # SCRAPE GITHUB WEBSITE FOR LATEST REPO VERSION
 github_repo="$1"
 github_url="$2"

 if curl_cmd="$(curl -m "$curl_timeout" -sSL "https://api.github.com/repos/$github_repo/$github_url")"; then
 g_ver="$(echo "$curl_cmd" | jq -r '.[0].name')"
 g_ver="${g_ver#v}"
 g_ssl="$(echo "$curl_cmd" | jq -r '.[0].name')"
 g_ssl="${g_ssl#OpenSSL }"
 g_pkg="$(echo "$curl_cmd" | jq -r '.[0].name')"
 g_pkg="${g_pkg#pkg-config-}"
 g_url="$(echo "$curl_cmd" | jq -r '.[0].tarball_url')"
 fi
}

git_2_fn()
{
 videolan_repo="$1"
 videolan_url="$2"
 if curl_cmd="$(curl -m "$curl_timeout" -sSL "https://code.videolan.org/api/v4/projects/$videolan_repo/repository/$videolan_url")"; then
 g_ver="$(echo "$curl_cmd" | jq -r '.[0].commit.id')"
 g_sver="$(echo "$curl_cmd" | jq -r '.[0].commit.short_id')"
 g_ver1="$(echo "$curl_cmd" | jq -r '.[0].name')"
 g_ver1="${g_ver1#v}"
 fi
}

git_ver_fn()
{
 local v_flag v_tag url_tag

 v_url="$1"
 v_tag="$2"

 if [ -n "$3" ]; then v_flag="$3"; fi

 if [ "$v_flag" = 'B' ] && [ "$v_tag" = '2' ]; then
 url_tag='git_2_fn' gv_url='branches'
 fi

 if [ "$v_flag" = 'X' ] && [ "$v_tag" = '5' ]; then
 url_tag='git_5_fn'
 fi

 if [ "$v_flag" = 'T' ] && [ "$v_tag" = '1' ]; then
 url_tag='git_1_fn' gv_url='tags'
 elif [ "$v_flag" = 'T' ] && [ "$v_tag" = '2' ]; then
 url_tag='git_2_fn' gv_url='tags'
 fi

 if [ "$v_flag" = 'R' ] && [ "$v_tag" = '1' ]; then
 url_tag='git_1_fn'; gv_url='releases'
 elif [ "$v_flag" = 'R' ] && [ "$v_tag" = '2' ]; then
 url_tag='git_2_fn'; gv_url='releases'
 fi

 case "$v_tag" in
 2) url_tag='git_2_fn';;
 esac

 "$url_tag" "$v_url" "$gv_url" 2>/dev/null
}

# begin source code building
git_ver_fn 'freedesktop/pkg-config' '1' 'T'
if build 'pkg-config' "$g_pkg"; then
 download "https://pkgconfig.freedesktop.org/releases/$g_ver.tar.gz" "$g_ver.tar.gz"
 execute ./configure --silent --prefix="$workspace" --with-pc-path="$workspace"/lib/pkgconfig/ --with-internal-glib
 execute make -j "$cpu_threads"
 execute make install
 build_done 'pkg-config' "$g_pkg"
fi

git_ver_fn 'yasm/yasm' '1' 'T'
if build 'yasm' "$g_ver"; then
 download "https://github.com/yasm/yasm/releases/download/v$g_ver/yasm-$g_ver.tar.gz" "yasm-$g_ver.tar.gz"
 execute ./configure --prefix="$workspace"
 execute make -j "$cpu_threads"
 execute make install
 build_done 'yasm' "$g_ver"
fi



-
Xvfb and pulse audio not sync
14 décembre 2023, par Matrix 404I'm excited to introduce my new JavaScript server-side library called XFP Streamer, designed to handle recording and streaming Puppeteer window content. However, I'm currently facing an issue with audio synchronization, and I could really use some help from someone experienced with ffmpeg and recording in general.


The library's repository is available on GitHub, and I warmly welcome any contributions or assistance. Feel free to check it out at https://github.com/mboussaid/xfp-streamer.


Below is a simple example demonstrating how to record the Google website into a file.flv video file using XFP :


const XFP = require('./index');
XFP.onReady().then(async ()=>{
 // create new xfp instance
 const xfp = new XFP({
 debug:1
 });
 await xfp.onStart();
 // record everyting inside the file file.flv
 xfp.pipeToFile('file.flv',{
 debug:1
 })
 // xfp.pipeToRtmp('file.flv','RTMP LINK HERE')
 await xfp.onUseUrl('https://www.google.com') // navigate to google
 setTimeout(async ()=>{
 await xfp.onStop();
 },5000) // stop everyting after 5 seconds
},(missing)=>{
 // missing tools
 console.log('Missing tools',missing)
})



Please note that to ensure proper functionality, you will need to have the following tools installed :


pulseaudio
xvfb
ffmpeg
pactl
pacmd
Currently, I'm facing an issue with audio and video synchronization not working as expected. If you have experience with ffmpeg and recording, I would greatly appreciate your help in resolving this issue.


Thank you all for your support, and I look forward to your contributions !


Best regards,