File size: 1,497 Bytes
1d0abcd
6cf7dc2
1d0abcd
 
 
 
 
 
 
 
 
 
9aa62c0
1d0abcd
 
 
 
 
 
9aa62c0
1d0abcd
 
 
9aa62c0
1d0abcd
 
 
 
 
 
 
 
 
 
 
 
 
 
9aa62c0
 
1d0abcd
 
9aa62c0
1d0abcd
 
 
 
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
import gradio as gr
from video_accent_analyzer import VideoAccentAnalyzer

analyzer = VideoAccentAnalyzer()


def analyze_video(url=None, video_file=None):
    if url:
        result = analyzer.analyze_video_url(url)
    elif video_file:
        result = analyzer.analyze_local_video(video_file)
    else:
        return "❌ Please provide a video URL or upload a file"

    if 'error' in result:
        return f"❌ Error: {result['error']}"

    markdown = f"## 🎯 Results\n"
    markdown += f"**Predicted Accent:** {result['predicted_accent']}\n"
    markdown += f"**Confidence:** {result['confidence']:.1f}%\n"
    markdown += f"**English Confidence:** {result['english_confidence']:.1f}%\n\n"
    markdown += "### πŸ“Š Probability Breakdown:\n"

    for accent, prob in sorted(result['probabilities'].items(), key=lambda x: x[1], reverse=True):
        markdown += f"- {accent}: {prob:.1f}%\n"

    return markdown


# Create Gradio interface
interface = gr.Interface(
    fn=analyze_video,
    inputs=[
        gr.Textbox(label="Video URL (YouTube/Loom/Direct MP4)"),
        gr.File(label="Or Upload Video File", type="filepath")
    ],
    outputs=gr.Markdown(label="Analysis Results"),
    examples=[
        ["https://www.youtube.com/watch?v=abc123 ", None],
        [None, "example_video.mp4"]
    ],
    title="🎧 Video Accent Analyzer",
    description="Detect English accents in videos from YouTube, Loom, or uploaded files"
)

if __name__ == "__main__":
    interface.launch()