
Recherche avancée
Autres articles (24)
-
Qu’est ce qu’un éditorial
21 juin 2013, parEcrivez votre de point de vue dans un article. Celui-ci sera rangé dans une rubrique prévue à cet effet.
Un éditorial est un article de type texte uniquement. Il a pour objectif de ranger les points de vue dans une rubrique dédiée. Un seul éditorial est placé à la une en page d’accueil. Pour consulter les précédents, consultez la rubrique dédiée.
Vous pouvez personnaliser le formulaire de création d’un éditorial.
Formulaire de création d’un éditorial Dans le cas d’un document de type éditorial, les (...) -
Multilang : améliorer l’interface pour les blocs multilingues
18 février 2011, parMultilang est un plugin supplémentaire qui n’est pas activé par défaut lors de l’initialisation de MediaSPIP.
Après son activation, une préconfiguration est mise en place automatiquement par MediaSPIP init permettant à la nouvelle fonctionnalité d’être automatiquement opérationnelle. Il n’est donc pas obligatoire de passer par une étape de configuration pour cela. -
Ajouter des informations spécifiques aux utilisateurs et autres modifications de comportement liées aux auteurs
12 avril 2011, parLa manière la plus simple d’ajouter des informations aux auteurs est d’installer le plugin Inscription3. Il permet également de modifier certains comportements liés aux utilisateurs (référez-vous à sa documentation pour plus d’informations).
Il est également possible d’ajouter des champs aux auteurs en installant les plugins champs extras 2 et Interface pour champs extras.
Sur d’autres sites (5483)
-
Transcription via OpenAi's whisper : AssertionError : incorrect audio shape
1er avril 2024, par muratowskiI'm trying to use OpenAI's open source Whisper library to transcribe audio files.


Here is my script's source code :


import whisper

model = whisper.load_model("large-v2")

# load the entire audio file
audio = whisper.load_audio("/content/file.mp3")
#When i write that code snippet here ==> audio = whisper.pad_or_trim(audio) the first 30 secs are converted and without any problem they are converted.

# make log-Mel spectrogram and move to the same device as the model
mel = whisper.log_mel_spectrogram(audio).to(model.device)

# detect the spoken language
_, probs = model.detect_language(mel)
print(f"Detected language: {max(probs, key=probs.get)}")

# decode the audio
options = whisper.DecodingOptions(fp16=False)
result = whisper.decode(model, mel, options)

# print the recognized text if available
try:
 if hasattr(result, "text"):
 print(result.text)
except Exception as e:
 print(f"Error while printing transcription: {e}")

# write the recognized text to a file
try:
 with open("output_of_file.txt", "w") as f:
 f.write(result.text)
 print("Transcription saved to file.")
except Exception as e:
 print(f"Error while saving transcription: {e}")



In here :


# load the entire audio file
audio = whisper.load_audio("/content/file.mp3")



when I write below : " audio = whisper.pad_or_trim(audio) ", the first 30 secs of the sound file is transcribed without any problem and language detection works as well,


but when I delete it and want the whole file to be transcribed, I get the following error :




AssertionError : incorrect audio shape




What should I do ? Should I change the structure of the sound file ? If yes, which library should I use and what type of script should I write ?


-
How to call ffmpeg main method from Xcode 7.2 ?
15 mars 2016, par user5761723I’m new to iOS app Development. I compiled the ffmpeg-3.0 libraries for iOS. and integrate them into Xcode. but when i try to call main method of ffmpeg.c, it won’t work.
Can someone tell me the procedure, how to move ahead from here ?. i actually want to convert audio formats.
-
I can't get my backend working with frontend in production but in local environment [duplicate]
3 août 2024, par YouareGrouseChrisThis is the frontend code :


import React, { useState } from 'react';
import axios from 'axios';
import fileDownload from 'js-file-download';

