Spaces:
Sleeping
Sleeping
# >>>>>> Adapted/frankensteined from these scripts: <<<<<<< | |
# for Summary Interface: | |
# >>>>https://huggingface.co/spaces/khxu/pegasus-text-summarizers/blob/main/app.py | |
# | |
import gradio as gr | |
from transformers import pipeline | |
from gradio.mix import Parallel, Series | |
# >>>>>>>>>>>>>>>>>>>> Danger Below <<<<<<<<<<<<<<<<<<<<<< | |
# Load Interfaces: | |
s2t = gr.Interface.load('huggingface/facebook/s2t-medium-librispeech-asr') | |
grammar = gr.Interface.load('huggingface/prithivida/grammar_error_correcter_v1') | |
sum_it = gr.Interface.load('huggingface/SamuelMiller/sum_it') | |
# Audio Functions: | |
def out(audio): | |
if audio1==None: | |
return "no audio" | |
else: | |
a = s2t(audio) | |
g = grammar(a) | |
#s = sum_it(g) # Summarize Audio with sum_it | |
return grammar(a) # grammar(s), # Grammar Filter | |
# Construct Interfaces: | |
iface = gr.Interface( | |
fn=out, | |
title="Speech Audio to text (with corrected grammar)", | |
description="Let's Hear It!! This app transforms your speech (input) to text with corrected grammar after (output)!", | |
inputs=[gr.inputs.Audio(source="microphone", type="filepath", label=None, optional=True)], | |
outputs=['text','text'] | |
) | |
# From Original Code: | |
# gr.inputs.Audio(source="upload", type="filepath", label=None, optional=True), | |
# examples=[["Grammar-Correct-Sample.mp3"], ["Grammar-Wrong-Sample.mp3"],], | |
# Launch Interface | |
iface.launch(enable_queue=True,show_error=True) |