gaur3009 commited on
Commit
7971622
·
verified ·
1 Parent(s): 6f1bd97

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +28 -0
app.py ADDED
@@ -0,0 +1,28 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ from transformers import pipeline
3
+ from fpdf import FPDF
4
+ import librosa
5
+
6
+ def transcribe_and_generate_pdf(audio_file):
7
+ transcriber = pipeline("automatic-speech-recognition", model="openai/whisper-large")
8
+ audio, _ = librosa.load(audio_file, sr=16000)
9
+ transcription = transcriber(audio)["text"]
10
+
11
+ output_pdf = "transcription.pdf"
12
+ pdf = FPDF()
13
+ pdf.add_page()
14
+ pdf.set_font("Arial", size=12)
15
+ pdf.multi_cell(0, 10, transcription)
16
+ pdf.output(output_pdf)
17
+
18
+ return transcription, output_pdf
19
+
20
+ interface = gr.Interface(
21
+ fn=transcribe_and_generate_pdf,
22
+ inputs=gr.Audio(source="upload", type="filepath"),
23
+ outputs=[gr.Textbox(label="Transcription"), gr.File(label="Download PDF")],
24
+ title="Audio-to-Text and PDF Generator",
25
+ )
26
+
27
+ if __name__ == "__main__":
28
+ interface.launch()