function HomePage() {
 const [url, setUrl] = useState('');
 const [filename, setFilename] = useState('');

 const handleSubmit = async (e) => {
 e.preventDefault();
 try {
 const response = await axios.post('https://api-lnp5.onrender.com/api/download', { url, filename }, { responseType: 'blob' });
 fileDownload(response.data, filename);
 console.log(response.data); // handle the response as needed
 } catch (error) {
 console.error(error);
 }
 };

 return (
 <div classname="flex flex-col items-center justify-center h-screen overflow-hidden">
 <h1 classname="text-3xl font-bold mb-6">Download Reddit video!!!</h1>
 <form classname="flex flex-col items-center">
 <label classname="mb-4">
 <div classname="text-lg mb-4 inline-block">Video URL:</div>
 <div>
 <input type="text" value="{url}" />> setUrl(e.target.value)} required 
 className="border px-3 py-2 rounded focus:outline-none focus:ring focus:border-blue-300 w-96"/>
 </div>
 </label>
 <label classname="mb-4">
 <div classname="text-lg mb-4 inline-block">Filename:</div>
 <div>
 <input type="text" value="{filename}" />> setFilename(e.target.value)} required 
 className="border px-3 py-2 rounded focus:outline-none focus:ring focus:border-blue-300 w-96"/>
 </div>
 </label>
 <button type="submit" classname="bg-blue-500 text-white px-4 py-2 rounded hover:bg-blue-600">Download</button>
 </form>
 </div>
 );
}

export default HomePage;



This is the backend code using python fastapi :


from fastapi import FastAPI, HTTPException

from fastapi.responses import FileResponse
from fastapi.middleware.cors import CORSMiddleware
from pydantic import BaseModel
import requests
import json
import subprocess
import os

app = FastAPI()

origins = [
 "https://videodownload-frontend.onrender.com", # replace with the origin of your frontend
]

app.add_middleware(
 CORSMiddleware,
 allow_origins=["*"],
 allow_credentials=True,
 allow_methods=["*"],
 allow_headers=["*"],
)

class Video(BaseModel):
 url: str
 filename: str


def get_unique_filename(filename):
 counter = 1
 base_filename, extension = os.path.splitext(filename)
 unique_filename = filename

 while os.path.isfile(unique_filename):
 unique_filename = f"{base_filename}({counter}){extension}"
 counter += 1

 return unique_filename

@app.post("/api/download")
async def download_video(video: Video):
 url = video.url
 filename = get_unique_filename(video.filename)

 url += '.json'
 response = requests.get(url, headers={'User-agent': 'Mozilla/5.0'})

 if response.status_code != 200:
 raise HTTPException(status_code=404, detail="Video not found")

 json_response = json.loads(response.text)
 video_url = json_response[0]["data"]["children"][0]["data"]["secure_media"]["reddit_video"]["fallback_url"]
 audio_url = video_url.rsplit('/', 1)[0] + '/DASH_audio.mp4'

 video_response = requests.get(video_url, stream=True)
 audio_response = requests.get(audio_url, stream=True)

 with open('video_temp.mp4', 'wb') as f:
 for chunk in video_response.iter_content(chunk_size=1024 * 1024):
 if chunk:
 f.write(chunk)
 if audio_response.status_code == 200:
 with open('audio_temp.mp4', 'wb') as f:
 for chunk in audio_response.iter_content(chunk_size=1024 * 1024):
 if chunk:
 f.write(chunk)
 subprocess.run(['ffmpeg', '-i', 'video_temp.mp4', '-i', 'audio_temp.mp4', '-c', 'copy', filename])
 else:
 os.rename('video_temp.mp4', filename)

 return FileResponse(filename, media_type='application/octet-stream', filename=filename)



I deployed the fastapi by docker to Render. When I start the frontend development server, I could communicate with the backend without problems. But when I deployed both frontend and backend to Render, it shows always the CORS policy




Why is it ? if I could communicate with backend when starting local development server, it should be not related to backend.


This is URL to my frontend : https://videodownload-frontend.onrender.com/


Thank you !


I tried reconnect and restart the web service, also I tried to add CORS in fastapi. The api works fine with local server opened up. What should I do to debug ? thank you