soiz commited on
Commit
8ae4519
·
verified ·
1 Parent(s): 0be617c

Create .html

Browse files
Files changed (1) hide show
  1. .html +148 -0
.html ADDED
@@ -0,0 +1,148 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <!DOCTYPE html>
2
+ <html lang="en">
3
+ <head>
4
+ <meta charset="UTF-8">
5
+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
6
+ <title>Audio Conversion Form</title>
7
+ <style>
8
+ body {
9
+ font-family: Arial, sans-serif;
10
+ margin: 20px;
11
+ }
12
+ form {
13
+ max-width: 600px;
14
+ margin: auto;
15
+ padding: 20px;
16
+ border: 1px solid #ccc;
17
+ border-radius: 10px;
18
+ background-color: #f9f9f9;
19
+ }
20
+ label {
21
+ display: block;
22
+ margin-bottom: 5px;
23
+ font-weight: bold;
24
+ }
25
+ input, select {
26
+ width: 100%;
27
+ margin-bottom: 15px;
28
+ padding: 8px;
29
+ box-sizing: border-box;
30
+ }
31
+ button {
32
+ padding: 10px 20px;
33
+ background-color: #007BFF;
34
+ color: #fff;
35
+ border: none;
36
+ border-radius: 5px;
37
+ cursor: pointer;
38
+ }
39
+ button:disabled {
40
+ background-color: #ccc;
41
+ }
42
+ .error {
43
+ color: red;
44
+ font-size: 0.9em;
45
+ }
46
+ </style>
47
+ </head>
48
+ <body>
49
+
50
+ <h1>Audio Conversion Form</h1>
51
+ <p>Fill in the form below to convert your audio files. Please ensure all inputs are valid.</p>
52
+
53
+ <form id="conversionForm" enctype="multipart/form-data">
54
+ <label for="source">Source File (Required):</label>
55
+ <input type="file" id="source" name="source" accept=".wav,.mp3" required>
56
+ <span id="sourceError" class="error"></span>
57
+
58
+ <label for="target">Target File (Required):</label>
59
+ <input type="file" id="target" name="target" accept=".wav,.mp3" required>
60
+ <span id="targetError" class="error"></span>
61
+
62
+ <label for="diffusion_steps">Diffusion Steps (Integer, Required):</label>
63
+ <input type="number" id="diffusion_steps" name="diffusion_steps" min="1" step="1" required>
64
+ <span id="stepsError" class="error"></span>
65
+
66
+ <label for="length_adjust">Length Adjust (Float, Optional):</label>
67
+ <input type="number" id="length_adjust" name="length_adjust" step="0.01" required>
68
+
69
+ <label for="inference_cfg_rate">Inference CFG Rate (Float, Optional):</label>
70
+ <input type="number" id="inference_cfg_rate" name="inference_cfg_rate" step="0.01" required>
71
+
72
+ <label for="f0_condition">F0 Condition (Yes/No):</label>
73
+ <select id="f0_condition" name="f0_condition" required>
74
+ <option value="true">Yes</option>
75
+ <option value="false">No</option>
76
+ </select>
77
+
78
+ <label for="auto_f0_adjust">Auto F0 Adjust (Yes/No):</label>
79
+ <select id="auto_f0_adjust" name="auto_f0_adjust" required>
80
+ <option value="true">Yes</option>
81
+ <option value="false">No</option>
82
+ </select>
83
+
84
+ <label for="pitch_shift">Pitch Shift (Integer, Optional):</label>
85
+ <input type="number" id="pitch_shift" name="pitch_shift" step="1" required>
86
+
87
+ <button type="submit">Convert</button>
88
+ </form>
89
+
90
+ <p id="outputMessage"></p>
91
+ <audio id="resultAudio" controls style="display:none;"></audio>
92
+
93
+ <script>
94
+ document.getElementById('conversionForm').addEventListener('submit', async (event) => {
95
+ event.preventDefault(); // Prevent form submission
96
+ const form = event.target;
97
+ const formData = new FormData(form);
98
+
99
+ // Reset error messages
100
+ document.querySelectorAll('.error').forEach(el => el.textContent = '');
101
+
102
+ // Validate inputs
103
+ let isValid = true;
104
+
105
+ if (!formData.get('source')) {
106
+ document.getElementById('sourceError').textContent = 'Source file is required.';
107
+ isValid = false;
108
+ }
109
+
110
+ if (!formData.get('target')) {
111
+ document.getElementById('targetError').textContent = 'Target file is required.';
112
+ isValid = false;
113
+ }
114
+
115
+ if (!isValid) return;
116
+
117
+ try {
118
+ // Disable the button to prevent multiple submissions
119
+ form.querySelector('button').disabled = true;
120
+
121
+ const response = await fetch('https://soiz-seed-vc-api.hf.space/convert', {
122
+ method: 'POST',
123
+ body: formData,
124
+ });
125
+
126
+ if (!response.ok) {
127
+ throw new Error(`Server error: ${response.statusText}`);
128
+ }
129
+
130
+ // Handle the response
131
+ const blob = await response.blob();
132
+ const audioURL = URL.createObjectURL(blob);
133
+
134
+ const resultAudio = document.getElementById('resultAudio');
135
+ resultAudio.src = audioURL;
136
+ resultAudio.style.display = 'block';
137
+ document.getElementById('outputMessage').textContent = 'Conversion successful! Listen to the result below.';
138
+ } catch (error) {
139
+ console.error(error);
140
+ document.getElementById('outputMessage').textContent = `Error: ${error.message}`;
141
+ } finally {
142
+ form.querySelector('button').disabled = false;
143
+ }
144
+ });
145
+ </script>
146
+
147
+ </body>
148
+ </html>