File size: 1,597 Bytes
02d76b7
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
import gradio as gr
from pyscript import Transcriptor

demo = gr.Blocks()
transcriptor = Transcriptor(model_size="large-v3-turbo")

microphone_transcribe = gr.Interface(
    fn=transcriptor.transcribe_audio,
    inputs=[
        gr.Audio(sources="microphone", type="filepath", label="Microphone"),
        gr.Radio([True, False], value=True, label="Enable audio enhancement"),
    ],
    outputs=[
        gr.Textbox(label="Transcription"),
        # gr.File(label="Download Transcription"),
        # gr.Textbox(label="Console Output", lines=10)
    ],
    title="Audio-Transcription leveraging Whisper Model",
    description=(
        "Transcribe microphone recording or audio inputs and return the transcription with speaker diarization."
    ),
    allow_flagging="never",
)

file_transcribe = gr.Interface(
    fn=transcriptor.transcribe_audio,
    inputs=[
        gr.Audio(sources="upload", type="filepath", label="Audio file"),
        gr.Radio([True, False], value=True, label="Enable audio enhancement"),
    ],
    outputs=[
        gr.Textbox(label="Transcription"),
        # gr.File(label="Download Transcription"),
        # gr.Textbox(label="Console Output", lines=10)
    ],
    title="Audio-Transcription leveraging Whisper Model",
    description=(
        "Transcribe microphone recording or audio inputs and return the transcription with speaker diarization."
    ),
    allow_flagging="never",
)


with demo:
    gr.TabbedInterface([microphone_transcribe, file_transcribe], ["Microphone", "Audio file"])

demo.queue().launch()