# Module Imports from pytube import YouTube import whisper import gradio as gr model = whisper.load_model("base.en") # Functions def transcribe(file): options = dict(task="transcribe", best_of=5) text = model.transcribe(file, **options)["text"] return text.strip() def translate(file): options = dict(task="translate", best_of=5) text = model.transcribe(file, **options)["text"] return text.strip() def get_filename(file_obj): return file_obj.orig_name def inference(link): yt = YouTube(link) path = yt.streams.filter(only_audio=True)[0].download(filename="audio.mp4") options = whisper.DecodingOptions(without_timestamps=True) results = model.transcribe(path) return results['text'] def populate_metadata(link): yt = YouTube(link) return yt.thumbnail_url, yt.title def transcribe_file(file): options = dict(task="transcribe", best_of=5) file = get_filename(file) text = model.transcribe(file, **options)["text"] return text.strip() # Gradio Blocks demo = gr.Blocks() with demo: gr.Markdown("""

Speech To Text Grammar Checker

""") with gr.Tabs(): with gr.TabItem("Voice Record"): with gr.Row(): audio = gr.Audio(show_label=False,source="microphone",type="filepath") text_output1 = gr.Textbox(label="Transcription", placeholder="Text Output") transcribe_button1 = gr.Button("Transcribe") CG_button1 = gr.Button("Check Grammar (Work In Progress)") with gr.TabItem("Upload File"): with gr.Row(): file_upload = gr.File() text_output2 = gr.Textbox(label="Transcription", placeholder="Text Output") transcribe_button2 = gr.Button("Transcribe") CG_button3 = gr.Button("Check Grammar (Work In Progress)") with gr.TabItem("Youtube Link"): with gr.Box(): link = gr.Textbox(label="YouTube Link") with gr.Row().style(mobile_collapse=False, equal_height=True): title = gr.Label(label="Video Title", placeholder="Title") img = gr.Image(label="Thumbnail") text_link_output = gr.Textbox(label="Transcription", placeholder="Text Output",lines=5) with gr.Row().style(mobile_collapse=False, equal_height=True): transcribe_button3 = gr.Button("Transcribe") CG_button3 = gr.Button("Check Grammar (Work In Progress)") with gr.TabItem("About"): with gr.Row(): gr.Markdown("""

Thesis System presented by

Jomari A. Buenaobra
Christian G. Eslit
Daniel L. Espinola
Jhon Vincent A. Gupo
Ryan M. Ibay

In partial fulfillment of the requirements for the degree
Bachelor of Science in Computer Science Specialized in Intelligent Systems
Laguna State Polytechnic University - Los Baños Campus .

We would also like to thank our fellow adviser and subject specialist for their guidance in making this idea a reality.
Crisanto F. Gulay - Adviser
Jonardo R. Asor - Subject Specialist

""") link.change(populate_metadata, inputs=[link], outputs=[img, title]) transcribe_button1.click(transcribe, inputs=audio, outputs=text_output1) transcribe_button2.click(transcribe_file, inputs=file_upload, outputs=text_output2) transcribe_button3.click(inference, inputs=link, outputs=text_link_output) demo.launch()