|
from transformers import pipeline |
|
import gradio as gr |
|
import time |
|
from video_downloader import download_video |
|
from moviepy.editor import AudioFileClip |
|
import datetime |
|
import os |
|
|
|
pipe = pipeline("automatic-speech-recognition", model="Artanis1551/whisper_romanian3") |
|
|
|
|
|
def process_video(date): |
|
|
|
date = datetime.datetime.strptime(date, "%Y-%m-%d").strftime("%Y%m%d") |
|
|
|
|
|
video_path = download_video(date) |
|
|
|
|
|
audio_path = f"audio_{date}.wav" |
|
AudioFileClip(video_path).write_audiofile(audio_path) |
|
|
|
|
|
with open(audio_path, "rb") as audio_file: |
|
audio = audio_file.read() |
|
transcription = pipe(audio)["text"] |
|
|
|
|
|
os.remove(audio_path) |
|
|
|
return video_path, transcription |
|
|
|
|
|
iface = gr.Interface( |
|
fn=process_video, |
|
inputs="date", |
|
outputs=["video", "text"], |
|
title="Romanian Transcription Test", |
|
) |
|
|
|
iface.launch() |
|
|