File size: 1,009 Bytes
dad2a9b
 
 
 
 
 
 
ee74fc7
 
 
 
dad2a9b
 
 
 
 
 
 
 
 
 
ee74fc7
dad2a9b
 
 
 
1545980
 
dad2a9b
 
ee74fc7
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
import gradio as gr
import whisper
import os

model = whisper.load_model("base")

def transcribe_audio(audio_file):
    # Check file size (e.g., 25MB limit)
    if os.path.getsize(audio_file.name) > 25 * 1024 * 1024:
        return "Error: File size exceeds 25MB limit.", None

    result = model.transcribe(audio_file.name)
    output_filename = os.path.splitext(os.path.basename(audio_file.name))[0] + ".txt"
    
    with open(output_filename, "w") as text_file:
        text_file.write(result["text"])
    
    return result["text"], output_filename

iface = gr.Interface(
    fn=transcribe_audio,
    inputs=gr.File(label="Upload Audio File (Max 25MB)"),
    outputs=[
        gr.Textbox(label="Transcription"),
        gr.File(label="Download Transcript")
    ],
    title="Free Transcript Maker",
    description="Upload an audio file (WAV, MP3, etc.) up to 25MB to get its transcription. The transcript will be displayed and available for download. Please use responsibly."
)

iface.launch(share=True)