File size: 2,386 Bytes
5edee8f ca9e7bd 3a3a57f ca9e7bd f78137c ca9e7bd 3a3a57f c359414 c88db77 c359414 f78137c a65e425 3422eeb ce8df04 c28084b ce8df04 f78137c ce8df04 ca9e7bd ce8df04 ca9e7bd ce8df04 f78137c 218b27d f78137c ca9e7bd f78137c ce8df04 218b27d 3422eeb bafefac 218b27d 4befcc4 |
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 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 |
import gradio as gr
import requests
# from transcribe import transcribe
from sentiment_analysis import sentiment_analyser
from summary import summarizer
from topic import topic_gen
from data import data
def transcribe2():
response = requests.post("https://dwarkesh-whisper-speaker-recognition.hf.space/run/predict", json={
"data": [
{"name":"audio.wav","data":"data:audio/wav;base64,UklGRiQAAABXQVZFZm10IBAAAAABAAEARKwAAIhYAQACABAAZGF0YQAAAAA="},
2,
]}).json()
data = response["data"]
def main(audio_file, number_of_speakers):
# Audio to Text Converter
# text_data = transcribe(audio_file, number_of_speakers)
# print(text_data)
text_data = data
topic = topic_gen(text_data)[0]["generated_text"]
summary = summarizer(text_data)[0]["summary_text"]
sent_analy = sentiment_analyser(text_data)
sent_analysis = sent_analy[0]["label"] + " (" + str(float(sent_analy[0]["score"]) * 100) + "%)"
return topic, summary, sent_analysis
# UI Interface on the Hugging Face Page
with gr.Blocks() as demo:
gr.Markdown("# Shravan - Unlocking Value from Call Data")
with gr.Box():
with gr.Row():
with gr.Column():
audio_file = gr.Audio(label="Upload an Audio file (.wav)", source="upload", type="filepath")
number_of_speakers = gr.Number(label="Number of Speakers", value=2)
with gr.Row():
btn_clear = gr.ClearButton(value="Clear", components=[audio_file, number_of_speakers])
btn_submit = gr.Button(value="Submit")
with gr.Column():
topic = gr.Textbox(label="Title", placeholder="Title for Conversation")
summary = gr.Textbox(label="Short Summary", placeholder="Short Summary for Conversation")
sentiment_analysis = gr.Textbox(label="Sentiment Analysis", placeholder="Sentiment Analysis for Conversation")
btn_submit.click(fn=main, inputs=[audio_file, number_of_speakers], outputs=[topic, summary, sentiment_analysis])
gr.Markdown("## Examples")
gr.Examples(
examples=[
["./examples/sample4.wav", 2],
],
inputs=[audio_file, number_of_speakers],
outputs=[topic, summary, sentiment_analysis],
fn=main,
)
gr.Markdown(
"""
NOTE: The Tool takes around 5mins to run. So be patient! ;)
See [https://github.com/peb-peb/shravan](https://github.com/peb-peb/shravan) for more details.
"""
)
demo.launch()
|