Update main.py
Browse files189 unmodified lines1901911921931941951961971981992002012022032042052062072082092102112122132142152162171 unmodified line219220221222223224225189 unmodified linesawait restart_and_check_space(repo_id) # Перезапуск транскрибационного сервиса, если он не запущенelse:logging.info('Transcription space is running, sending file')async with httpx.AsyncClient() as client:files = {'file': (file.filename, file.file, file.content_type)}data = {'final_url': "https://sabbah13-video-call-recording-and-transcription-9729a08.hf.space/transcript/video-file/",'max_speakers': 10,'min_speakers': 1,"hash_path": hash_path}headers = {"Authorization": f'Bearer {os.getenv("HF_TOKEN")}'}# Отправляем видео на сервер транскрибацииresponse = await client.post(transcribation_url_my_video, files=files, data=data, headers=headers)if response.status_code == 200:logging.info("Video successfully sent for transcription")else:logging.error(f"Error sending video for transcription: {response.text}")except Exception as e:logging.error(f"Error in background task: {e}")1 unmodified line@app.post("/upload/")async def upload_video(file: UploadFile, hash_path: str = Form(...), background_tasks: BackgroundTasks = BackgroundTasks()):try:logging.info(f"Received video: {file.filename}, hash_path: {hash_path}")189 unmodified lines1901911921931941951961971981992002012022032042052062072082092102112122132142152162171 unmodified line219220221222223224225189 unmodified linesawait restart_and_check_space(repo_id) # Перезапуск транскрибационного сервиса, если он не запущенelse:logging.info('Transcription space is running, sending file')async with httpx.AsyncClient() as client:files = {'file': (file.filename, file.file, file.content_type)}data = {'final_url': "https://sabbah13-video-call-recording-and-transcription-9729a08.hf.space/transcript/video-file/",'max_speakers': 10,'min_speakers': 1,"hash_path": hash_path}headers = {"Authorization": f'Bearer {os.environ.get("HF_TOKEN")}'}# Отправляем видео на сервер транскрибацииresponse = await client.post(transcribation_url_my_video, files=files, data=data, headers=headers)if response.status_code == 200:logging.info("Video successfully sent for transcription")else:logging.error(f"Error sending video for transcription: {response.text}")except Exception as e:logging.error(f"Error in background task: {e}")1 unmodified line@app.post("/upload/")async def upload_video(file: UploadFile, hash_path: str = Form(...), background_tasks: BackgroundTasks = BackgroundTasks(), token: str = Depends(verify_token)):try:logging.info(f"Received video: {file.filename}, hash_path: {hash_path}")
main.py+20-20