File size: 3,122 Bytes
489a593
 
 
 
 
ea2069e
489a593
ea2069e
 
 
 
 
 
489a593
ea2069e
 
 
 
 
 
 
489a593
ea2069e
 
489a593
ea2069e
 
 
 
 
489a593
ea2069e
 
 
 
 
 
 
 
489a593
ea2069e
 
489a593
 
 
ea2069e
 
 
 
 
 
 
489a593
 
 
ea2069e
 
 
 
 
b30b59c
ea2069e
 
 
 
 
 
 
489a593
ea2069e
 
 
 
 
 
489a593
ea2069e
 
489a593
ea2069e
 
 
 
489a593
 
 
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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Audio Transcriptor</title>
    <style>
        body {
            font-family: Arial, sans-serif;
            background: #1a1a2e;
            color: #fff;
            text-align: center;
            padding: 20px;
        }
        .container {
            max-width: 600px;
            margin: 0 auto;
            background: #16213e;
            padding: 20px;
            border-radius: 10px;
            box-shadow: 0 10px 20px rgba(0, 0, 0, 0.3);
        }
        h1 {
            margin-bottom: 20px;
        }
        #language, #transcription {
            margin: 10px 0;
            padding: 10px;
            background: #0f172a;
            border-radius: 5px;
        }
        #downloadLink {
            display: inline-block;
            margin-top: 10px;
            padding: 10px 20px;
            background: #00b4db;
            color: #fff;
            text-decoration: none;
            border-radius: 5px;
        }
        #downloadLink:hover {
            background: #0083b0;
        }
    </style>
</head>
<body>
    <div class="container">
        <h1>Audio Transcriptor</h1>
        <p>Visit the Gradio app to upload or record audio: <a href="https://huggingface.co/spaces/omar1232/Advanced_Audio_Visualizer" target="_blank">Link</a></p>
        <div id="language">Detected Language: Waiting...</div>
        <div id="transcription">Transcription: Waiting...</div>
        <a id="downloadLink" style="display: none;" href="#" download>Download Transcription</a>
    </div>

    <script>
        async function fetchTranscription() {
            try {
                const response = await fetch('https://huggingface.co/spaces/omar1232/Advanced_Audio_Visualizer/api/predict', {
                    method: 'POST',
                    headers: { 'Content-Type': 'application/json' },
                    body: JSON.stringify({ fn_index: 0, data: [null, null] }) // Adjust fn_index based on Gradio API
                });
                const result = await response.json();
                const [language, transcription, textFile] = result.data;

                // Update UI
                document.getElementById('language').textContent = `Detected Language: ${language || 'Unknown'}`;
                document.getElementById('transcription').textContent = `Transcription: ${transcription || 'No transcription available'}`;
                
                // Update download link
                if (textFile) {
                    const downloadLink = document.getElementById('downloadLink');
                    downloadLink.href = textFile;
                    downloadLink.style.display = 'inline-block';
                    downloadLink.textContent = 'Download Transcription';
                }
            } catch (error) {
                console.error('Error fetching transcription:', error);
            }
        }

        // Poll every 1 second
        setInterval(fetchTranscription, 1000);
    </script>
</body>
</html>