Spaces:
Sleeping
Sleeping
File size: 1,671 Bytes
967b24c |
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 |
import json
from textwrap import indent
import gradio as gr
import os
from humanfriendly.terminal import output
from app.modules.processing import transcript_audio, save_transcript
from app.modules.summarizer import process_transcript_file, generate_meeting_minutes
from app.config import *
from app.modules.exporter import export_meeting_minutes_to_docx
def process_audio_to_doc(audio_path: str, open_ai_key: str) -> str:
"""
Nhận 1 file audio -> Meeting minutes
:param audio_path:
:return:
"""
os.environ['OPENAI_API_KEY'] = open_ai_key
if not audio_path:
raise ValueError("No audio path provided")
transcript = transcript_audio(audio_path, device=WHISPER_DEVICE, vad_filter=WHISPER_USE_VAD,
beam_size=WHISPER_BEAM_SIZE, model_size=WHISPER_MODEL_SIZE)
print(transcript)
temp_path = 'temp_transcript.txt'
save_transcript(transcript, temp_path)
#Xử lý transcript
meeting_minutes = process_transcript_file(temp_path)
print(meeting_minutes)
# Refine
output_docx = "generated_meeting_minutes.docx"
export_meeting_minutes_to_docx(meeting_minutes, output_docx)
return output_docx
#Xây dựng 1 giao diện Gradio
iface = gr.Interface(
fn=process_audio_to_doc,
inputs= [gr.Audio(type="filepath", label="Tải lên file audio"), gr.Text(label="API_open_ai key")],
outputs = gr.File(label="Tải xuống docx cuộc họp"),
title="Meeting minutes",
description="Taỉ audio và trả về biên bản cuộc họp",
)
if __name__ == "__main__":
iface.launch() |