File size: 965 Bytes
c569b48
81e4ee2
 
 
 
 
 
 
 
f36e52e
81e4ee2
 
 
 
 
a77426c
c569b48
81e4ee2
 
 
 
c569b48
f36e52e
81e4ee2
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
import gradio as gr
from audio_processing import process_audio, print_results
def transcribe_audio(audio_file):
    language_segments, final_segments = process_audio(audio_file)
    
    output = "Detected language changes:\n\n"
    for segment in language_segments:
        output += f"Language: {segment['language']}\n"
        output += f"Time: {segment['start']:.2f}s - {segment['end']:.2f}s\n\n"

    output += "Transcription with language detection and speaker diarization:\n\n"
    for segment in final_segments:
        output += f"[{segment['start']:.2f}s - {segment['end']:.2f}s] ({segment['language']}) Speaker {segment['speaker']}: {segment['text']}\n"
        # output += f"[{segment['start']:.2f}s - {segment['end']:.2f}s] ({segment['language']}): {segment['text']}\n"
    return output

iface = gr.Interface(
    fn=transcribe_audio,
    inputs=gr.Audio(type="filepath"),
    outputs="text",
    title="WhisperX Audio Transcription"
)

iface.launch()