File size: 807 Bytes
b403268
51267b6
b403268
 
 
51267b6
 
b403268
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
51267b6
b403268
 
 
51267b6
 
 
b403268
51267b6
 
 
 
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
import os
import gradio as gr
from utils import get_text_from_audio, get_video_from_yt
from logger import logging
import config


def get_results(video_url :str) -> str:

    logging.info(f">>>Getting predictions for : {video_url}")

    try :
        video_path = get_video_from_yt(video_url=video_url, save_file_dir=config.AUDIO_FILES_DIR)
        
        if not video_path:
            return "Problem while downloading the video. Please check the logs."
        
        text = get_text_from_audio(video_path)

        if not text:
            return "Problem generating the text. Please check the logs."
        
        return text

    except Exception as e:
        logging.exception(e)
        return str(e)



iface = gr.Interface(fn=get_results, inputs="text", outputs="text")
iface.launch()