File size: 1,021 Bytes
fac06d0 de84263 fac06d0 de84263 d14f075 fac06d0 534a7d7 de84263 e5f8741 306a78c 534a7d7 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 |
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):
# Download the video
video_path = download_video(date)
# Extract audio from the video
audio_path = f"audio_{date}.wav"
AudioFileClip(video_path).write_audiofile(audio_path)
# Transcribe the audio
with open(audio_path, "rb") as audio_file:
audio = audio_file.read()
transcription = pipe(audio)["text"]
# Remove the audio file
os.remove(audio_path)
return video_path, transcription
iface = gr.Interface(
fn=process_video,
inputs=gr.inputs.Textbox(label="Date with format YYYYMMDD"),
outputs=[
gr.outputs.Video(),
gr.outputs.Textbox(lines=1000, max_lines=1000, interactive=True),
],
title="Romanian Transcription Test",
)
iface.launch()
|